> frame; //some othe-6ren">
gpt4 book ai didi

c++ - Imshow 视频的特定部分

转载 作者:行者123 更新时间:2023-11-28 00:03:09 29 4
gpt4 key购买 nike

我有一个视频截图,没什么特别的:

VideoCapture cap("video.mp4"); 
Mat frame;

while (true) {
cap >> frame;
//some other stuff...
}

然后我显示分辨率为 800、600 的视频。我的问题是,如何显示视频的预定义区域,例如在坐标 50x、100y 中?

最佳答案

您可以只显示每一帧的裁剪,这可以通过使用 Rect 定义感兴趣区域 (ROI) 来获得:

VideoCapture cap("video.mp4"); 
Mat frame;
Mat crop;
Rect roi(50, 100, 200, 200); // Your Region of Interest

while (true) {
cap >> frame;
crop = frame(roi);
imshow("Cropped Video", crop);
waitKey(1);
}

关于c++ - Imshow 视频的特定部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37419563/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com