1 | initial version |
Some findings:
Here's my code.... (i'm running inside openFrameworks, hence image.getPixelsRef():
Mat cvImage;
cvtColor(toCv(this->image.getPixelsRef()), cvImage, CV_RGB2GRAY);
int blockSize = sqrt(this->paramMaxArea) * 3.0f;
blockSize = (blockSize / 2) * 2 + 1;
if (blockSize <= 1) {
blockSize = 3;
}
adaptiveThreshold(cvImage, cvImage, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, blockSize, 2);
imitate(this->thresholdedImage, cvImage);
memcpy(this->thresholdedImage.getPixels(), cvImage.data, this->thresholdedImage.getPixelsRef().size());
this->thresholdedImage.update();
SimpleBlobDetector::Params params;
params.maxArea = paramMaxArea; // 100 * 100
params.minArea = paramMinArea; // 10 * 10
Ptr<FeatureDetector> blobDetector = new SimpleBlobDetector(params);
auto success = findCirclesGrid(cvImage, cv::Size(5, 7), this->centers, CALIB_CB_ASYMMETRIC_GRID | CALIB_CB_CLUSTERING, blobDetector);
cout << (success ? "success" : "fail") << endl;
Here's the image i'm testing with: http://www.kimchiandchips.com/files/opencv/5x7.JPG (i can't attach directly here since it's larger than 1MB)
And here's a screenshot of the app running: C:\fakepath\Screen Shot 2014-10-02 at 23.52.34.png
The full code can be found at: this gist
2 | No.2 Revision |
Some findings:
Here's my code.... (i'm running inside openFrameworks, hence image.getPixelsRef():
Mat cvImage;
cvtColor(toCv(this->image.getPixelsRef()), cvImage, CV_RGB2GRAY);
int blockSize = sqrt(this->paramMaxArea) * 3.0f;
blockSize = (blockSize / 2) * 2 + 1;
if (blockSize <= 1) {
blockSize = 3;
}
adaptiveThreshold(cvImage, cvImage, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, blockSize, 2);
imitate(this->thresholdedImage, cvImage);
memcpy(this->thresholdedImage.getPixels(), cvImage.data, this->thresholdedImage.getPixelsRef().size());
this->thresholdedImage.update();
SimpleBlobDetector::Params params;
params.maxArea = paramMaxArea; // 100 * 100
params.minArea = paramMinArea; // 10 * 10
Ptr<FeatureDetector> blobDetector = new SimpleBlobDetector(params);
auto success = findCirclesGrid(cvImage, cv::Size(5, 7), this->centers, CALIB_CB_ASYMMETRIC_GRID | CALIB_CB_CLUSTERING, blobDetector);
cout << (success ? "success" : "fail") << endl;
Here's the image i'm testing with: http://www.kimchiandchips.com/files/opencv/5x7.JPG (i can't attach directly here since it's larger than 1MB)
And here's a screenshot of the app running:
C:\fakepath\Screen Shot 2014-10-02 at 23.52.34.pngScreen Shot
The full code can be found at: this gist