Aruco Detection - OpenCV Error: Incorrect size of input array

asked 2018-01-23 08:53:19 -0600

sarah1802 gravatar image

Hi There,

I try to detect my ArUco markers with this posted code (only part of it) and get on the last line the OpenCV Error: Incorrect size of input array ... in cvRodrigues2, file C:...

It worked if I only have one marker in the picture. I think more marker are the problem? But how to solve it (as a beginner I am not sure, what to look for. I have searched the whole day but did not find anything :-( )

    while (true)

    if (playVideo == true)
        if (!

        aruco::detectMarkers(frame, markerDictionary, markerCorners, markerIds);
        aruco::estimatePoseSingleMarkers(markerCorners, arucoSquareDimension, cameraMatrix, distortionCoefficients, rotationVectors, translationVectors);

        for (int i = 0; i < markerIds.size(); i++)
            aruco::drawDetectedMarkers(frame, markerCorners, markerIds);    //Zeichnet die Umrandung und die ID auf die Marker
            aruco::drawAxis(frame, cameraMatrix, distortionCoefficients, rotationVectors[i], translationVectors[i], arucoSquareDimension*0.5f); //Zeichnet die Koordinatensysteme, die Zahl gibt die Größe der Vektoren in Meter an

            //Hier wird die Marker ID in der Konsole ausgegeben
            std::cout << "Die ID des Markers lautet:";
            for (std::vector<int>::iterator it = markerIds.begin(); it != markerIds.end(); ++it)
                std::cout << ' ' << *it;
            std::cout << '\n';

            //Hier wird die Rotation in der Konsole ausgegeben  *180)/(3.14159265359)
            std::cout << "Die Rotation des Markers ist:";
            for (std::vector<Vec3d>::iterator it = rotationVectors.begin(); it != rotationVectors.end(); ++it)
                std::cout << ' ' << (*it * 180) / (3.14159265359) << " grad";
            std::cout << '\n';

            Mat R;

            cv::Rodrigues(rotationVectors, R);

Thank you! Sarah

edit retag flag offensive close merge delete


I think it should be cv::Rodrigues(rotationVectors[i], R); to access the rotation vector for the ith marker.

Eduardo gravatar imageEduardo ( 2018-01-23 14:35:26 -0600 )edit

Thank you. That was the problem :). (Sometimes the little things are the worst in programming :D )

sarah1802 gravatar imagesarah1802 ( 2018-01-24 02:17:55 -0600 )edit