title: Unhandled exception in Visual Studio while using Open CV
body: <p>I'm new to Visual Studio. I keep getting an error: Unhadled exception occurred at [some memory location] in Project1.exe
  The memory location keeps changing each time I hit debug. I have tried really very simple codes, but still I keep getting this error.</p>
  
  <p>The window that opens when I debug also gives an error:</p>
  
  <p><em>OpenCV Error: Assertion Failed (scn == 3 || scn == 4) in unknown function, file ..\..\..\src\opencv\modules\imgproc\src\color.cpp, line 3042</em></p>
  
  <p>The code I'm running is:</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;iostream&gt;
      #include &lt;vector&gt;
      #include "opencv2/core/core.hpp"
      #include "opencv2/features2d/features2d.hpp"
      #include "opencv2/highgui/highgui.hpp"
      #include "opencv2/calib3d/calib3d.hpp"
      #include "opencv2/video/video.hpp"
      #include "opencv2/opencv.hpp"
      using namespace cv;
      using namespace std;
  
      int main (int argc, char *argv[])
      {
        cv::Mat frame;
        cv::Mat back;
        cv::Mat fore;
        cv::Mat edges;
        VideoCapture cap (0);
        BackgroundSubtractorMOG2 bg;
        bg.set ("nmixtures", 3);
        bg.set ("detectShadows", false);
        std::vector &lt; std::vector &lt; cv::Point &gt; &gt;contours;
  
        cv::namedWindow ("Frame");
        cv::namedWindow ("Background");
  
        for (;;)
          {
            cap &gt;&gt; frame;
            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) &gt;= 0) break;
  
          }
          return 0;
      }
  </code></pre>