Commit cb16f733 authored by Nghia Ho's avatar Nghia Ho

Added C interface

parent a40f217a
......@@ -615,6 +615,10 @@ CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
double reps, double aeps, float* line );
/* Finds the intersecting region made by two rotated rectangles.
If there is an intersection the vertices of the region are returned. */
CVAPI(int) cvRotatedRectangleIntersection( const CvBox2D* rect1, const CvBox2D* rect2, CvPoint2D32f intersectingRegion[8], int* pointCount );
#ifdef __cplusplus
}
#endif
......
......@@ -49,7 +49,7 @@ namespace cv
int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion )
{
const float samePointEps = 0.00001; // used to test if two points are the same, due to numerical error
const float samePointEps = 0.00001; // used to test if two points are the same
Point2f vec1[4], vec2[4];
Point2f pts1[4], pts2[4];
......@@ -213,9 +213,28 @@ int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& r
return INTERSECT_NONE ;
}
// If this check fails then it means we're getting dupes, increase samePointEps
CV_Assert( intersection.size() <= 8 );
Mat(intersection).copyTo(intersectingRegion);
return ret;
}
} // end namespace
int cvRotatedRectangleIntersection( const CvBox2D* rect1, const CvBox2D* rect2, CvPoint2D32f intersectingRegion[8], int* pointCount )
{
std::vector <cv::Point2f> pts;
int ret = cv::rotatedRectangleIntersection( *rect1, *rect2, pts );
for( size_t i=0; i < pts.size(); i++ )
{
intersectingRegion[i] = pts[i];
}
*pointCount = (int)pts.size();
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment