When I try to use the template matching method TM_CCOEFF
of opencv package, my python crashed. However no error message was shown on my terminal. I can use the normed method TM_CCOEFF_NOMRED
without any issue. I really need the implementation of TM_CCOEFF
The environment is Python2.7 from anaconda. OpenCV 2.4.11
The code is:
cv2.matchTemplate(img1, img2, eval('cv2.TM_CCOEFF'))
The error I got from Visual Studio debuger:
Unhandled exception at 0x74B5E4E4 in python.exe: 0xC0000005: Access violation writing location 0x00090FE8.
Error report file:
-
-
6.1
7601 Service Pack 1
(0x4): Windows 7 Enterprise
Enterprise
7601.23313.amd64fre.win7sp1_ldr.151230-0600
1130
Multiprocessor Free
X64
1033
-
APPCRASH
python.exe
0.0.0.0
4f84a6c8
opencv_core249.dll
0.0.0.0
5408cb57
c0000005
00005253
-
6.1.7601.2.1.0.256.4
1033
f8df
f8dfaee172ac09535f188b654ca18c90
6715
67151222e0799356f987ab35b4fd5e05
-
9829DFB7-2EA2-4836-A3C1-35C18A006A4F
Dell Inc.
OptiPlex 7010
A16
There is no other information I got from this crash. How can I solve this?
you always should check for the resources: c++ code:
Mat img; imread("im1.jpg",1);
if ( img.empty() )
{
cerr << "whaa!" << endl;
return 0;
}
result.create(result_rows, result_cols, CV_32FC1);
cvtColor(img, img, CV_BGR2GRAY); // <-- add this
cvtColor(templ, templ, CV_BGR2GRAY); // <-- add this
matchTemplate(img, templ, result, match_method);
This is C++ code but it worked for me.
User contributions licensed under CC BY-SA 3.0