【问题标题】:Shape Detection using OpenCV from live video stream使用实时视频流中的 OpenCV 进行形状检测
【发布时间】:2016-01-27 16:05:10
【问题描述】:

在这个post 中,考虑了OpenCV 中的形状检测(来自图像)的主题。扩展话题,如何通过 OpenCV 从实时视频流中实时检测形状?

【问题讨论】:

  • 只需使用VideoCapture,并将每一帧视为单个图像

标签: opencv image-processing video-processing


【解决方案1】:

是的,可以使用 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 cudaopencv gpu 库可能会为您提供所需的更快速度。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-25
    • 1970-01-01
    • 2014-03-28
    • 2014-07-25
    • 2014-09-04
    • 2011-09-13
    • 1970-01-01
    相关资源
    最近更新 更多