【发布时间】:2016-01-27 16:05:10
【问题描述】:
在这个post 中,考虑了OpenCV 中的形状检测(来自图像)的主题。扩展话题,如何通过 OpenCV 从实时视频流中实时检测形状?
【问题讨论】:
-
只需使用
VideoCapture,并将每一帧视为单个图像
标签: opencv image-processing video-processing
在这个post 中,考虑了OpenCV 中的形状检测(来自图像)的主题。扩展话题,如何通过 OpenCV 从实时视频流中实时检测形状?
【问题讨论】:
VideoCapture,并将每一帧视为单个图像
标签: opencv image-processing video-processing
是的,可以使用 OpenCV 从视频流中检测形状 - 正如 Miki 提到的,VideoCapture 并将每一帧作为单个图像抓取将是做到这一点的方法。 C++ 中的代码类似于:
//inside your method, make sure to bring in the libraries needed
VideoCapture capture(0); //opens the first webcam on your computer
Mat frame;
while (true) {
capture >> frame; //pulls the next frame in
if (frame.empty()) { //makes sure it's not empty
printf("No frame!");
break;}
//do whatever you want with that frame here
imshow("framename", frame); //displays the frame to the user
waitKey(1); //longer gives you a longer delay between frames
}
实时执行此操作有点困难 - 根据相机上的帧速率有多快以及计算机处理程序的能力有多强,您可以将更新速率降低到几分之一秒。如果它仍然不够快,通过opencv cuda 或opencv gpu 库可能会为您提供所需的更快速度。
【讨论】: