1 | initial version |
Uchiyama did a Paper on his so called "Random dot markers" where he searches for black blobs (inverse of your binary-image..) before applying the LLAH to identify the markers. I'm not entirely sure whether I used parts of his algorithm (Source available at http://hvrl.ics.keio.ac.jp/uchiyama/me/code/UCHIYAMARKERS/index.html ) or was unsatisfied and implemented it on my own, at least my comment in the header says it's somewhere grabbed from there.
However, I found a pretty nice implementation I did a year ago - not really tested but working. The output of it is the following;
I hope that works for you as well.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "keyExtraction.h"
using namespace cv;
using namespace std;
int main()
{
Mat m = imread("/home/tbergmueller/clusters.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat debug; // for output only
cvtColor(m,debug, CV_GRAY2BGR); // convert to BGR to allow red numbers printed to this mat
bitwise_not(m,m); // Invert because my algorithm is for searching black regions
CvMat cMat = m;
avPoint* clusters = NULL; // important: init with NULL, otherwise algo crashes
int nrOfPoints = avExtractKeys(&cMat,&clusters);
cout << "Found " << nrOfPoints << " points" << endl;
for(int i=0; i<nrOfPoints; i++)
{
stringstream ss;
ss << i;
Point p(clusters[i].center.x, clusters[i].center.y);
putText(debug,ss.str(),p,CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(255,0,0), 1, CV_AA);
}
imshow("Debug", debug);
waitKey();
return 0;
}
I uploaded the complete source if you want; http://thomasbergmueller.com/share/src.zip
2 | No.2 Revision |
Uchiyama did a Paper on his so called "Random dot markers" where he searches for black blobs (inverse of your binary-image..) before applying the LLAH to identify the markers. I'm not entirely sure whether I used parts of his algorithm (Source available at http://hvrl.ics.keio.ac.jp/uchiyama/me/code/UCHIYAMARKERS/index.html ) or was unsatisfied and implemented it on my own, at least my comment in the header says it's somewhere grabbed from there.
However, I found a pretty nice implementation I did a year ago - not really tested but working. The output of it is the following;
I hope that works for you as well.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "keyExtraction.h"
using namespace cv;
using namespace std;
int main()
{
Mat m = imread("/home/tbergmueller/clusters.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat debug; // for output only
cvtColor(m,debug, CV_GRAY2BGR); // convert to BGR to allow red numbers printed to this mat
bitwise_not(m,m); // Invert because my algorithm is for searching black regions
CvMat cMat = m;
avPoint* clusters = NULL; // important: init with NULL, otherwise algo crashes
int nrOfPoints = avExtractKeys(&cMat,&clusters);
cout << "Found " << nrOfPoints << " points" << endl;
for(int i=0; i<nrOfPoints; i++)
{
stringstream ss;
ss << i;
Point p(clusters[i].center.x, clusters[i].center.y);
putText(debug,ss.str(),p,CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(255,0,0), 1, CV_AA);
}
imshow("Debug", debug);
waitKey();
return 0;
}
I uploaded the complete source if you want; http://thomasbergmueller.com/share/src.zip
3 | Added image |
Uchiyama did a Paper on his so called "Random dot markers" where he searches for black blobs (inverse of your binary-image..) before applying the LLAH to identify the markers. I'm not entirely sure whether I used parts of his algorithm (Source available at http://hvrl.ics.keio.ac.jp/uchiyama/me/code/UCHIYAMARKERS/index.html ) or was unsatisfied and implemented it on my own, at least my comment in the header says it's somewhere grabbed from there.
However, I found a pretty nice implementation I did a year ago - not really tested but working. The output of it is the following;
I hope that works for you as well.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "keyExtraction.h"
using namespace cv;
using namespace std;
int main()
{
Mat m = imread("/home/tbergmueller/clusters.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat debug; // for output only
cvtColor(m,debug, CV_GRAY2BGR); // convert to BGR to allow red numbers printed to this mat
bitwise_not(m,m); // Invert because my algorithm is for searching black regions
CvMat cMat = m;
avPoint* clusters = NULL; // important: init with NULL, otherwise algo crashes
int nrOfPoints = avExtractKeys(&cMat,&clusters);
cout << "Found " << nrOfPoints << " points" << endl;
for(int i=0; i<nrOfPoints; i++)
{
stringstream ss;
ss << i;
Point p(clusters[i].center.x, clusters[i].center.y);
putText(debug,ss.str(),p,CV_FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(255,0,0), 1, CV_AA);
}
imshow("Debug", debug);
waitKey();
return 0;
}
I uploaded the complete source if you want; http://thomasbergmueller.com/share/src.zip