I am using ofxOpenNI and I use the threshold method to segmentate the image, the problem I have is that the segmentated image has a lot of “jaggies” (figure 1) so when I do blob detection sometimes I get false blobs.
I want to achieve results similar to Design-I\O—Puppet-Parade (figure 2).
I think they are using the blur() and erode() functions from OpenCV.
Maybe you can have a look at the source code to find more on how they have implemented it.
i converted my blobs in polyline and then smoothed it by using getSmoothed of polyline.
Hope to help you
I have checked the source but unfortunately is only for freenect and I am using OpenNI, sure I could install it but I am afraid that I will mess up my projects, maybe I will try it on a virtual machine.
Anyways I will take a look to the erode and dilate functions I have already created a erode/dilate function and I do not get similar results, so it maybe that the implementation on OF has a better kernel.
Is there a function to convert the blobs into a polyline? Or you just discretize between the points that form the blob?
So i create my polyline : ofPolyline myPoly;
and in update i do a myPoly.getVertices(blob.pts);
then i smooth my polyline.
So you don’t have a special function for convert, but like you can see, it’s very close of it
As @cgiles has explained, I also think simplifying a polyline would be the best way do this.
Actually you can just do it like this,
//blob is type of ofxCvBlob
simpleContour = blob.pts;
Repeat the above till you get the needed number of points.
float simplifyAmount = 2.5f;
// simplify more if still too big
while (simpleContour.size() > 500)
simplifyAmount += .5f;
But if he want a smoothed version of his blob, it’s better to use getSmooth, no ?
Oh! I am sorry! My bad, I did not notice the getSmooth function.
Yes, you are correct. It is better to use the getSmooth function to get a smoothed version of the blob. Simplifying a polyline will drop the excess points and will not really make it smoothed.
I used getSmoothed(int value) but I can not notice any difference, probably I am doing something wrong
for (int i = 0; i < contourFinder.nBlobs; i++)
ofPolyline contourPoly = contourFinder.blobs[i].pts;
// smoothing is set to 200
ofPolyline scontourPoly = contourFinder.getSmoothed(smoothing);