Apologies for what is probably a painfully basic question. I’m new to Processing, but I’m not new to media programming (19+ year user of SuperCollider, 2-3 years teaching with Pure Data). Processing 3.5.4.
I am seeing a number of code examples online using the Blob class. (The goal is to supplement some image processing in Pure Data with blobby goodness – Pd’s Gem external claims to have a blob tracker but it’s slow enough to be unusable. That’s fine because Pd focuses on audio rather than video processing – so the lesson for the students will be how to integrate with other tools that are better suited to the task.)
Trying it for myself, I got as far as opening and displaying the camera and instantiating an OpenCV object but it chokes on ‘Cannot find a class or type named “Blob”’.
I tried several Google searches about “processing language Blob class” and I find many, many pages about how to use Blob, but nothing about where it’s defined. I can’t even find a reference for the class.
Then I noticed that these code examples all(?) import hypermedia.video.*;
.
Processing IDE → Import Library → Add Library → search “hyper” oh, well, there’s nothing. Search “video” and several packages do show up, but there is no indication in the window which one of those might be hypermedia.
I also see that there is a BlobDetection library, but I’m not sure this is the right one because I didn’t see import blobDetection.*;
in any of the examples (and blobs
comes from the OpenCV object anyway).
So… this incoming user is experiencing a disconnect between examples and documentation.
Where do I get Blob
?
hjh
Working example, displaying camera:
import processing.video.*;
Capture video;
void setup() {
size(640, 480);
video = new Capture(this, 640, 480);
video.start();
}
void draw() {
if (video.available() == true) {
video.read();
};
image(video, 0, 0);
}
This sketch can’t find Blob:
import gab.opencv.*;
import processing.video.*;
OpenCV opencv;
Capture video;
float s=10;
float sc;
void setup() {
size(640, 480);
video = new Capture(this, 640, 480);
opencv=new OpenCV(this, 640, 480);
video.start();
}
void draw() {
if (video.available() == true) {
video.read();
};
image(video, 0, 0);
// background(255);
opencv.threshold(80);
Blob[] blobs=opencv.blobs(10, width*height,100,true,OpenCV.MAX_VERTICES*4);
for(int i=0; i<blobs.length;i++) {
for(int j=0; j<blobs[i].points.length; j++) {
fill(255);
stroke(sc);
rect(blobs[i].points[j].x,blobs[i].points[j].y,s,s);
}
}
}