如何在OpenCV相机捕获中动态调整帧大小和显示帧区域?
我试图建立一个模型,可以根据检测动态调整 OpenCV 中相机捕获的显示区域。我找到了调整帧和分辨率大小的方法,但是如果我想专注于整个捕获的特定区域该怎么办?我怎样才能做到这一点?
我尝试了 cv2.resize() 方法和 cap.set() 方法,它们分别更改了帧大小和分辨率,但我无法使提要聚焦于整个捕获帧的特定区域
I was trying to build a model that can dynamically adjust the display region of the camera capture in OpenCV according to the detections. I found frame and resolution resizing methods, but what if I want to focus on a particular region of the entire capture? How can I do that?
I tried the cv2.resize() method, and the cap.set() method, which changed the frame size and the resolution respectively, but I could not make the feed to get focused on a particular region of the entire captured frame
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我的想法是正确的,您想根据您的检测来裁剪图像的一部分坐标。 OpenCV 用数组表示图像,因此示例图像:
然后您只需通过索引访问数组的部分并获取其裁剪部分:
If I've got your idea correct, you want to crop a part of an image with coordinates based on your detection. OpenCV represents images with arrays, so with exaple image:
Then you just access array's part by indexing and get its cropped part: