禁用`CV_CAP_PROP_CONVERT_RGB`有什么作用? [英] What does disabling `CV_CAP_PROP_CONVERT_RGB` do?
本文介绍了禁用`CV_CAP_PROP_CONVERT_RGB`有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用opencv获取原始摄像机输出.如果我正常阅读图像,则会得到640x480x3的图像:
I'm attempting to get raw camera output with opencv. If I read an image normally I get a 640x480x3 image:
>>> import cv2
>>> cap = cv2.VideoCapture(2)
>>> _, im = cap.read()
>>> im.shape
(480, 640, 3)
如果我禁用 cv2.CAP_PROP_CONVERT_RGB
,那么我会得到一个大小异常的数组,其结尾始终为零:
If I disable cv2.CAP_PROP_CONVERT_RGB
then I get a strangely sized array, the end of which is always zeros:
>>> cap.set(cv2.CAP_PROP_CONVERT_RGB, False)
True
>>> _, im = cap.read()
>>> im.shape
(1, 614400)
>>> cv2.imshow('im', im.reshape((960, 640))); cv2.waitKey(0)
生成的图像"为:
该如何处理这些数据以从中获取实际图像?
What do I do with this data to get an actual image from it?
推荐答案
来自 videoio.hpp
:
CAP_PROP_CONVERT_RGB = 16,//!<布尔型标志,指示是否应将图像转换为RGB.
CAP_PROP_CONVERT_RGB =16, //!< Boolean flags indicating whether images should be converted to RGB.
例如,您需要解码一维数据.
For your example, you need to decode the 1D data.
cv2.imshow('im', cv2.imdecode(im,-1))
这篇关于禁用`CV_CAP_PROP_CONVERT_RGB`有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文