In application development, if the obtained video image is after the projection transformation and needs to be corrected, you can use the cvwarpperspective function to implement the perspective transformation. Through the perspective transformation, you can flip the image, linear arbitrary deformation.
You can also use the projection transform cvgetquadranglesubpix to flip an image, but it has three less degrees of freedom, so any linear deformation cannot be achieved.
// Perspective transformation
Int humanmotion: warpperspective (iplimage * gray)
{
Iplimage * img_old = cvcloneimage (Gray );
Int fix = 4;
Int W = img_old-> width + fix;
Int H = img_old-> height + fix;
Cvpoint2d32f src_point [4];
Cvpoint2d32f dst_point [4];
// Set the source observation surface, that is, the four vertices of the specified Quadrilateral
Src_point [0]. x = 17;
Src_point [0]. Y = 475;
Src_point [1]. x= 952;
Src_point [1]. Y = 449;
Src_point [2]. x = 100;
Src_point [1]. Y = 128;
Src_point [3]. x = 840;
Src_point [3]. Y = 110;
// Set the target observation surface, that is, the four vertices of the specified Quadrilateral
Dst_point [0]. x =-fix;
Dst_point [0]. Y = h;
Dst_point [1]. x = W;
Dst_point [1]. Y = h;
Dst_point [2]. x =-fix;
Dst_point [2]. Y =-fix;
Dst_point [3]. x = W;
Dst_point [3]. Y =-fix;
Float newm [9];
Cvmat newm = cvmat (3, 3, cv_32f, newm );
// Obtain the perspective conversion matrix
Cvwarpperspectiveqmatrix (src_point, dst_point, & newm );
// Perspective Conversion
Cvwarpperspective (img_old, gray, & newm, cv_inter_linear + cv_warp_fill_outliers, cvscalarall (0 ));
Cvreleaseimage (& img_old );
Return 0;
}
// Test the Projection Transformation
Int humanmotion: test_cvmul2 (iplimage * gray)
{
Iplimage * src = cvcloneimage (Gray );
Float M [6];
Int angle = frame_count % 60-30;
Cvmat M = cvmat (2, 3, cv_32f, M );
Int W = Src-> width;
Int H = Src-> height;
M [0] = (float) (COS (angle * cv_pi/180 .));
M [1] = (float) (sin (angle * cv_pi/180 .));
M [2] = W * 0.5f;
M [3] =-M [1];
M [4] = m [0];
M [5] = H * 0.5f;
Cvgetquadranglesubpix (SRC, gray, & M );
Return 0;
}