[英]Displaying Images from file using OpenCV VideoCapture, and C++ vectors
[英]Wrong size of VideoCapture using OpenCv in C++
我正在嘗試使用 OpenCv 在 C++ 中制作實時跟蹤應用程序。 我的代碼到目前為止工作,但顯示的相機分辨率太小。 如果我使用 Windows 相機應用程序拍攝照片/視頻,分辨率為 1280x720,我的程序中顯示的分辨率為 639x479。 這是我的代碼:
using namespace cv;
using namespace std;
int main(int argc)
{
VideoCapture camera(0);
if (!camera.isOpened()) {
cerr << "ERROR: Could not open camera" << endl;
return 1;
}
namedWindow("Webcam");
Mat frame;
while (1) {
camera >> frame;
imshow("Webcam", frame);
if (waitKey(1) >= 0) {
break;
}
}
return 0;
}
我嘗試使用resizeWindow("Webcam", 1280, 720)
但 window 自動調整回 639x479。 如果我把Window全屏,相機分辨率還是639x479。 我認為問題是某些 VideoCapture 默認值,但我不確定。 如何將捕獲和顯示的分辨率設置為 1280x720?
這也可能是驅動程序問題(請參閱 answers.opencv,該問題經常發生)。 您也可以嘗試camera.set(CAP_PROP_FRAME_WIDTH, 1280.0)
和相同的高度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.