Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top