Hi
I have a camera with 1600x1300 resolution at 8 or 16 bits grayscale.
I grab the frames using this program:
VideoCapture cap1;
Mat CameraFrame1;
cap1.open(0);
cap1.set(cv::CAP_PROP_FRAME_WIDTH, 640);
cap1.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
//cap1.set(cv::CAP_PROP_CONVERT_RGB, 0);
//cap1.set(cv::CAP_PROP_FORMAT, CV_8UC1);
int grabFormat = cap1.get(cv::CAP_PROP_FORMAT);
cout << "Format = " << type2str(grabFormat) << endl;
int frame = 0;
for (;;)
{
cap1 >> CameraFrame1;
int numRows = CameraFrame1.rows;
int numCols = CameraFrame1.cols;
int type = CameraFrame1.type();
// some frame processing
....
frame++;
if (frame == 100) {
cout << "type = " << type2str(type) << " c,r = " << numCols << "," << numRows << endl;
frame = 0;
}
// Wait for Escape keyevent to exit from loop
char keypressed = (char)waitKey(10);
if (keypressed == 27)
break;
}
I get this output:
Format = 8UC1
type = 8UC3 c,r = 640,480
type = 8UC3 c,r = 640,480
type = 8UC3 c,r = 640,480
type = 8UC3 c,r = 640,480
type = 8UC3 c,r = 640,480
type = 8UC3 c,r = 640,480
....
So the VideoCapture indicates format 8UC1, but the captured frames are of type 8UC3!
Enabling the line
cap1.set(cv::CAP_PROP_CONVERT_RGB, 0);
or line
cap1.set(cv::CAP_PROP_FORMAT, CV_8UC1);
does not make any difference.
Also strange is that if I do not set the resolution to 640x480, the captured frames are
1600x1300 of 8UC1 type! So then it is ok!
Note that at the start of the program I get these two warnings:
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1034) getProperty OpenCV | GStreamer warning: unhandled property: 8
Removing the lines
int grabFormat = cap1.get(cv::CAP_PROP_FORMAT);
cout << "Format = " << type2str(grabFormat) << endl;
will remove the second warning. But the frames are still of type 8UC3.
How can I prevent the rgb conversion?