Quick and dirty Euglena tracking using OpenCV, Syphon, and OSC.
- Full source: File:TrackEuglenaSyphonOSC.zip
Threshold based Euglena detection
opencv.loadImage(cam);
opencv.gray();
opencv.invert();
threshold = int(map(mouseX,0,width,0,255));
opencv.erode();
opencv.dilate();
opencv.threshold(threshold);
// ...
contours = opencv.findContours();
Skipping large/small contours
for (Contour contour : contours) {
float a = contour.area();
Rectangle r = contour.getBoundingBox();
float wh = float(r.width)/float(r.height);
if (a > minArea && wh > 0.1 && wh < 10 && a < maxArea) {
// ...