# 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

show us, what you tried so far.

( 2016-01-04 03:30:06 -0600 )edit

( 2016-01-04 03:51:58 -0600 )edit

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

May i know what should I change or add this code in my ori code? http://paste.ideaslabs.com/show/baMTo...

( 2016-01-04 19:36:06 -0600 )edit

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

( 2016-01-04 21:04:45 -0600 )edit

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.

( 2016-01-04 22:26:38 -0600 )edit

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

( 2016-01-04 22:27:22 -0600 )edit

Official site

GitHub

Wiki

Documentation