Reputation: 5193
I am looking in to Augmented reality marker tracking and found a brilliant OpenCV example on github.
https://github.com/jorge-r-murillo-c/AR-IOs-marker-detector
I believe I found the code that is translated in to the marker that its looking for
int Marker::hammDistMarker(cv::Mat bits)
{
int ids[4][5]=
{
{1,0,0,0,0},
{1,0,1,1,1},
{0,1,0,0,1},
{0,1,1,1,0}
};
int dist=0;
for (int y=0;y<5;y++)
{
int minSum=1e5; //hamming distance to each possible word
for (int p=0;p<4;p++)
{
int sum=0;
//now, count
for (int x=0;x<5;x++)
{
sum += bits.at<uchar>(y,x) == ids[p][x] ? 0 : 1;
}
if (minSum>sum)
minSum=sum;
}
//do the and
dist += minSum;
}
return dist;
}
However this has no correlation to the picture of the marker
I did look in the book that this code came from but it made no sense to me.
Is there a tool, process, function that would turn the image in to the tracking data or am I barking up the wrong tree?
Upvotes: 0
Views: 1295
Reputation: 11
You have a matrix called ids[], and this matrix has the code of the marker in binary system. If you read in binary system, the first row in the matrix is {1,0,0,0,0} and the marker image shows that the first row in the image is one square white and four square black.
The next row has {black,white,white,white,black}={0,1,1,1,0} that corresponds to the fouth row in the matrix.
The hammDistMarker() function computes the distance between the image captured by the camera and the code in the ids matrix, but it computes row per row.
For example, if you remove the white square in the first row of the marker, the matrix will be:
int ids[4][5]=
{
{0,0,0,0,0},
{1,0,1,1,1},
{0,1,0,0,1},
{0,1,1,1,0}
};
I'm sorry, I tried uploading an image but I can't.
I hope this information will be helpful for you.
If you want, I can draw one marker with symbols.
Upvotes: 1