File: imgproc_segmentation.cpp

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (35 lines) | stat: -rw-r--r-- 949 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/segmentation.hpp"

using namespace cv;

static
void usage_example_intelligent_scissors()
{
    Mat image(Size(1920, 1080), CV_8UC3, Scalar::all(128));

    //! [usage_example_intelligent_scissors]
    segmentation::IntelligentScissorsMB tool;
    tool.setEdgeFeatureCannyParameters(16, 100)  // using Canny() as edge feature extractor
        .setGradientMagnitudeMaxLimit(200);

    // calculate image features
    tool.applyImage(image);

    // calculate map for specified source point
    Point source_point(200, 100);
    tool.buildMap(source_point);

    // fast fetching of contours
    // for specified target point and the pre-calculated map (stored internally)
    Point target_point(400, 300);
    std::vector<Point> pts;
    tool.getContour(target_point, pts);
    //! [usage_example_intelligent_scissors]
}

int main()
{
    usage_example_intelligent_scissors();
    return 0;
}