Ask Your Question
0

Need Help in Marker detection using openCV and ARToolKit

asked 2012-09-18 12:40:08 -0600

Mayank gravatar image

updated 2020-11-03 08:49:17 -0600

Hello Everyone,

I am currently working on a project which requires marker detection and then over laying it with some other image. I am not able to understand how marker detection works and how can I program it with OpenCV. The ARToolkit examples are in OpenGL but I need my program to be in OpenCV.

The problem is I am not able to under stand how do I detect the marker and get its co- ordinates.

I have attached my code Please guide me on what should I do next I just need to learn to detect a marker any marker would do.

int pattID  = 0;
char           *patt_name      = "Data/patt.hiro";
double          patt_width     = 80.0;
double          patt_center[2] = {0.0, 0.0};
double          patt_trans[3][4];

int main()
{
    CvCapture* capture = cvCaptureFromCAM(0);
    if(!capture)
    {
        printf("No Cam Connected");
        getch();
        return -1;
    }
IplImage* frame = cvQueryFrame(capture);

//Load (default) camera parameters
ARParam cameraParam;
if(arParamLoad("camera_para.dat",1,&cameraParam) < 0)
{
    printf("Camera calibration parameters file Load Error\n");
    getch();
    return -1;
}

//Initalize Camera Parameters
arInitCparam(&cameraParam);

//Load Hiro Pattern
if((pattID = arLoadPatt(patt_name)) < 0)
{
    printf("Pattern File Load Error");
    getch();
    return -1;
}

while(1)
{
    ARMarkerInfo* markerInfo = NULL;
    int markerNum = -1;

    IplImage* img = cvQueryFrame(capture);


    //Code for Resizing of image
/* input new width and height.

arParamChangeSize(&cameraParam, frame.rows, frame.cols, &cameraParam);

*/

// Marker Detection
    if (arDetectMarker((ARUint8 *)frame->imageData, 150, &markerInfo, &markerNum) < 0) 
 {
    printf("Marker Detector Error");
    getch();
    return -1;
 }

 //Check which one of the found markers is the one we seek
int k = -1;
    for (int i = 0; i < markerNum; i++) 
    {
        if (pattID == markerInfo[i].id) 
        {
            if (k == -1) 
            {
                k = i;
            } 
            else if (markerInfo[k].cf < markerInfo[i].cf) 
            {
                k = i;
            }
        }
    }

//Please Let me know how to proceed further in this code. }

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2012-09-25 10:58:51 -0600

Kirill Kornyakov gravatar image

Try to investigate these two projects

  1. https://github.com/BloodAxe/OpenCV-Hotshots-Marker-Based-AR
  2. https://github.com/BloodAxe/OpenCV-Hotshots-Markless-AR

Here is some information about them: http://computer-vision-talks.com/2012/09/a-bunch-of-news-about-book-research-and-life/ .

And please note that your question is "not a real question". It may be downvoted by angry people!

edit flag offensive delete link more
1

answered 2013-02-28 14:16:36 -0600

andreg gravatar image

If your project allows other marker based tracking approaches, you may have a look a Track-it-yourself (TIY), it is platform independent open source and builds on OpenCV.

http://code.google.com/p/tiy/

It is an easy to set up and affordable infra-red reflective marker tracking system.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-18 12:40:08 -0600

Seen: 5,912 times

Last updated: Feb 28 '13