# Aruco aruco.drawAxis() not accepting arguments

**URL:** <https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872>\
**Category:** Python\
**Tags:** aruco\
**Created:** [December 26, 2021, 6:29pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872 "2021-12-26T18:29:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattWTSN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mattwtsn/32/2114_2.png) [@MattWTSN](https://forum.opencv.org/u/MattWTSN)\
**Post date:** [December 26, 2021, 6:29pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/1 "2021-12-26T18:29:53Z")

</div>

This is the camera matrix content:

```auto
[[1.39808931e+03 0.00000000e+00 1.05008177e+03]
[0.00000000e+00 1.39923210e+03 7.37656591e+02]
[0.00000000e+00 0.00000000e+00 1.00000000e+00]]

```

This is the relevant code:

```auto
corners, ids, rejectedImgPoints = aruco.detectMarkers(img, aruco.getPredefinedDictionary(aruco.DICT_4X4_1000))
    
retval, rvec, tvec = aruco.estimatePoseBoard( corners, ids, board, camera_matrix, dist_coeffs, None, None )
    
frame = aruco.drawAxis(img, camera_matrix, dist_coeffs, rvec, tvec, length=0.008 )

```

This is the error message:

`cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-i3ohmhl0\opencv\modules\calib3d\src\calibration.cpp:556: error: (-5:Bad argument) One of required arguments is not a valid matrix in function 'cvProjectPoints2Internal'`

What is wrong?

---

<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:** [December 26, 2021, 7:35pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/2 "2021-12-26T19:35:20Z")

</div>

the other arguments would be good to know too. values, `shape`, `dtype`, …

---

<div class="post-metadata">

**Author:** ![MattWTSN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mattwtsn/32/2114_2.png) [@MattWTSN](https://forum.opencv.org/u/MattWTSN)\
**Post date:** [January 2, 2022, 4:47pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/3 "2022-01-02T16:47:02Z")

</div>

Sure.

1. print(img) gives

```auto
[[[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 ...

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ...
  [0 0 0]
  [0 0 0]
  [0 0 0]]]

```

1. `print(dist_coeffs)` gives  
`[[-4.25085710e-01 2.29057132e-01 4.01520054e-04 -2.88108507e-04 -6.83859299e-02]]`

2. `print(rvec)` and `print(tvec)` give `None`

3. `print( numpy.shape (img) )` gives (4192, 3104, 3)

1. `print( numpy.shape (camera_matrix) )` gives `(3, 3)`

2. `print( numpy.shape (dist_coeffs) )` gives `(1, 5)`

1. `print( numpy.shape (rvec) )` and `print( numpy.shape (rvec) )` gives `()`.

2. `print( numpy.dtype (rvec) )` and `print( numpy.dtype (rvec) )` gives `float64`.

---

<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:** [January 2, 2022, 5:33pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/4 "2022-01-02T17:33:44Z")

</div>

estimate _single_ markers. I doubt you actually have a _board_. you didn’t show the definition of `board`.

the rvec and tvec being none tells me the function couldn’t do its job. retval is likely `False`.

the image looks black around the corners. why is that? is it entirely black? what did you do to it? post the whole image. post source data. post the entire code.

---

<div class="post-metadata">

**Author:** ![MattWTSN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mattwtsn/32/2114_2.png) [@MattWTSN](https://forum.opencv.org/u/MattWTSN)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/5 "2022-01-05T15:08:25Z")

</div>

Oh, I didn’t realize that error message simply meant markers were not detected. It seems like something more fundamental was wrong in the code. I increased source resolution and the board markers were detected as expected.

Thanks.

How should I implement the exception handling so that my code doesn’t simply crash when markers are not detected, but so that I also won’t be bypassing a real issue?

---

<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:** [January 5, 2022, 6:14pm UTC](https://forum.opencv.org/t/aruco-aruco-drawaxis-not-accepting-arguments/6872/6 "2022-01-05T18:14:35Z")

</div>

check return values.

check if things that _should_ be numpy arrays are actually `None` (identity comparison with None goes like: `thing is None` or `thing is not None`)
