【发布时间】:2017-11-03 17:06:24
【问题描述】:
我试图以完全相同的大小显示捕获。我试过这个:
// in the class.h
cv::Mat frame;
cv::VideoCapture capture;
我现在尝试了几种解决方案:
// Number 1: The size doesn't change at all.
this->capture.open(0);
or
this->capture.open(filename);
this->capture.set(CV_CAP_PROP_FRAME_WIDTH, 800);
this->capture.set(CV_CAP_PROP_FRAME_HEIGHT, 600);
-
// Number 2: Exception
this->capture.open(0);
or
this->capture.open(filename);
this->capture.read(this->frame);
if (!this->frame.empty())
cv::resize(this->frame, this->frame, cv::Size(800, 600));
-
// Number 3: Exception
this->capture.open(0);
or
this->capture.open(filename);
cv::resize(this->frame, this->frame, cv::Size(800, 600));
this->capture.read(this->frame);
这些都不起作用。知道如何正确调整它的大小吗?
【问题讨论】:
-
什么不起作用?你有其他尺寸的视频吗?我认为更多代码会有所帮助。
-
我看不出它需要更多代码。它不起作用,因为视频没有调整大小、网络摄像头或文件。
-
OP 用测试编辑。
-
// Number 3: Exception是否意味着您遇到了异常?如果是这样的话。在 3 中,在阅读之前调整框架大小没有任何意义。我同意 a-Jays 关于代码的观点 - 很难了解上下文。 -
是的,对于 2 也是,这意味着我遇到了异常。我不明白为什么你需要上下文,因为代码是非常自我解释的。但我想,有些人只是想投反对票。