Get the each coodinates of all corner of 2 rectangle

May i know how to get the coordinate of each corner rectangle? Means i need get 8 coordinates of corner from there. edit retag close merge delete

My full codes was under comments which is "main", "color.h", "color.cpp" and already use the comments code to get the rectangle, and this is the link. http://answers.opencv.org/question/81...

Sort by » oldest newest most voted i hope the code below helps you.

#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"

using namespace cv;

int main()
{

Mat src = Mat::zeros( 400, 400, CV_8UC3);

Rect r(100,100,50,50);

Point point0 = Point(r.x, r.y);
Point point1 = Point(r.x + r.width, r.y);
Point point2 = Point(r.x + r.width, r.y + r.height);
Point point3 = Point(r.x, r.y + r.height);

rectangle( src, r, Scalar::all(255));

circle( src, point0, 10, Scalar( 0, 0, 255) );
circle( src, point1, 10, Scalar( 0, 0, 255) );
circle( src, point2, 10, Scalar( 0, 0, 255) );
circle( src, point3, 10, Scalar( 0, 0, 255) );

imshow( "coodinates of all corner of rectangle", src );
waitKey();

return 0;
}
more

what is your desired final result? you must to give some effort to complate your code.

Actually this is my Final project about obstacle avoidance and i just starting using opencv less than 2 months, but now i need to complete my first part project that is detect the obstcle using opencv.

Finally i get the corner from rectangle like this picture. thanks for your help sir http://pasteboard.co/yEnWjGb.jpg

Stats

Asked: 2016-01-04 03:23:59 -0500

Seen: 5,294 times

Last updated: Jan 04 '16