Skip to content

Instantly share code, notes, and snippets.

@wlucas-DFT
Created November 6, 2014 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlucas-DFT/0b8e1e07f34ee7e489c6 to your computer and use it in GitHub Desktop.
Save wlucas-DFT/0b8e1e07f34ee7e489c6 to your computer and use it in GitHub Desktop.
Boost Geometry intersection testing.
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