No more accurate method was found. opencv included an elliptical image, and its center position was pixel-level. How can we achieve sub-pixel accuracy?
The following uses the method of drawing a small circle to draw a point. The coordinate of a point is the center of the circle. Given a smaller radius, the point can be represented by this small circle.
Circle function:
void cvCircle( CvArr* img, CvPoint center, int radius, CvScalar color, int thickness=1, int line_type=8, int shift=0 );
Example:
Cvsize SZ; // image size
SZ. Height = 600;
SZ. width = 800;
Image = cvcreateimage (SZ, ipl_depth_8u, 0 );
// Store images
Cvnamedwindow ("image1", cv_window_autosize );
Cvsaveimage ("image1.jpg", image );
// Cvshowimage ("image1", image );
// Draw 30 points on the graph. The iamge_ellipse1 is a matrix of 30*2 and contains the image coordinates of 30 points.
For (INT I = 0; I <30; I ++)
{
Cvpoint centerpoint;
Centerpoint. x = int (cvgetreal2d (image_ellipse1, I, 0 ));
Centerpoint. Y = int (cvgetreal2d (image_ellipse1, I, 1 ));
Cvcircle (image, centerpoint, 3, cv_rgb (0,255, 0), 1, 8, 3 );
}
Cvnamedwindow ("image1", cv_window_autosize );
Cvsaveimage ("image1.jpg", image );
Cvshowimage ("image1", image );
Cvwaitkey (0 );
Cvreleaseimage (& image );
Cvdestroywindow ("image1 ");