Reputation: 241
I have to implement a cross correlation of two arrays in C++, and I think that could be do with template matching in OpenCV.
I started with a simple case:
double telo [3] ={0,1,2};
Mat prueba(1,3,CV_64F,telo);
double telo2[3] = {0,1,2};
Mat prueba2(1,3,CV_64F,telo2);
Mat result(1,50,CV_64F);
matchTemplate(prueba,prueba2,result,CV_TM_CCORR);
But it crashes, how can i do this? it is possible?
Thanks
Upvotes: 1
Views: 4832
Reputation: 5139
Error message reveals that only CV_8U
or CV_32F
types are used. The code runs with float
types. If you want to use double precision, you'll have to built your own function.
Working code:
float telo [3] ={0,1,2};
Mat prueba(1,3,CV_32F,telo);
float telo2[3] = {0,1,2};
Mat prueba2(1,3,CV_32F,telo2);
Mat result;
matchTemplate(prueba,prueba2,result,CV_TM_CCORR);
Assertion messages explain most of the times the situation. Check the console output next time.
Upvotes: 3