问题
I am trying to use the active contour algorithm using OpenCV function. There is an implementation named cvSnakeImage
. But I can't find an example in the OpenCV documentation. I found an example here. I added some lines and I expect that this code segments the image but the result is not expected. The points from snake method don't move.
I edited a function from this code. And it is here :
void AactiveSnake(IplImage* image)
{
points = (CvPoint*)cvAlloc(15*sizeof(CvPoint*));
int x,y;
for(int i = 0;i < 14 ; i++){
x = Xvalues[i];
y = Yvalues[i];
points[i].x = x;
points[i].y = y;
}
cout << "AactiveSnake";
cvSnakeImage(image,points,15,&Alfa,&Beta,&Gamma,CV_VALUE,win,criteria,0);
IplImage* temp;
temp = cvCloneImage(imageRGB);
for(int i = 0;i < 14 ; i++){
x = points[i].x;
y = points[i].y;
Xvalues[i] = x;
Yvalues[i] = y;
cvCircle(temp,cvPoint(x,y),1,CV_RGB(255,0,0),-1);
}
cout << "*\n";
cvShowImage( "Snake-Points", temp );
waitKey(0);
}
Input image :

来源:https://stackoverflow.com/questions/29031909/opencv-active-contours