Bonjour,

Je débute avec OpenCV et je voudrais utiliser la fonction MatchShapes. D'après la documentation, les 2 premiers arguments peuvent être des images en niveau de gris cependant j'obtiens l'erreur suivante (que je ne comprends pas) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file cxcore/cxarray.cpp, line 2470
terminate called after throwing an instance of 'cv::Exception'
Voici le code (pourtant tout simple) qui provoque l'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
#include <iostream>
#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
 
using namespace cv;
 
int main(){
std::string s1("Base/001.jpg");
std::string s2("Base/008.jpg");
Mat img1 = imread(s1);
Mat img2 = imread(s2);
if (!img1.data || !img2.data)
{
	std::cout << "Problem with pictures" << std::endl;
	std::exit(-1);
}
cv::Mat imgG1, imgG2;
cv::cvtColor(img1, imgG1, CV_BGR2GRAY);
cv::cvtColor(img2, imgG2, CV_BGR2GRAY);
 
double lol = cvMatchShapes(&imgG1, &imgG2, CV_CONTOURS_MATCH_I1);
std::cout << "HU CMP1\t\t:\t" << lol << std::endl;
return 0;
}
Si quelqu'un pouvait me débloquer