ARUCO Marker - Pose estimation

asked 2020-03-09 22:51:29 -0600

updated 2020-03-10 03:41:50 -0600

supra56 gravatar image

Hey, i am using a separately compiled Aruco library (3.1.9). i am kind of new to all this. I understand that the function in this library is very different from the tutorial provided by openCV. I am using Kinect4.0 . I have the camera matrix and its distortion coefficient (hoping its right) . if you know the API to retrieve Kinect 4 intrinsics , Lemme know too. Anw, my goal is to be able to draw 3D axis on the four aruco markers.

CameraParameters camP;
                //MarkerMap Markermap;
            //  MarkerPoseTracker Markerpose;
                Marker Markers1;
                try {
                    Mat cam_K1 = (Mat_<float>(3, 3) << 6.0673152953959038e+02, 0, 6.3239497947721168e+02,
                        0, 5.9697422854193269e+02, 3.5950738778984589e+02,
                        0, 0, 1);
                    //cam_K1.convertTo(cam_K1, CV_64F);
                    Mat cam_KC1 = (Mat_<float>(1, 4) << 1.0176580485723817e-01, -8.0501599482671743e-02, -1.1446067749405969e-02, -4.0922733208172092e-03

                        );
                    //cam_KC1.convertTo(cam_KC1, CV_64F);
                    camP.setParams(cam_K1, cam_KC1, color_frame.size());
                    Markers1.calculateExtrinsics(0.08F, camP, false);
                }
                catch (cv::Exception &e)
                {
                    cerr << e.msg << endl;
                }
                //Markerpose.estimatePose(Markers1, camP, 0.08, 4.0F);
                //Mat RT = Markerpose.getRvec();
                //Mat TT = Markerpose.getTvec();

                Mat color_Frame_withaxis;
                color_Frame_withaxis = color_frame.clone();
                CvDrawingUtils::draw3dAxis(color_Frame_withaxis, camP, Markers1.Rvec,Markers1.Tvec, 2.0);
                imwrite("color_frame_withaxis.png", color_Frame_withaxis);

color_Frame is the coloured image captured form kinect. am manually writing the cam mat n Dcoeff bcz am lazy to make a call to the file to retrieve.
Is it the correct to way to try and draw 3D axis on the image?

Gist : Create a Marker object and CameraParameter object. Save the parameters in "camP". Call Markers1.extrinsics to save Rvec and Tvec then use Draw3Daxis to see the result. As of now am getting error in obtaining Rvec and Tvec.

edit retag flag offensive close merge delete