# 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.

This forum is disabled, please visit https://forum.opencv.org

Get the each coodinates of all corner of 2 rectangle

1

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;
}
```

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

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

Asked: **
2016-01-04 03:23:59 -0600
**

Seen: **9,810 times**

Last updated: **Jan 04 '16**

how to get the position of a pixel with the mouse?

coordinates of detected target

fail to "findchessboardcorners" in images taken from a fisheye camera

Extract the coordinates of a point OpenCV C + + [closed]

open cv, vector<DMatch> matches, xy coordinates

Points form one camera system to another

detect the direction of an object

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

show us, what you tried so far.

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...