assertion failed
I am using opencv for image processing, while comparing images by using command compareHist i am getting the following error:
OpenCV Error: Assertion failed (H1.type() == H2.type() && H1.type() == CV_32F) in compareHist, file /home/alishba/opencv-2.4.9/modules/imgproc/src/histogram.cpp, line 1985
terminate called after throwing an instance of 'cv::Exception'
what(): /home/alishba/opencv-2.4.9/modules/imgproc/src/histogram.cpp:1985: error: (-215) H1.type() == H2.type() && H1.type() == CV_32F in function
compareHist compareHist
Aborted (core
dumped) dumped)
int main()
{
string path="Finger Vein Database/";
int sets=5;
int learning =3;
int
test=1; test=1;
//creating learning database
cout<<"creating
DB\n"; DB\n";
//Mat
database[setslearning];
vector<mat> database(setslearning);
database[sets*learning];
vector<Mat> database(sets*learning);
int counter=0;
for(int i=1;i<=sets;i++)
{
for(int j=1;j<=learning;j++)
{
stringstream ssm;
//string t1="%ss%d/1%d.bmp";
//sprintf(t1,path,i,j);
ssm<<path<<"s"<<i<<" 1"<<j<<".bmp";="" string="" t1="ssm.str();" mat="" im="imread(t1,0);" mat="" hist="GetCompiledHistogram(im);" database[counter++]="hist;" t1="" ;="" im="&NULL;" hist="&NULL;" }<="" p="">
}
counter=0;
ssm<<path<<"s"<<i<<"/1"<<j<<".bmp";
string t1=ssm.str();
Mat im= imread(t1,0);
Mat hist=GetCompiledHistogram(im);
database[counter++]=hist;
t1="";
//im=&NULL;
//hist=&NULL;
}
}
counter=0;
//testing
cout<<"Testing started\n";
//Mat
databaseTest[setstest];
vector<mat> databaseTest(setstest);
databaseTest[sets*test];
vector<Mat> databaseTest(sets*test);
for(int i=1;i<=sets;i++)
{
for(int j=learning+1;j<=test;j++)
{
stringstream ssm;
ssm<<path<<"s"<<i<<" 1"<<j<<".bmp";="" string="" t1="ssm.str();" mat="" im="imread(t1,0);" mat="" hist="GetCompiledHistogram(im);" databasetest[counter++]="hist;" t1="" ;="" im="NULL;" hist="NULL;" }<="" p="">
ssm<<path<<"s"<<i<<"/1"<<j<<".bmp";
string t1=ssm.str();
Mat im= imread(t1,0);
Mat hist=GetCompiledHistogram(im);
databaseTest[counter++]=hist;
t1="";
//im=NULL;
//hist=NULL;
}
}
int count=0;
//int
maxX=sizeof(databaseTest)/sizeof(databaseTest);
maxX=sizeof(databaseTest)/sizeof(*databaseTest);
int maxX=databaseTest.size();
double out;
for(int
x=0;x<maxx;x++) {="" int="" maxy="sizeof(database)/sizeof(</em">database);
x=0;x<maxX;x++)
{
//int maxY=sizeof(database)/sizeof(*database);
int maxY=database.size();
double results[maxY];
for(int y=0;
y<maxy;y++) {="" cout<<x<<"="" "<<y<<"\n";="" mat="" h1="database[y];" mat="" h2="databaseTest[x];" cout="" <<="" typeid(h2).name()="" <<="" '\n';="" out="compareHist(h1,h2" ,="" cv_comp_correl);="" results[y]="out;" }="" int="" mached="MinIn(results,maxY);" if(ceil(mached="" learning)="=x)" <br="">
y<maxY;y++)
{
cout<<x<<" "<<y<<"\n";
Mat h1=database[y];
Mat h2=databaseTest[x];
cout << typeid(h2).name() << '\n';
out=compareHist(h1,h2 , CV_COMP_CORREL);
results[y]=out;
}
int mached= MinIn(results,maxY);
if(ceil(mached/learning)==x)
count++;
}
int total =sets*test;
cout<<((total-count)/total);
return 0;
} }