Ask Your Question
0

Reading greyscale video files

asked 2013-09-16 14:05:00 -0600

Farshad gravatar image

Hi, I was wondering if there was a way to read in greyscale video files in OpenCV. I currently have to convert greyscale video into RGB format outside OpenCV, read it in and again convert it to greyscale using cvtColor() function... Is there anyway I can omit these counterintuitive steps and just grab greyscale frames from original video files?

edit retag flag offensive close merge delete

Comments

how do you convert to grb ? if you have a way to read that video, you might as well skip the videocapture, and use the frames directly.

berak gravatar imageberak ( 2013-09-16 14:18:19 -0600 )edit

I convert the original video to RGB outside OpenCV using VLC Media Player.

Farshad gravatar imageFarshad ( 2013-09-17 11:22:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-09-17 02:17:10 -0600

If you have grayscale video originally, then reading a frame from the stream, using the videoCapture interface will give you a fake BGR channel result, because all three channels will have the same intensity values set. You do not need a convert anymore, and you can basically split channels.

VideoCapture cap(0); // open the default camera
Mat frame, channel;
vector<Mat> channels;
cap >> frame; // get a new frame from camera
split(frame, channels);

Mat intensities_grey = channels[0];
edit flag offensive delete link more

Comments

Thanks Steven. In doing this, I get segmentation fault in FFMPEG_proxy (CvCapture_FFMPEG_proxy class). Is there any special setting for the FFMPEG decoder I have to implement? I am completely baffled with the complexity of this decoder so any help is greatly appreciated.

Farshad gravatar imageFarshad ( 2013-09-17 10:38:36 -0600 )edit

Additional information possibly relevant to this discussion (extracted from VLC Media Player)

Stream 0 Type: Video Code: 8 bits greyscale (GREY) Resolution: 1280x720 Display Resolution: 1280x720 Frame Rate: 30.096

thanks, Farshad.

Farshad gravatar imageFarshad ( 2013-09-17 11:10:24 -0600 )edit

Question Tools

Stats

Asked: 2013-09-16 14:05:00 -0600

Seen: 2,385 times

Last updated: Sep 17 '13