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.
The window that opens when I debug also gives an error:
OpenCV Error: Assertion Failed (scn == 3 || scn == 4) in unknown function, file ..\..\..\src\opencv\modules\imgproc\src\color.cpp, line 3042
The code I'm running is:
#include <stdio.h>
#include <iostream>
#include <vector>
#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 < std::vector < cv::Point > >contours;
cv::namedWindow ("Frame");
cv::namedWindow ("Background");
for (;;)
{
cap >> 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) >= 0) break;
}
return 0;
}