Saturday, November 7, 2026
HomeiOS Developmentc++ - How can I take advantage of opencv clever scissors to...

c++ – How can I take advantage of opencv clever scissors to get the factors that correspond to edges in a picture?

[ad_1]

I’m making an attempt to make use of opencv Clever Scissors to search out edges in an iOS app. I’ve a picture view with a gesture recognizer. And I take the areas from that gesture recognizer and cross them to the next c++ operate…

Mat OpencvManager::imageWithContours(Point2i target_point) {
  Mat dst = originalImage.clone();
  
  Mat contour = Mat();
  software.getContour(target_point, contour);
 
  std::vector<cv::Mat> contours = std::vector<cv::Mat>();
  contours.push_back(contour);

  Scalar shade = Scalar(0,255,0,255);
  polylines(dst, contours, false, shade, 3, LINE_4);

  return dst;
}

And once I change the picture within the imageview with the output I get the next….

Polyline from opencv

But when I take the factors from…

  Mat contour = Mat();
  software.getContour(target_point, contour);

And draw the trail in iOS utilizing…

func createPath(for factors: [CGPoint]) {
    let sketchLayer = addSketchLayer()
    sketchLayer.strokeColor = UIColor.inexperienced.cgColor
    sketchLayer.lineWidth = 3
    
    let path = CGMutablePath()
    
    for level in factors {
      if level == factors.first {
        path.transfer(to: level)
      } else {
        path.addLine(to: level)
      }
    }
    
    sketchLayer.path = path
  }

I get the next…

Path drawn from factors in iOS

Within the first picture, you’ll be able to see the inexperienced line follows the sting of the circle after which trails off to the final level from the pan gesture. However within the second picture, there’s a line from the sting of the circle to every level from the pan gesture. So one thing is occurring in polylines(dst, contours, false, shade, 3, LINE_4) that’s eliminating the traces from the contact location to the sting. And I do not perceive what that’s. However I would like the factors so as, not simply the picture. So I would like to make use of the second technique.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments