imgproc_segmentation.cpp 949 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "opencv2/imgproc.hpp"
  2. #include "opencv2/imgproc/segmentation.hpp"
  3. using namespace cv;
  4. static
  5. void usage_example_intelligent_scissors()
  6. {
  7. Mat image(Size(1920, 1080), CV_8UC3, Scalar::all(128));
  8. //! [usage_example_intelligent_scissors]
  9. segmentation::IntelligentScissorsMB tool;
  10. tool.setEdgeFeatureCannyParameters(16, 100) // using Canny() as edge feature extractor
  11. .setGradientMagnitudeMaxLimit(200);
  12. // calculate image features
  13. tool.applyImage(image);
  14. // calculate map for specified source point
  15. Point source_point(200, 100);
  16. tool.buildMap(source_point);
  17. // fast fetching of contours
  18. // for specified target point and the pre-calculated map (stored internally)
  19. Point target_point(400, 300);
  20. std::vector<Point> pts;
  21. tool.getContour(target_point, pts);
  22. //! [usage_example_intelligent_scissors]
  23. }
  24. int main()
  25. {
  26. usage_example_intelligent_scissors();
  27. return 0;
  28. }