How to find out image format retrieved via VideoCapture ?

asked 2015-03-21 12:59:58 -0600

I am retrieving frames from a video file. I am using VideoCapture class to perform this operation (the code that I am using is given below). It is retrieving a frame but I don't know whether it is RGB or HSV or some other format. How do I find out ?

Mat mFrame = new Mat();
VideoCapture camera = new VideoCapture("/home/ganesh/Videos/my_video_3.mkv");

boolean isCaptured = camera.grab();
boolean isRetrieved = camera.retrieve(mFrame);
edit retag flag offensive close merge delete

Comments

you're safe to assume 24bit bgr here.

berak gravatar imageberak ( 2015-03-21 13:57:11 -0600 )edit

how is it so ?

ganesh17 gravatar imageganesh17 ( 2015-03-21 22:38:20 -0600 )edit
1

BGR is the default color format for OpenCV, it has always been that way. Moreover, if you want to get more information about the loaded image you can use the .type() and .depth() attributes of the Mat structure.

theodore gravatar imagetheodore ( 2015-03-22 13:55:26 -0600 )edit

As berak said, it is always 24 BPP format. It can either be 8-bit gray scale with padded 16 bit or can also be BGR color data. Depends on data stored in the video.

Spark gravatar imageSpark ( 2015-03-23 05:44:21 -0600 )edit

@ganesh17, mark answers if it was helpful

Spark gravatar imageSpark ( 2015-03-23 05:44:41 -0600 )edit