我正在使用 Logitech C920 和 OpenCV 开发一个小型网络摄像头应用程序。
在给定的分辨率下,我实际上可以毫无问题地从相机获取图像。但除了帧的宽度和高度,我无法访问相机中的任何设置。我有以下代码。您可以猜到,代码生成了除前两行之外的所有零行。
难道我做错了什么?或者这是罗技的另一个专有 BS?如果这是 OpenCV 的限制,是否还有其他选项可以在 Windows 操作系统中为该网络摄像头开发应用程序?
m_cam.open(0);
if(!m_cam.isOpened() ) // check if we succeeded
{
std::cerr << "ERROR: Could not open cameras." << std::endl;
return;
}
int ex = static_cast<int>(m_cam.get(CV_CAP_PROP_FOURCC));
char EXT[] = {ex & 0XFF , (ex & 0XFF00) >> 8,(ex & 0XFF0000) >> 16,(ex & 0XFF000000) >> 24, 0};
m_cam.set(CV_CAP_PROP_FOURCC,CV_FOURCC('H','2','6','4'));
m_cam.set(CV_CAP_PROP_FRAME_WIDTH,1280);//2304);//1829//1200//800
m_cam.set(CV_CAP_PROP_FRAME_HEIGHT,720);//1536); //1080//800//600
m_cam.set(CV_CAP_PROP_FPS, 30);
//m_cam.set(CV_CAP_PROP_EXPOSURE,0);
std::cout<< m_cam.get(CV_CAP_PROP_FRAME_WIDTH) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_FRAME_HEIGHT) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_FPS) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_EXPOSURE) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_FORMAT) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_CONTRAST) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_BRIGHTNESS) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_SATURATION) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_HUE) << std::endl;
std::cout<< m_cam.get(CV_CAP_PROP_POS_FRAMES) << std::endl;