Hi,
I'm trying to get frames from the HTC Vive front facing camera but I'm only getting seemingly gray frames out (though they are theoretically not empty).
My code looks like this:
int main() {
VideoCapture videoSource(0);
Size size{
(int)videoSource.get(CV_CAP_PROP_FRAME_WIDTH),
(int)videoSource.get(CV_CAP_PROP_FRAME_HEIGHT)
};
namedWindow("input", WINDOW_NORMAL);
resizeWindow("input", size.width, size.height);
Mat frameIn;
auto p1 = videoSource.get(CAP_PROP_MODE);
auto p2 = videoSource.get(CAP_PROP_FORMAT);
auto p3 = videoSource.get(CAP_PROP_FPS);
unsigned f = (unsigned)videoSource.get(CV_CAP_PROP_FOURCC);
char fourcc[] = {
(char)f,
(char)(f >> 8),
(char)(f >> 16),
(char)(f >> 24),
'\0'
};
cout << "\n\nCAPTURE DEVICE\n---------------"
<< "\nmode: " << p1
<< "\nformat: " << p2
<< "\nfps: " << p3
<< "\nFOURCC: " << string(fourcc)
<< "\nsize: " << size;
// One frame, to check info:
videoSource >> frameIn;
cout << "\n\nFRAME IN (MAT):\n--------------"
<< "\ntype: " << frameIn.type()
<< "\ndepth: " << frameIn.depth()
<< "\nsize: " << frameIn.size();
while (!frameIn.empty()) {
imshow("input", frameIn);
char key = waitKey(10);
if (key == 27) {
cvDestroyAllWindows();
break;
}
videoSource >> frameIn;
}
return 0;
}
And the output (other than a gray window) is:
CAPTURE DEVICE
mode: 0 format: 0 fps: 30.0003 FOURCC: YUY2 size: [612 x 460]
FRAME IN (MAT):
type: 16 depth: 0 size: [612 x 460]
I'm new to OpenCV so I might be missing something obvious. But from the above, it seems like the camera is being detected. The 4cc is yuy2 though, but it still returns 0 for mode and format.
When I check frameIn.empty()
is returns false, but as you can see, there doesn't seem to be anything in the mats.
Any help would be greatly appreciated.