문제

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.

The examples that I've found gets the frame in RGB and then converts it with

cvCvtColor(im_rgb,im_gray,CV_RGB2GRAY)  

Thanks.

도움이 되었습니까?

해결책

On Linux, simply use the v4l2-ctl command to reduce all saturation and get the camera to spit out grayscale output:

 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

다른 팁

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top