Finished test code, added image to the doc
This commit is contained in:
parent
27bcc0bf07
commit
00f63fa8f7
@ -657,3 +657,33 @@ See below a sample output of the function where each image pixel is tested again
|
||||
.. [Suzuki85] Suzuki, S. and Abe, K., *Topological Structural Analysis of Digitized Binary Images by Border Following*. CVGIP 30 1, pp 32-46 (1985)
|
||||
|
||||
.. [TehChin89] Teh, C.H. and Chin, R.T., *On the Detection of Dominant Points on Digital Curve*. PAMI 11 8, pp 859-872 (1989)
|
||||
|
||||
|
||||
|
||||
rotatedRectangleIntersection
|
||||
-------------------------------
|
||||
Finds out if there is any intersection between two rotated rectangles. If there is then the vertices of the interesecting region are returned as well.
|
||||
|
||||
.. ocv:function:: int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion )
|
||||
.. ocv:pyfunction:: cv2.rotatedRectangleIntersection( rect1, rect2 ) -> retval, intersectingRegion
|
||||
.. ocv:cfunction:: int cvRotatedRectangleIntersection( const CvBox2D* rect1, const CvBox2D* rect2, CvPoint2D32f intersectingRegion[8], int* pointCount )
|
||||
|
||||
:param rect1: First rectangle
|
||||
|
||||
:param rect2: Second rectangle
|
||||
|
||||
:param intersectingRegion: The output array of the verticies of the intersecting region. It returns at most 8 vertices. Stored as ``std::vector<cv::Point2f>`` or ``cv::Mat`` as Mx1 of type CV_32FC2.
|
||||
|
||||
:param pointCount: The number of vertices.
|
||||
|
||||
The following values are returned by the function:
|
||||
|
||||
* INTERSECT_NONE=0 - No intersection
|
||||
|
||||
* INTERSECT_PARTIAL=1 - There is a partial intersection
|
||||
|
||||
* INTERSECT_FULL=2 - One of the rectangle is fully enclosed in the other
|
||||
|
||||
Below are some examples of intersection configurations. The hatched pattern indicates the intersecting region and the red vertices are returned by the function.
|
||||
|
||||
.. image:: pics/intersection.png
|
||||
|
@ -61,6 +61,34 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
|
||||
|
||||
int ret = INTERSECT_FULL;
|
||||
|
||||
// Specical case of rect1 == rect2
|
||||
{
|
||||
bool same = true;
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if( fabs(pts1[i].x - pts2[i].x) > samePointEps || (fabs(pts1[i].y - pts2[i].y) > samePointEps) )
|
||||
{
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(same)
|
||||
{
|
||||
intersection.resize(4);
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
intersection[i] = pts1[i];
|
||||
}
|
||||
|
||||
Mat(intersection).copyTo(intersectingRegion);
|
||||
|
||||
return INTERSECT_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Line vector
|
||||
// A line from p1 to p2 is: p1 + (p2-p1)*t, t=[0,1]
|
||||
for( int i = 0; i < 4; i++ )
|
||||
|
Loading…
x
Reference in New Issue
Block a user