我想用Python和OpenCV从视频中捕获帧,然后用Tensorflow对捕获的Mat图像进行分类。问题是我不知道如何将Mat格式转换为3D Tensor变量。这是我目前使用Tensorflow(从文件加载图像)的方式:
image_data = tf.gfile.FastGFile(imagePath, 'rb').read()
with tf.Session() as sess:
softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
predictions = sess.run(softmax_tensor,
{'DecodeJpeg/contents:0': image_data})
我将非常感激任何帮助,提前致谢。