Then we are modifying some default settings to allow drawings in overlay the contours pixels and the position of the center of gravity with a thickness of 2 pixels.
The following example shows how to detect blobs in the first image and then track all the detected blobs. This functionality is only available with vpDot2 class.
Then, two cases are handled. The first case, when learn is set to true, consists in learning the blob characteristics. The user has to click in a blob that serves as reference blob. The size, area, gray level min and max, and some precision parameters will than be used to search similar blobs in the whole image.
if (learn) {
// Learn the characteristics of the blob to auto detect
Here blob_list contains the list of the blobs that are detected in the image I. When learning is enabled, the blob that is tracked is not in the list of auto detected blobs. We add it to the end of the list:
if (learn) {
// The blob that is tracked by initTracking() is not in the list of auto detected blobs
// We add it:
blob_list.push_back(blob);
}
Finally, when a new image is available we do the tracking of all the blobs:
for(std::list<vpDot2>::iterator it=blob_list.begin(); it != blob_list.end(); ++it) {