Ask Your Question

Why does cap.get(CV_CAP_PROP_FORMAT) return 0?

asked 2013-09-23 13:25:17 -0500

wpd gravatar image

Consider the following snippet of code:

VideoCapture cap(argv[1]);
int frame_format = cap.get(CV_CAP_PROP_FORMAT);

When I run this, and pass in a .bmp file as argv[1], the call to get(CV_CAP_PROP_FORMAT) returns 0. I would have expected it to return 16 (CV_8UC3).

When I fetch an image from the file with

cap >> image;
int image_type = image.type();

I get the 16 I expect.

Thanks for any tips you can give me.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-09-23 13:40:05 -0500

Moster gravatar image

From the opencv docs: "Note: When querying a property that is not supported by the backend used by the VideoCapture class, value 0 is returned."

edit flag offensive delete link more


Thank you for your answer. I guess that makes sense, although it is a bit confusing that, when reading from a .bmp file with a fixed format, OpenCV is unable to determine the format of the data.

Is it possible that CV_CAP_PROP_FORMAT doesn't return the CV_<bit-depth>{U|S|F}C(<number_of_channels>) value that I naively expected it would?

I'm going to go ask a different question now...


wpd gravatar imagewpd ( 2013-09-23 13:56:58 -0500 )edit

If it works, it should be returning the Mat type you get from the VideoCapture object.

CV_CAP_PROP_FORMAT: Format of the Mat objects returned by retrieve() . (doc)

Moster gravatar imageMoster ( 2013-09-23 14:13:04 -0500 )edit

It just means that your camera drivers, do not support querrying the frame format.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-24 03:39:42 -0500 )edit

Thanks. I was confused that the "camera driver" for reading .bmp files does not support querying the frame format. From your answer to my other question, it would seem that the default format is CV_8UC3 and that I should be able to assume that in the absence of any other knowledge.

I'm ok with that. I wish it were better documented somewhere.

wpd gravatar imagewpd ( 2013-09-24 08:33:08 -0500 )edit

I commented on that topic how you can propose adaptations for the documents. OpenCV doesn't have a technical writer for the moment, so basically it depends on the help of the community to come up with adaptations, changes and extras.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-24 08:46:06 -0500 )edit

Question Tools


Asked: 2013-09-23 13:25:17 -0500

Seen: 6,425 times

Last updated: Sep 23 '13