繁体   English   中英

实时比较两个图像与预定义图像与Opencv c ++中的实时捕获图像

[英]Compare two image in real time with predefined image with real time capture image in Opencv c++

我正在做一个自动织物缺陷检测项目。 在这方面,我使用 [FFT][1](快速傅立叶变换)开发了算法,并且它在我的 Ubuntu 14.04 opencv c++ 但是现在我想将其开发为实时,我必须每 2 秒捕获一次图像,并且必须使用我开发的算法处理该图像。 我需要关于如何在opencv c++使用网络摄像头捕获图像并使用正在捕获的相同图像进行处理的想法。 如果有人知道这一点,请帮助我。 先感谢您。

您可以遵循 OpenCV 提供的指导 - 他们提供了足够的示例,例如以下示例代码。 以下代码由 OpenCV 开发团队提供作为示例。

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;
   Mat edges;
   namedWindow("edges",1);
   for(;;)
   {
       Mat frame;
       cap >> frame; // get a new frame from camera
       cvtColor(frame, edges, CV_BGR2GRAY);
       GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
       Canny(edges, edges, 0, 30, 3);
       imshow("edges", edges);
      if(waitKey(30) >= 0) break;
   }
   // the camera will be deinitialized automatically in VideoCapture       destructor
    return 0;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM