Hi all! i’m a bit of a newbie here
i’m working with openCV Library and i’m trying to make a sketch that draw lines between points of a contour.
I have no experience working with array lists and pvectors, but basicaly i’m tryng to make a for loop to load the points but I can’t make it load it
The way it generate the contours is this
But i have no idea how to read an specific point in the array and return the x and y value
pls help!
import gab.opencv.*;
import processing.video.*;
PImage src, dst;
OpenCV opencv;
Capture video;
ArrayList<Contour> contours;
ArrayList<Contour> polygons;
void setup() {
size(800, 600);
video = new Capture(this, 800 , 600);
opencv = new OpenCV(this, video);
video.start();
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
opencv.loadImage(video);
dst = opencv.getOutput();
image(dst, 0, 0);
opencv.gray();
opencv.threshold(70);
contours = opencv.findContours();
noFill();
strokeWeight(3);
for (Contour contour : contours) {
stroke(0, 255, 0);
stroke(255, 0, 0);
beginShape();
for (PVector point : contour.getPoints()) {
vertex(point.x, point.y);
}
endShape();
}
}