python - 使用 PyCapture2 和 OpenCV 从 Point Grey 相机获取图像

标签 python opencv flycapture

我正在尝试使用 PyCapture2 从 Point Grey Camera 获取图像,PyCapture2 由他们作为 FlyCapture2 的 python 包装器提供。我可以检索图像缓冲区,但无法将图像作为 Mat 数据类型获取到 OpenCV 中。

供引用:

while not cv2.waitKey(100) & 0xFF == ord('q'):
    try:
        raw_object = camera.retrieveBuffer()
    except PyCapture2.Fc2error as fc2Err:
        print "Error retrieving buffer : ", fc2Err
        continue

    rgb_object = raw_object.convert(PyCapture2.PIXEL_FORMAT.BGR)

如何将这个 rgb_object 转换成 Mat Image?

最佳答案

这是我做的:

image = cam.retrieveBuffer()
row_bytes = float(len(image.getData()))/float(image.getRows());
cv_image = np.array(image.getData(), dtype="uint8").reshape( (image.getRows(), image.getCols()) );
cv2.imshow('frame',cv_image)

如果你想要彩色图像:

color_cv_image = cv2.cvtColor(cv_image, cv2.COLOR_BAYER_BG2BGR)

引用:http://answers.opencv.org/question/74788/point-grey-usb3-camera-pixel-color-format/

关于python - 使用 PyCapture2 和 OpenCV 从 Point Grey 相机获取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44012780/

相关文章:

python - 如何在 Jupyter 笔记本中包装代码/文本

python在字符串中求解方程

python - Python OpenCV中ARGB、RGBA色彩空间的区别

python - 如何使用 OpenCV (python) 检测此图像中的岩石?

matlab在获取pointgrey图像时崩溃

python:从读取文本文件并提取单列的循环创建变量

python - 提高输出两幅图像之间不同像素的 Python 函数的性能

c++ - 在 FlyCapture2 C++ API 中使用 embeddedFrameCounter

Python:Sphinx namedtuple 文档