Since in my embedded application I need images in grayscale, in order to save time I'm trying to get a frame from the webcam directly in grayscale without getting it from RGB format conversion.
因为在我的嵌入式应用程序中,我需要灰度图像,为了节省时间,我试图直接以灰度从网络摄像头获取帧,而不是从RGB格式转换。
The examples that I've found gets the frame in RGB and then converts it with
我发现的示例获取RGB中的帧,然后将其转换为
cvCvtColor(im_rgb,im_gray,CV_RGB2GRAY)
Thanks.
2 个解决方案
#1
1
On Linux, simply use the v4l2-ctl
command to reduce all saturation and get the camera to spit out grayscale output:
在Linux上,只需使用v4l2-ctl命令降低所有饱和度并让相机吐出灰度输出:
v4l2-ctl -c saturation=0
Of course, that will work only if your webcam supports the saturation
option. To check whether it does, take a look at all available controls:
当然,只有当您的网络摄像头支持饱和度选项时,这才有效。要检查它是否存在,请查看所有可用的控件:
v4l2-ctl -l
#2
0
In short, NO!
总之,不!
Most of the camera output are in YUV formats. The videoCapture function converts this to RGB. cvSetCaptureProperty
function can be used to set the value of CV_CAP_PROP_CONVERT_RGB
flag as FALSE. Thus the output will be in YUV. Converting this image to gray scale image.
大多数相机输出都是YUV格式。 videoCapture函数将其转换为RGB。 cvSetCaptureProperty函数可用于将CV_CAP_PROP_CONVERT_RGB标志的值设置为FALSE。因此输出将为YUV。将此图像转换为灰度图像。
By doing so, we could avoid the YUV-to-RGB conversion. And the YUV-to-Gray conversion is computationally less intensive as Y-channel is indeed the gray data. I am not so sure, will have to give it a try.
通过这样做,我们可以避免YUV到RGB的转换。由于Y通道确实是灰度数据,因此YUV到灰度的转换在计算上不那么密集。我不太确定,将不得不试一试。
#1
1
On Linux, simply use the v4l2-ctl
command to reduce all saturation and get the camera to spit out grayscale output:
在Linux上,只需使用v4l2-ctl命令降低所有饱和度并让相机吐出灰度输出:
v4l2-ctl -c saturation=0
Of course, that will work only if your webcam supports the saturation
option. To check whether it does, take a look at all available controls:
当然,只有当您的网络摄像头支持饱和度选项时,这才有效。要检查它是否存在,请查看所有可用的控件:
v4l2-ctl -l
#2
0
In short, NO!
总之,不!
Most of the camera output are in YUV formats. The videoCapture function converts this to RGB. cvSetCaptureProperty
function can be used to set the value of CV_CAP_PROP_CONVERT_RGB
flag as FALSE. Thus the output will be in YUV. Converting this image to gray scale image.
大多数相机输出都是YUV格式。 videoCapture函数将其转换为RGB。 cvSetCaptureProperty函数可用于将CV_CAP_PROP_CONVERT_RGB标志的值设置为FALSE。因此输出将为YUV。将此图像转换为灰度图像。
By doing so, we could avoid the YUV-to-RGB conversion. And the YUV-to-Gray conversion is computationally less intensive as Y-channel is indeed the gray data. I am not so sure, will have to give it a try.
通过这样做,我们可以避免YUV到RGB的转换。由于Y通道确实是灰度数据,因此YUV到灰度的转换在计算上不那么密集。我不太确定,将不得不试一试。