-
-
Save wlucas-DFT/0b8e1e07f34ee7e489c6 to your computer and use it in GitHub Desktop.
Boost Geometry intersection testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOST_GEOMETRY_REGISTER_POINT_2D(cv::Point_<int>, int, cs::cartesian, x, y); | |
BOOST_GEOMETRY_REGISTER_BOX(cv::Rect, cv::Point, tl(), br()); | |
BOOST_GEOMETRY_REGISTER_RING(dft::Contour); // Contour = std::vector<cv::Point> | |
typedef box_view<cv::Rect> box_view; | |
box_view activeRegion(r); | |
Contour correctedContour = originalContour; | |
correct(correctedContour); | |
double activeRegionArea = area(activeRegion); | |
double contourArea = area(correctedContour); | |
Contour intersectionContour; | |
intersection(activeRegion, correctedContour, intersectionContour); | |
correct(intersectionContour); | |
double intersectionArea = area(intersectionContour); | |
std::cout << wkt<box_view>(activeRegion) << std::endl; | |
std::cout << wkt<Contour>(correctedContour) << std::endl; | |
std::cout << wkt<Contour>(intersectionContour) << std::endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment