Vernier Library
detectingHPCodePattern.cpp
#include "Vernier.hpp"
using namespace vernier;
using namespace cv;
using namespace std;
int main() {
// Loading the image
string filename = "HPCodeImage_20um.png";
Mat image = cv::imread(filename);
// Detecting the pattern and estimating its pose
double physicalPeriod = 20; // µm
int snapshotSize = 256; // pixels
HPCodePatternDetector detector(physicalPeriod, 33, snapshotSize);
detector.compute(image);
// Displaying the pose if a pattern has been found
cout << "Detector: " << detector.toString() << endl;
if (detector.patternFound()) {
cout << "Found " << detector.markers.size() << " markers in " << filename << endl;
for (auto it : detector.markers) {
cout << " Stamp " << it.first << " at " << it.second.toString() << endl;
}
detector.draw(image);
} else {
cout << "Marker not found..." << endl;
}
// Showing image and its spectrum
detector.showControlImages();
imshow(filename, image);
waitKey(3000);
}