How to use org.bytedeco.opencv.global.opencv_imgproc.polylines method #1778
-
Hello, Since yesterday I'm trying to make this code work. The expected result is a polyline on my image (the mat parameter). What is sure is that this does not work. It shows me a result after 2min for just 10 points. private fun drawAVPolyline(mat: Mat) {
// Some other code with coords lists
val size = 10L
val pts = Point(size)
for (i in 0 until size) {
pts.position(i).apply { x(list[i.toInt()]); y(list[i.toInt()]) }
}
polylines(mat, pts, IntPointer(size.toInt()), 1, false, Scalar(255,255,255), 2, 8, 0)
} I don't quite understand what to pass for the points parameter (is what I did right?), and what to pass for the npts and ncontours parameters. Could someone help me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It's usually easier to look at some sample code in C++ and port that, for example: polylines(mat, new MatVector(new Mat(pts.position(0))), false, ...) |
Beta Was this translation helpful? Give feedback.
It's usually easier to look at some sample code in C++ and port that, for example:
https://github.com/opencv/opencv/blob/master/samples/dnn/scene_text_detection.cpp#L109
But I see that uses
std::vector<std::vector<cv::Point>>
, which isn't mapped... We should be able to get this working pretty easily with MatVector though. If you want to draw a single polygon with those points, something like this should work: