No edit summary |
|||
Line 16: | Line 16: | ||
opencv.threshold(threshold); | opencv.threshold(threshold); | ||
// ... | |||
contours = opencv.findContours(); | |||
</source> | |||
=== Skipping large/small contours === | |||
<source lang="java"> | |||
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) { | |||
// ... | |||
</source> | </source> |
Revision as of 09:22, 7 June 2015
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) {
// ...