Ask Your Question

bboy's profile - activity

2017-02-07 04:51:57 -0600 received badge  Student (source)
2013-07-01 13:21:38 -0600 asked a question Euler angles determination for rectangle perspective

Hi everyone!

I've a problem since last week, on a program for real-time detection based on Canny + find contours whose goal is to detect a rectangle. This part of my program works well!

Now I would like to determine in real-time the three Euler angles in order to have the orientation of my rectangle. For that, I create a "virtual" rectangle with four points and calculate the transformation matrix with the four corners of my detected rectangle. In order to first validate my calculation of these angmes, I've tried different methods:

-I create four points who represents a rectangle -I create four points who will represent my detected rectangle -I use getPerspectiveTransform or findHomography to obtain transformation matrix (both do the same matrix) -I use RCDecomp3x3 to get my three rotation matrices -I calculate my three angles from Qx,Qy and Qz, these three rotation matrices.

I've also tried to calculate global rotation matrix QxQyQz and calculate the angles from it (with atan2 formulas). I've also tried with 5 points (the center of both rectangles and their corners).

My problem is that my values for X and Y are false, because X is always 0 and Y is 0 or 180. Only the Z value changes!

Do you know where is my problem?

Thanks a lot!

Here is my program, I can change the points of the detected rectangle to test every angle.

Mat image = Mat::ones(600,400,CV_32F);
Mat dst2;

//A reference rectangle
vector<Point2f> source(5);
source[0] = Point(100,200);
source[1] = Point(100,100);
source[2] = Point(200,100);
source[3] = Point(200,200);
source[4] = Point(150,150);
line(image,source[0],source[1],Scalar(0,0,0));
line(image,source[1],source[2],Scalar(0,0,0));
line(image,source[2],source[3],Scalar(0,0,0));
line(image,source[3],source[0],Scalar(0,0,0));
circle(image,source[4],2,Scalar(0,0,0));

//My detected rectangle
vector<Point2f> dst(5);
dst[0] = Point(100,200);    
dst[1] = Point(180,180);      
dst[2] = Point(280,180);    
dst[3] = Point(200,200);        
dst[4] = Point(190,190);
circle(image,dst[4],2,Scalar(0,0,0));
line(image,dst[0],dst[1],Scalar(0,0,0));
line(image,dst[1],dst[2],Scalar(0,0,0));
line(image,dst[2],dst[3],Scalar(0,0,0));
line(image,dst[3],dst[0],Scalar(0,0,0));

Mat mtxr,mtxq,qx,qy,qz;
Mat matrice = findHomography(source,dst);

RQDecomp3x3(matrice,mtxr,mtxq,qx,qy,qz);
cout<<"Angle x = "<<180*(acos(qx.at<double>(1,1)))/3.14159<<endl;
cout<<"Angle y = "<<180*(acos(qy.at<double>(0,0)))/3.14159<<endl;
cout<<"Angle z = "<<180*(acos(qz.at<double>(0,0)))/3.14159<<endl;

//A second example rectangle
perspectiveTransform(source,dst,matrice);
vector<Point2f> source2(4);
source2[0] = Point(100,500);
source2[1] = Point(100,300);
source2[2] = Point(300,300);
source2[3] = Point(300,500);
line ...
(more)
2013-06-18 14:05:12 -0600 asked a question Real-time pattern recognition and contour tracing with opencv

Hi everyone!

I have a project to detect a pattern on an object and trace his contour in real time. I'm new user of Opencv, and I don't really know how to start!

I've tried some tutorials, for example "matching with surf + homography", "hough lines" and "hough circles"... I've realized that there were many methods that could be used to detect a pattern, but they don't necessarily work in real time because they are too slow.

The pattern I want to detect could be a circle, but in other application a rectangle or an elipse, and eventually a nondescript pattern. Hough circle works well in real time and traces the contour as I want, but it only works with a circle so I can't chose the pattern I want to detect, that's why I need your help.

What is according to you the best method to realize my project? I don't want a script, just ideas to help me, because I'm a little lost!

Thanks a lot!