遵循在学习OpenCV中给出的Delaunay三角剖分之后,我很难理解此片段,这是负责绘制镶嵌的最终作品,此处draw_subdiv_facet正在为一个voroni送出一个voroni时间
static void draw_subdiv_facet( IplImage* img, CvSubdiv2DEdge edge )
{
CvSubdiv2DEdge t = edge;
int i, count = 0;
//cvpoint structure
//param x: x-coordinate of the point.
//param y: y-coordinate of the point.
//param point: the point to convert.
CvPoint* buf = 0;
// count number of edges in facet
do
{
count++;
t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
} while (t != edge );
cout<<"ncount is : "<<count<<endl;
//allocate the array
buf = (CvPoint*)malloc( count * sizeof(buf[0]));
// gather points
t = edge;
for( i = 0; i < count; i++ )
{
//
CvSubdiv2DPoint* pt = cvSubdiv2DEdgeOrg( t );
if( !pt ) break;
buf[i] = cvPoint( cvRound(pt->pt.x), cvRound(pt->pt.y));
cout<<"pt.x is : "<<cvRound(pt->pt.x);
cout<<" pt.y is : "<<cvRound(pt->pt.y)<<endl;
cout<<"converted to cvPoint gives"<<buf[i].x<<" , "<<buf[i].y<<endl;
t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
}
if( i == count )
{
CvSubdiv2DPoint* pt = cvSubdiv2DEdgeDst( cvSubdiv2DRotateEdge( edge, 1 ));
//cvFillConvexPoly( img, buf, count, CV_RGB(rand()&255,rand()&255,rand()&255), CV_AA, 0 );
CvPoint xx = buf[0];
cout<<"located at "<<xx.x<<","<<xx.y<<endl;
cvPolyLine( img, &buf, &count, 1, 1, CV_RGB(0,0,0), 1, CV_AA, 0);
draw_subdiv_point( img, pt->pt, CV_RGB(0,0,0));
}
free( buf );
}
这是负责在多边形中绘制线条和着色的原因
CvRect rect = { 0, 0, 600, 600 };
img = cvCreateImage( cvSize(rect.width,rect.height), 8, 3 );
这些点在-1000或更大的范围内,因此如何仍在绘制点。
目前尚不清楚您要问什么。如果点"按1000或更多的顺序",那么源图像可能很大。这些点相对于源图像,而不是窗口。如果需要将点放入绘图窗口中,则需要手动缩放点。
你是对的。它绘制了可能在200多个以上的坐标中的10分中绘制了10分,顺便说一句,我只是没有看到这些点,而且很困惑,但它们一直在那里。谢谢。