# Cannot detect aruco marker

**URL:** <https://forum.ubiquityrobotics.com/t/cannot-detect-aruco-marker/1056>\
**Category:** Uncategorized\
**Created:** [May 14, 2023, 11:01am UTC](https://forum.ubiquityrobotics.com/t/cannot-detect-aruco-marker/1056 "2023-05-14T11:01:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dododo456](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/d/8edcca/32.png) [@dododo456](https://forum.ubiquityrobotics.com/u/dododo456)\
**Post date:** [May 14, 2023, 11:01am UTC](https://forum.ubiquityrobotics.com/t/cannot-detect-aruco-marker/1056/1 "2023-05-14T11:01:46Z")

</div>

Hello,

I tried aruco marker with following code.  
But markerIds.size() keeps zero. However marker is in front of camera.  
Camera module works normally maybe.

To use aruco maker, I installed ros-noetic-fiducials.  
And aruco marker was generated by  
$ rosrun aruco\_detect create\_markers.py 100 112 fiducials.pdf

Could someone advise me on what the problem is?  
Are few warning of GStreamer related to this problem?

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* The code \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
#include   
#include   
#include \<opencv2/opencv.hpp\>  
#include \<opencv2/aruco.hpp\>

using namespace std;  
using namespace cv;  
using namespace aruco;

int main(int argc, char\*\* argv)  
{  
VideoCapture cap(0);  
cap.set(cv::CAP\_PROP\_FRAME\_WIDTH, 640);  
cap.set(cv::CAP\_PROP\_FRAME\_HEIGHT, 480);

```
Ptr<Dictionary> dictionary = getPredefinedDictionary(DICT_4X4_50);

//reading camera calibration data
cv::Mat cameraMatrix, distCoeffs;
cv::FileStorage fs("calibration.xml", cv::FileStorage::READ);
fs["camera_matrix"] >> cameraMatrix;
fs["dist_coeffs"] >> distCoeffs;

while (true) {
    Mat frame;
    cap.read(frame);

    vector<int> markerIds;
    vector<vector<Point2f>> markerCorners;
    detectMarkers(frame, dictionary, markerCorners, markerIds);

    if (markerIds.size() > 0) {
        drawDetectedMarkers(frame, markerCorners, markerIds);
        vector<Vec3d> rvecs, tvecs;
        estimatePoseSingleMarkers(markerCorners, 0.05, cameraMatrix, distCoeffs, rvecs, tvecs);

        for (int i = 0; i < markerIds.size(); i++) {
            cout << "Marker ID: " << markerIds[i] << endl;
            cout << "Translation: " << tvecs[i] << endl;
            cout << "Rotation: " << rvecs[i] << endl;
        }
    }

    imshow("ArUco Marker Detection", frame);
    waitKey(1);
}

return 0;

```

}

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* Warning \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[WARN:0] global …/modules/videoio/src/cap\_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory.  
[WARN:0] global …/modules/videoio/src/cap\_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline  
[WARN:0] global …/modules/videoio/src/cap\_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

---

<div class="post-metadata">

**Author:** ![anfederman](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/anfederman/32/141_2.png) [@anfederman](https://forum.ubiquityrobotics.com/u/anfederman)\
**Post date:** [May 20, 2023, 9:45pm UTC](https://forum.ubiquityrobotics.com/t/cannot-detect-aruco-marker/1056/2 "2023-05-20T21:45:14Z")

</div>

Here is the the rostopic list of a aruco stack running in simulation:

/aruco\_detect/compressed/parameter\_descriptions  
/aruco\_detect/compressed/parameter\_updates  
/aruco\_detect/parameter\_descriptions  
/aruco\_detect/parameter\_updates  
/fiducial\_images  
/fiducial\_images/compressed  
/fiducial\_images/compressed/parameter\_descriptions  
/fiducial\_images/compressed/parameter\_updates  
/fiducial\_images/compressedDepth  
/fiducial\_images/compressedDepth/parameter\_descriptions  
/fiducial\_images/compressedDepth/parameter\_updates  
/fiducial\_images/theora  
/fiducial\_images/theora/parameter\_descriptions  
/fiducial\_images/theora/parameter\_updates  
/fiducial\_map  
/fiducial\_pose  
/fiducial\_slam/camera\_pose  
/fiducial\_transforms  
/fiducial\_vertices  
/fiducials  
/ignore\_fiducials  
/raspicam\_node/camera\_info  
/raspicam\_node/image/compressed

These topics need to be sending data for aruco markers to work. To debug I would run rostopic echo on the topics starting with raspicam, to see where the stack is failing.

---

<div class="post-metadata">

**Author:** ![dododo456](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/d/8edcca/32.png) [@dododo456](https://forum.ubiquityrobotics.com/u/dododo456)\
**Post date:** [May 20, 2023, 11:27pm UTC](https://forum.ubiquityrobotics.com/t/cannot-detect-aruco-marker/1056/3 "2023-05-20T23:27:20Z")

</div>

Thank you for your reply!  
This issue was resolved.
