尝试使用Qt和OpenCV从高清网络摄像头获得1080p的实时feed,只能获得480p
Trying to get 1080p live feed from HD webcam using Qt and OpenCV only get 480p
我试图使用Qt和OpenCV获得全高清处理,目前我只能获得480p,正如您可以在代码中看到的,我已经获得了框架的宽度和高度。我还尝试设置使用cvSize(1920 x 1080)的大小,但它不会改变分辨率。
非常感谢您的帮助!
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
VideoCapture cap(1); //capture webcam
if (!cap.isOpened()) //if not successful then exit
{
qDebug() << "Cannot open webcam";
return -1;
}
namedWindow("Camera feed", CV_WINDOW_AUTOSIZE); //create window
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get width of frames of video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get height of frames of video
Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));
qDebug() << "Frame size = " << dWidth << "x" << dHeight << endl;
VideoWriter oVideoWriter("video.avi", CV_FOURCC('M','P','E','G'), 20, frameSize);
if(!oVideoWriter.isOpened())
{
qDebug() << "ERROR: Failed to write the video" << endl;
return -1;
}
while(1)
{
Mat frame;
bool bSuccess = cap.read(frame); //read a new frame from video
if(!bSuccess) //if unsuccessful, break loop
{
qDebug() << "Cannot read frame from video file" << endl;
break;
}
oVideoWriter.write(frame); //write the frame into the file
imshow("Camera feed", frame); //show the frame in "Live Feed" window
qDebug() << "Recording" << endl;
if (waitKey(30) == 27)
{
qDebug() << "Esc key is pressed by user" << endl;
break;
}
}
return 0;
}
您是否尝试过通过设置属性来强制捕获HD:
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
如果是,请检查该分辨率是否被设备在其他程序(如guvcview或v442 -ctl)中支持。如果您安装了最后一个,您可以使用以下命令检查支持的模式:v4l2-ctl --list-formats
相关文章:
- 从数据库实时显示QT c++中的数据
- 在 Windows 8/10 技术中完全实时的屏幕捕获,没有延迟
- 有没有办法使用 c++ 实时阅读文本?
- 在本地网络中通过OpenCV(C++)实时流式传输图像
- 将相机数据从服务器实时流式传输到客户端
- 将实时(非静态)放在qt(c ++)上
- 线程之间的实时数据共享
- 如何在实时应用程序中锁定线程
- OpenCV - 来自相机的实时馈送不流畅
- 如何提高 OpenCV 实时检测器应用程序的帧率?
- 使用 Opencv 将姿势值实时写入文本文件
- Firebase C++ Windows 上的实时数据库连接丢失
- 我在 IDA 或 dbg 或 olly 上看到的内存是否与我在 RAM 上实时加载的内存相同?
- 媒体基金会:WavSink以比实时消耗率更快的速度处理音频-是否可以实时限制后台处理
- 如何实时捕获相机的视频?
- ROOT中的实时更新
- C# 的垃圾回收会给实时音频应用程序带来问题吗?
- 如何编写日志文件,以便可以使用记事本实时读取它以进行C++
- QChart实时性能
- 尝试使用Qt和OpenCV从高清网络摄像头获得1080p的实时feed,只能获得480p