Reputation: 1479
Hope you can help me out. I try to use Aruco marker for finding the corners of an Window. So added an marker to each corner. But when i tried to detected the marker they don't get found. If it take a photo with an smartphone and then try to detect the marker on the Photo it works. Here is a minimum working Code example:
#include <opencv2/opencv.hpp>
#include <stdlib.h>
#include <string>
#include <opencv2/aruco.hpp>
using namespace cv;
using namespace std;
using namespace aruco;
Dictionary dictionary;
int markerSize = 200;
vector<int> ids;
vector< vector<Point2f> > corners;
Mat addMarkertoImage(const Mat image){
Mat retImage, marker0;
image.copyTo(retImage);
drawMarker(dictionary, 0, markerSize, marker0, 1);
unsigned char value;
//Add marker to top left corner
for(int i = 0; i<marker0.rows; i++)
for(int j = 0; j<marker0.cols; j++){
value = marker0.at<uchar>(i,j);
Vec3b colorValue = Vec3b(value, value, value);
retImage.at<Vec3b>(i,j) = colorValue;}
return retImage;
}
int main(){
Mat image, image_marker;
dictionary = getPredefinedDictionary(cv::aruco::DICT_6X6_250);
image = imread( "bild.jpg", 1 );
image_marker = addMarkertoImage(image);
detectMarkers(image_marker, dictionary, corners, ids);
drawDetectedMarkers(image_marker, corners, ids);
imshow("Display Image", image_marker);
waitKey(0);
return 0;
}
Any Ideas, why this does not work? But with an Photo taken by my iPhone camera is working?
Upvotes: 0
Views: 3421
Reputation: 1479
You meanwhile i solved the Problem on my own, the problem was the marker were to big to detected, with the default configuration. So i needed only to update the dectorparamenters and the example in the question worked.
Edit: Because i was asked of the changed parameters here. I added this code snipped with the changes:
ImageFinder::ImageFinder() {
//initalize dictionary with markers....
dictionary = getPredefinedDictionary(cv::aruco::DICT_6X6_250);
dp = new DetectorParameters();
dp->minDistanceToBorder = 0;
dp->adaptiveThreshWinSizeMax = 400;
}
Upvotes: 1