Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV: record footage in one window and Display the same video in 2nd window but with contours only
    text
    copied!<p>I want to capture a video and display it on one window and have second window in which contours are displayed simultaneous. I am struggling with how to have the processed video displayed in the second window. Please analyze my code and suggest a solution or indicate where am going wrong maybe give me some directions to an online tutorial or sources. Thanks.</p> <pre><code> #include "iostream" #include&lt;opencv\cv.h&gt; #include&lt;opencv\highgui.h&gt; #include&lt;opencv\ml.h&gt; #include&lt;opencv\cxcore.h&gt; #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;string&gt; #include &lt;opencv2/core/core.hpp&gt; // Basic OpenCV structures (cv::Mat) #include &lt;opencv2/highgui/highgui.hpp&gt; // Video write using namespace cv; using namespace std; Mat image; Mat image_gray; Mat image_gray2; Mat threshold_output; Mat frame; int thresh=100, max_thresh=255; int main(int argc, char** argv) { //Capture Video VideoCapture capCam(1); if (!capCam.isOpened()){ cout&lt;&lt;"ERROR: Failed to Initialize Camera"&lt;&lt;endl; return 1; } else{ cout&lt;&lt;"Camera Initialized"&lt;&lt;endl; } //Create Window char* ImputFootage = "Source"; namedWindow(ImputFootage, CV_WINDOW_AUTOSIZE); imshow(ImputFootage, frame); char* OutputFootage = "Processed"; namedWindow(OutputFootage, CV_WINDOW_AUTOSIZE); imshow(OutputFootage, frame); while(1){ capCam&gt;&gt; frame; imshow("Source", frame); return(1); if(capCam.read(ImputFootage)){ //Convert Image to gray &amp; blur it cvtColor( image, image_gray, CV_BGR2GRAY ); blur( image_gray, image_gray2, Size(3,3) ); //Threshold Gray&amp;Blur Image threshold(image_gray2, threshold_output, thresh, max_thresh, THRESH_BINARY); //2D Container vector&lt;vector&lt;Point&gt;&gt; contours; //Fnd Countours Points, (Imput Image, Storage, Mode1, Mode2, Offset??) findContours(threshold_output, contours, // a vector of contours CV_RETR_EXTERNAL,// retrieve the external contours CV_CHAIN_APPROX_NONE, Point(0, 0)); // all pixels of each contours // Draw black contours on a white image Mat result(threshold_output.size(),CV_8U,Scalar(255)); drawContours(result,contours, -1, // draw all contours Scalar(0), // in black 2); // with a thickness of 2 } } char CheckForEscKey = waitKey(10); return 1; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload