Ask Your Question

user19's profile - activity

2014-05-05 13:07:19 -0600 received badge  Editor (source)
2014-05-05 03:27:55 -0600 asked a question Color Detection Program Assertion failed (k==STD_VECTOR_MAT)

Problem Solved - double opencv version installed

I created a program to detect and track color. This program works perfectly on my PC with windows and ubuntu OS, but this program cannot run in my debian arm miniPC.

I am getting error: opencv error: Assertion failed (k==STD_VECTOR_MAT) in getMat., file /build/buildd-opencv_2.3.1-11-armhf-d9JIli/opencv-2.3.1/modules/core/src/matrix.cpp, line 918

I am using qtcreator 2.5.0 qt 4.8.2 and opencv 2.3.1-11

 //VARIABLE LIST///////////////////////////////////////
 int cap_x_size=320;
 int cap_y_size=240;
 int posx,posy;

 //matrix1
 bool betulyellow1;
 string yellow1="yellow";
 string yellowind = "yellow";
 int yellow1posx, yellow1posy;

 //matrix2
 bool betulyellow2;
 string yellow2="yellow";
 int yellow2posx, yellow2posy;

 vector<vector<Point> > leftcontur;
 vector<vector<Point> > rightcontur;
 vector<vector<Point> >::const_iterator itc;

 Moments momon;
 double momon01,momon10,momonrea;

 /////////////////////////////////////////////////////

 int main(int argc, char *argv[])
 {
 QApplication a(argc, argv);
 MainWindow w;
 w.show();

 Mat left(240, 320, CV_8UC3);
 Mat right(240, 320, CV_8UC3);
 Mat lefthsv(240, 320, CV_8UC3),righthsv(240, 320, CV_8UC3);
 Mat LYellow(240, 320, CV_8UC3),RYellow(240, 320, CV_8UC3);

 VideoCapture cap;
 VideoCapture cap2;

 cap.open(0);
 cap.set(CV_CAP_PROP_FRAME_WIDTH, cap_x_size);
 cap.set(CV_CAP_PROP_FRAME_HEIGHT, cap_y_size);

 cap2.open(1);
 cap2.set(CV_CAP_PROP_FRAME_WIDTH, cap_x_size);
 cap2.set(CV_CAP_PROP_FRAME_HEIGHT, cap_y_size);

while(1)
{
cap>>left;
cap2>>right;

cvtColor(left,lefthsv,CV_BGR2HSV);
cvtColor(right,righthsv,CV_BGR2HSV);

//left
findContours(LYellow,leftcontur,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
drawContours(LYellow,leftcontur,-1,Scalar(255),1);

//right
findContours(RYellow,rightcontur,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
drawContours(RYellow,rightcontur,-1,Scalar(255),1);

//left
for(itc = leftcontur.begin(); itc<leftcontur.end(); itc++) 
{
    momon = moments(Mat(*itc));
    momon10 = momon.m10;
    momon01 = momon.m01;
    momonrea= momon.m00; // momonrea is area
    posx = momon10/momonrea;
    posy = momon01/momonrea;
        circle(left,Point(posx,posy),2, Scalar(0,255,255),2);
        putText(left,yellow1,Point(posx,posy-20),1,1,Scalar(0,255,0));
        putText(left,intToString(posx)+ " , " +  intToString(posy),Point(posx,posy+20),1,1,Scalar(0,255,0));
        if(yellow1 == yellowind)
        {
            betulyellow1 = true;
        }
        else
        {
            betulyellow1 = false;
        }
}
if(betulyellow1)
{
    yellow1posx=posx;
    yellow1posy=posy;
    betulyellow1=false;
}
else
{
    yellow1posx=0;
    yellow1posy=0;
}


//right
for(itc = rightcontur.begin(); itc<rightcontur.end(); itc++)
{
    momon = moments(Mat(*itc));
    momon10 = momon.m10;
    momon01 = momon.m01;
    momonrea= momon.m00; // momonrea is area
    posx = momon10/momonrea;
    posy = momon01/momonrea;
        circle(right,Point(posx,posy),2, Scalar(0,255,255),2);
        putText(right,yellow1,Point(posx,posy-20),1,1,Scalar(0,255,0));
        putText(right,intToString(posx)+ " , " + intToString(posy),Point(posx,posy+20),1,1,Scalar(0,255,0));
        if(yellow2 == yellowind)
        {
            betulyellow2 = true;
        }
        else
        {
            betulyellow2 = false;
        }
}
if(betulyellow2)
{
    yellow2posx=posx;
    yellow2posy=posy;
    betulyellow2=false;
}
else
{
    yellow2posx=0;
    yellow2posy=0;
}

if(waitKey(10)==27)//press esc to exit
{
    destroyAllWindows();
    break;
}
}

return a.exec();
}

Problem Solved