diff --git a/src/BlobFinder.cpp b/src/BlobFinder.cpp index 3dd9ebad3404be4bd87b925a8b2d85d83e7e0c71..5d410dc1443d4cf7339f5c97413ca666f774469d 100644 --- a/src/BlobFinder.cpp +++ b/src/BlobFinder.cpp @@ -207,6 +207,26 @@ void BlobFinder::loadMask() { maskFbo.end(); } +void BlobFinder::filterTrailingPixels() { + filteredImage = grayImage; + + // close + filteredImage.dilate(); + filteredImage.erode(); + + // open + filteredImage.erode(); + filteredImage.dilate(); + + // close + filteredImage.dilate(); + filteredImage.erode(); + + // open + filteredImage.erode(); + filteredImage.dilate(); +} + void BlobFinder::update(){ ofColor white = ofColor::white; ofColor black = ofColor::black; @@ -223,7 +243,7 @@ void BlobFinder::update(){ minID = (blobEvents[e].mID >= minID) ? blobEvents[e].mID + 1 : minID; } - if (true || useMask.get()) { + if (useMask.get()) { fbo.begin(); // Cleaning everthing with alpha mask on 0 in order to make it transparent for default ofClear(0, 0, 0, 0); @@ -246,8 +266,7 @@ void BlobFinder::update(){ // load grayscale captured depth image from the color source grayImage.setFromColorImage(colorImg); - - //grayImage.blurHeavily(); + filterTrailingPixels(); ofPixelsRef blobRefPixls = blobRef.getPixels(); @@ -283,7 +302,7 @@ void BlobFinder::update(){ detectedHeads.clear(); - contourFinder.findContours(grayImage, minBlobSize, maxBlobSize, countBlob.get(), false); + contourFinder.findContours(filteredImage, minBlobSize, maxBlobSize, countBlob.get(), false); for (int i = 0; i < contourFinder.nBlobs; i++){ ofRectangle bounds = contourFinder.blobs[i].boundingRect; diff --git a/src/BlobFinder.h b/src/BlobFinder.h index 1533b3f9260aa152d71d90a35f823e0724c527b8..dc6eb2a5eddd7feb324b0785853e1fab31720ee8 100644 --- a/src/BlobFinder.h +++ b/src/BlobFinder.h @@ -46,6 +46,7 @@ public: void loadMask(); void saveMask(); + void filterTrailingPixels(); void update(); bool hasParamUpdate(); @@ -91,6 +92,7 @@ public: ofxCvGrayscaleImage blobRef; // body blob reference image ofxCvGrayscaleImage grayImage; // grayscale depth image + ofxCvGrayscaleImage filteredImage; // grayscale depth image with trailing pixels filtered out ofxCvGrayscaleImage grayEyeLevel; // the eyelevel thresholded image ofxCvGrayscaleImage grayThreshFar; // the far thresholded image diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 60157786cf599607d50617e386633f02d1308c47..87dedd4c8630b2232601292a1d45d8639f43cf76 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -420,7 +420,7 @@ void ofApp::drawCapturePointCloud(bool _mask) { } else { shader.setUniform1i("mask", 0); - glPointSize(6 * 2); + glPointSize(2); } shader.setUniform1f("lowerLimit", lowerLimit); shader.setUniform1f("upperLimit", upperLimit);