Ask Your Question

tymop's profile - activity

2017-08-25 14:54:18 -0600 received badge  Student (source)
2013-11-20 15:13:28 -0600 commented answer opencv transformation perspective

Thank you, that is good with this function.

2013-11-20 11:56:56 -0600 received badge  Editor (source)
2013-11-20 11:19:50 -0600 asked a question opencv transformation perspective

Hello, I get a picture taken in perspective and wishes to restore its original form.

For this I use the code snippet below: My original image is in Dossard[j] . img

For the sake of simplicity, and because I did not understand why my resulting image corresponded to nothing , I put the same coordinate values ​​for the 2 images ( dstTri [0] = srcTri x [0] x . . ; ... ) . I thought in this case that the image given by cvWarpAffine would be exactly the original. But this is not the case , and this is just to ask me some help .

The original image is a rectangle 54 pixels wide by 56 pixels high) containing 4 figures photographed at a slight angle The resulting image is a cream white uniform image (note : I notice that the color corresponds to the first pixel of the original image Random . ? )

Is anyone know why I have this result and what am I doing wrong ?

Thank you in advance for your help. image descriptionimage description


CvPoint2D32f srcTri[4], dstTri[4];
CvMat* warp_mat = cvCreateMat(2,3,CV_32FC1);
IplImage *src, *dst;

src = cvCloneImage( Dossard[j].img );
src->origin = Dossard[j].img->origin;
dst = cvCloneImage( src );
dst->origin = src->origin;

srcTri[0].x=0;srcTri[0].y=0;
srcTri[1].x=src->width;srcTri[1].y=0;
srcTri[2].x=src->width;srcTri[2].y=src->height;
srcTri[3].x=0;srcTri[3].y=src->height;

dstTri[0].x=srcTri[0].x;dstTri[0].y=srcTri[0].y;
dstTri[1].x=srcTri[1].x;dstTri[1].y=srcTri[1].y;
dstTri[2].x=srcTri[2].x;dstTri[2].y=srcTri[2].y;
dstTri[3].x=srcTri[3].x;dstTri[3].y=srcTri[3].y;

cvGetPerspectiveTransform(srcTri, dstTri, warp_mat);
cvWarpAffine( src, dst, warp_mat , CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS , cvScalarAll(0) );
cvSaveImage(buf2,dst,0);
2013-11-06 12:00:38 -0600 received badge  Organizer (source)
2013-11-05 13:34:18 -0600 asked a question rectangle coordinates x,y square.c

Dear, I am not a very good software maker, but I have a need to find some rectangles in a picture ,transform them into a rectangle if deformed, and extract them into onthers images.

For that, I use the example square.c from the opencv example, and :

  • I modify it to have the good arguments

int square(char* fichier)

  • I remove some functions like the treshold slide, ... not usefull for me

  • I store the result of findSquares4 in a variable.

square_found=findSquares4( img, storage2 );

But the result of this function is complex and I don't knwo where I can find the coordinates of my rectangles. image description

Does anybody can help me ?

Thanks a lot.