简体   繁体   中英

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

I am doing a project of Automatic fabric defect detection. In this i developed the algorithm using the [FFT][1] (Fast Fourier Transform) and its working fine in my Ubuntu 14.04 opencv c++ . But now i want to develop this to real time there i have to capture image every 2s and have to process that image with my developed algorithm. I need ideas on how to capture images using webcam in opencv c++ and to process withat same image which is being captured. Please do help me if anyone knows of this. Thank you in advance.

You can follow the guidance which has given by OpenCV - They have provided enough examples such as following sample code. Following code is provided by OpenCV Dev team as sample.

#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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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