# How to use SolvePnP correctly with Aruco markers?

**URL:** <https://forum.opencv.org/t/how-to-use-solvepnp-correctly-with-aruco-markers/4366>\
**Category:** Android/Java\
**Tags:** imgproc, calib3d\
**Created:** [July 17, 2021, 1:32am UTC](https://forum.opencv.org/t/how-to-use-solvepnp-correctly-with-aruco-markers/4366 "2021-07-17T01:32:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hackermaw](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/hackermaw/32/2689_2.png) [@hackermaw](https://forum.opencv.org/u/hackermaw)\
**Post date:** [July 17, 2021, 1:32am UTC](https://forum.opencv.org/t/how-to-use-solvepnp-correctly-with-aruco-markers/4366/1 "2021-07-17T01:32:57Z")

</div>

I am trying to use SolvePnP to render 3D objects on top of Aruco markers in Android, and this is how I am using it:

`solvePnP(marker.getObjPoints(), cornersPoints2f, marker.getCameraMatrix(), (MatOfDouble) marker.getDistortionCoeff(), rvec, tvec);`

- marker.getObjPoints are the object points returned by cv::estimatePoseSingleMarkers()

- cornersPoints2f is a MatOfPoint2f object (Java equivalent of std::vector)

- marker.getCameraMatrix() is the Intrinsic/camera matrix obtained at first through calibration but then stored on disk.

- marker.getDistortionCoeff() is the vector of distortion coefficients.

- rvec and tvec are the output vectors for SolvePnP.

What my issue is:

SolvePnP fails at run-time because an assert fails. The assert fails because it keeps checking if `cornersPoints2f` is 3-channel or 4-channel, and it’s neither. I don’t know why, but `cornersPoints2f` is always 2-Channel. Not something I can change. When the markers are detected, it is just set to 2-Channel and I don’t know what I can do about it.

Here’s the assert in-case you are interested.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/d/dcdcc4620ebcca9294103289639c0901b3559531.png)

What can I do about this? as far as I know, I can’t render objects at all without the SolvePnP step. And I currently can’t make it work. Any ideas as to what I can do?
