PDA

View Full Version : OpenCv Problem



danics
12th April 2010, 15:01
Hi every body!

i m using Qt and Opencv 2.0 for create a program that give a image and do color segmentation on it!
but my problem is a signal error that i give from some opencv methods like cvKmeans2 and cvCvtColor!
(disassembler for cvCvtColor is 0x1002e4e4 movdqa %xmm3,-0x38(%ebp))
if i add this functions in another C++ application like Visual C++ it works fine or in Qt if i dont use QApplication i havent any error please help me!

danics
13th April 2010, 10:40
nobody can help me
i think it is for Assert function
this is my code i have got a signal error on cvKmeans2 in Debug mode and i cant enter this function with step into too
<code>
loginfo += "\n\nCalculating Image Segmentation algorithm with Kmeans";
CvRNG rng = cvRNG(0xffffffff);

IplImage* toShow=cvCloneImage(im);

CvMat *arr =cvCreateMat(im->height*im->width, 1, CV_32FC1 );
CvMat *retVect =cvCreateMat(im->height*im->width, 1, CV_32SC1 );
//cvCvtColor(im, im, CV_BGR2HSV);
int *colorArr[3];

for(int i=0; i<3;i++)
colorArr[i] = new int[cluster_count];

for(int k=0; k<cluster_count; k++)
{
colorArr[0][k]=cvRandInt(&rng)&#37;255;
colorArr[1][k]=cvRandInt(&rng)%255;
colorArr[2][k]=cvRandInt(&rng)%255;
}

for(int i=0; i<im->height; i++)
for(int j=0; j<im->width; j++)
{
((float*)(arr->data.ptr + arr->step* (i*im->width+j)))[0]= ((uchar*)(im->imageData + im->widthStep*i))[j*3+CHANNEL];
}
loginfo +="\n\nConverted image data to cvMat";
//cvKMeans2forH(arr, cluster_count, retVect, cvTermCriteria( CV_TERMCRIT_ITER, 20, 1.0 ) );
cvKMeans2(arr, cluster_count, retVect, cvTermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 20, 1.0 ) );
loginfo +="\n\nDone K-means clustering";

for(int i=0; i<im->height; i++)
for(int j=0; j<im->width; j++)
{
int index=(retVect->data.ptr + retVect->step* (i*im->width+j))[0];
((uchar*)(toShow->imageData + toShow->widthStep*i))[j*3 ]= colorArr[0] [index];
((uchar*)(toShow->imageData + toShow->widthStep*i))[j*3+1]= colorArr[1] [index];
((uchar*)(toShow->imageData + toShow->widthStep*i))[j*3+2]= colorArr[2] [index];
}
loginfo +="\n\nFormed output image from returned index array";
loginfo += "\n\n-------------------------------------------";

cvNamedWindow("Clustered", 1);
cvShowImage("Clustered", toShow);
//cvSaveImage("Output.jpg", toShow);

cvWaitKey(0);

cvReleaseMat(&arr);
cvReleaseMat(&retVect);

cvDestroyWindow("Clustered");

cvReleaseImage(&toShow);
</code>

please help me