When i try to run this code in Visual Studio 2010 from here . i am getting the following error
OpenCV Error: Assertion failed ((img.depth() == CV_8U || img.depth() == CV_32F)
&& img.type() == templ.type()) in cv::matchTemplate, file ..\..\..\..\opencv\mod
ules\imgproc\src\templmatch.cpp, line 249
An exception occured
It seems you don't load images successfully. So make sure you pass in images correctly by setting argv[]
. Pay attention to the following lines of the code:
if(argc <= 1)
{
std::cout<<"\n Help "<<std::endl;
std::cout<<"\n ------------------------------------\n"<<std::endl;
std::cout<<"./blink_detect open_eye.jpg close_eye.jpg\n"<<std::endl;
std::cout<<"Eg :: ./blink_detect 2.jpg 3.jpg\n"<<std::endl;
std::cout<<"\n ------------------------------------\n"<<std::endl;
exit(0);
}
... ...
img1 = imread( argv[1], 1 );
img2 = imread( argv[2], 1 );
Edit : You can set argv[]
in two ways:
Through project's command arguments:
Project > Configuration Properties > Debugging > Command Arguments > 2.jpg 3.jpg
Directly in the source code:
argc = 3; argv[1] = "2.jpg"; argv[2] = "3.jpg";
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.