# Aruco Projection positioning

**URL:** <https://forum.opencv.org/t/aruco-projection-positioning/2060>\
**Category:** C++\
**Tags:** calib3d, aruco\
**Created:** [March 10, 2021, 3:23am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060 "2021-03-10T03:23:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CHEN](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@CHEN](https://forum.opencv.org/u/CHEN)\
**Post date:** [March 10, 2021, 3:23am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/1 "2021-03-10T03:23:20Z")

</div>

Hi! I have a micro robot with about height of 2.5cm and radius of 4cm.  
On the top of the robot, I put a Aruco mark on it, and also at the bottom, there are two photoresistors which are very close to the ground.

From  
`cv::aruco::estimatePoseSingleMarkers(corners, length, cameraMatrix, distCoeffs, rvecs, tvecs)`

I get rotation vector `rvecs` and translation vector `tvecs` of the maker.  
However `tvecs` is translation vector of the center of maker (in world coordinate).

Then,I use

```auto
axesPoints.push_back(Point3f(left_x, left_y,0))
axesPoints.push_back(Point3f(right_x, right_y,0))

```

Here `left_x` and `left_y` are _X-_ and _Y-_ axis coordinate of left photoresistor about center of maker, and `right_x` and `right_y` are coordinates of right photoresistor.

I use  
`cv::projectPoints(axesPoints, rvecs, tvecs, camera_matrix, distortion_coefficients, imagePoints)`

to get the coordinates of two photoresistors in the image/pixel coordinate system. I can get  
accurate coordinates of the two photoresistors just when the marker is directly below the camera, but in other positions, it’s a little bad.  
Even if I take into account the height difference between the photoresistors and the marker,

```auto
axesPoints.push_back(Point3f(left_x, left_y,h))
axesPoints.push_back(Point3f(right_x, right_y,h))

```

**it did not improve.**

If I can get the translation and rotation of the plane where the photoresistors are located instead of the marker plane, I will get the exact coordinates of the photoresistors in the pixel coordinate system. However I don’t konw how to do it.

Or how can I get the accurate coordinates in the image/pixel coordinate system of two photoresistors by the maker on the top of robot.

Any hints would be appreciated  
Best regards.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 10, 2021, 10:03am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/2 "2021-03-10T10:03:37Z")

</div>

welcome

> [@CHEN](#):
>
> **it did not improve.**

please post data (pictures).

work on your code so it runs in realtime, i.e. with a video feed. observe how the projected points behave while you move the camera. perhaps post such a video. can you see a pattern?

verify that an object-frame vector of (0,0,0) behaves correctly. give the object-frame coordinates of the marker’s corners, see if they get mapped correctly.

---

<div class="post-metadata">

**Author:** ![CHEN](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@CHEN](https://forum.opencv.org/u/CHEN)\
**Post date:** [March 11, 2021, 7:26am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/3 "2021-03-11T07:26:31Z")

</div>

Thank you very much for your reply!

A camera is fixed on the roof, a TV below the camera. So I can only move the robot .  
Here is a video in realtime when I move the robot.  
 ![video1](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/f/fba12c9132adc92fc3fff4a61a4ec6dcb352f97f.gif)

As shown in the video1, from the center to the edge of the TV, the positioning of the photoresistor is  
more and more deviated from the center of the projection circle.

---

<div class="post-metadata">

**Author:** ![CHEN](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@CHEN](https://forum.opencv.org/u/CHEN)\
**Post date:** [March 11, 2021, 7:27am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/4 "2021-03-11T07:27:23Z")

</div>

In the **video1** , I slowly moved the robot from directly below the camera to its lower right, that means  
from the center of the TV to the edge of the TV, as shown in the picture.

 ![fig1](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/e/e0c0fcff6f7efefff0b5ac97e9755cbebd029ff8.png)

How to make the photoresistors always in the center of the projection circle.

---

<div class="post-metadata">

**Author:** ![CHEN](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@CHEN](https://forum.opencv.org/u/CHEN)\
**Post date:** [March 11, 2021, 7:28am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/5 "2021-03-11T07:28:58Z")

</div>

As shown in the **video2** , when I place the marker directly on the TV and move it from the centre of the TV to the edge, the projection positioning does not change, i.e. the photoresistor does not move further and further away from the centre of the projection circle. So I can ensure the object-frame vector of (0,0,0) behaves correctly.  
 ![video2](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/7f854b1befd8731af6f82dcbea4c9772d9d6607c.gif)

For the robot, I suspect that the projection error comes from the height difference between the photoresistors and the marker, because ·tvecs· and· rves· are translation and rotation vector of the center of maker, not the plane in which the photoresistors are located.

We look forward to your reply.  
Best regards!

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 11, 2021, 11:48am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/6 "2021-03-11T11:48:04Z")

</div>

you need adjustments to the `objectPoints` (first) argument to `projectPoints`.

projectPoints takes a single rvec and tvec, so please call those arguments that, rather than a plural (“rvecs”, “tvecs”).

documentation says that the “world” coordinate system is the marker’s coordinate system (frame), and rvec&tvec encode the transformation into camera frame.

so all you need is to put points with a negative z into `objectPoints`… assuming the marker’s frame has x,y in its plane and z being a normal vector away from it.

do this: draw a “box” into your camera view (and show that view)

[https://docs.opencv.org/master/d7/d53/tutorial\_py\_pose.html](https://docs.opencv.org/master/d7/d53/tutorial_py_pose.html)

---

<div class="post-metadata">

**Author:** ![CHEN](https://avatars.discourse-cdn.com/v4/letter/c/3d9bf3/32.png) [@CHEN](https://forum.opencv.org/u/CHEN)\
**Post date:** [March 13, 2021, 3:26am UTC](https://forum.opencv.org/t/aruco-projection-positioning/2060/7 "2021-03-13T03:26:22Z")

</div>

Thank you! I tried, but it didn’t improve.

**so all you need is to put points with a negative z into `objectPoints`… assuming the marker’s frame has x,y in its plane and z being a normal vector away from it.**

However, by using geometric optics rather than the aruco library, I have basically solved this problem, making the projection positioning more accurate, which meets my requirements.
