# Issue with cv2.fiseye.calibrate :fisheye.cpp:742: error: (-215:Assertion failed) objectPoints.type() == CV\_32FC3 || objectPoints.type() == CV\_64FC3 in function 'calibrate'

**URL:** <https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049>\
**Category:** Python\
**Tags:** calib3d, fisheye\
**Created:** [March 22, 2022, 12:39pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049 "2022-03-22T12:39:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Francois](https://forum.opencv.org/u/Francois)\
**Post date:** [March 22, 2022, 12:39pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/1 "2022-03-22T12:39:20Z")

</div>

Hi All,

being new to Python and openCV I struggle with the following problem: When calling the cv2.fisheye.calibrate function in the following code:

```auto

def determine_extrinsics_camera(world_points,ref_proj,K,dist,gray,Fisheye,DIM):
    imgpoints=np.zeros((1,world_points.shape[1],2),np.float32)
    imgpoints2=copy(imgpoints)
    vv=np.zeros([1,3])
    R_tot=np.zeros((3,3),np.float32)
    R_inv=np.zeros((3,3),np.float32)
    uv_raw=np.zeros((imgpoints.shape[0],imgpoints.shape[1],imgpoints.shape[2]),np.float32)
    rvecs = [np.zeros((1, 1, 3), dtype=np.float64) for i in range(imgpoints.shape[1])]
    tvecs = [np.zeros((1, 1, 3), dtype=np.float64) for i in range(imgpoints.shape[1])]
    print(imgpoints.shape[1])
    for i in range(0,(imgpoints.shape[1]),1):
        uv_raw[0][i][0]=ref_proj[i][0]
        uv_raw[0][i][1]=ref_proj[i][1]
        if not Fisheye:
            uitkomst=cv2.undistortPoints(uv_raw,K,dist)
            vv[0][:]=((uitkomst[i][0][0],uitkomst[i][0][1],1))
        else:
            newcameramtx = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(
            K, dist, DIM, None, balance=1)
            uitkomst=cv2.fisheye.undistortPoints(uv_raw,K,dist,None,newcameramtx)
            vv[0][:]=((uitkomst[0][i][0],uitkomst[0][i][1],1))
        img_undist=np.matmul(K,np.transpose(vv))
        imgpoints2[0][i][0]=img_undist[0][0]
        imgpoints2[0][i][1]=img_undist[1][0]

    imgpoints=copy(uv_raw)
    if not Fisheye:
        vlag, _, _, rvecs,tvecs = \
        cv2.calibrateCamera
        (world_points,imgpoints2,
        gray.shape[::-1], 
        K,
       None,
       rvecs,
       tvecs,flags=(cv2.CALIB_USE_INTRINSIC_GUESS))
    else:
        calibration_flags = \
        cv2.fisheye.CALIB_RECOMPUTE_EXTRINSIC+cv2.fisheye.CALIB_CHECK_COND
        vlag,_,_,rvecs,tvecs=cv2.fisheye.calibrate(world_points,imgpoints2,gray.shape[::-1],K,None,rvecs,tvecs,calibration_flags,(cv2.TERM_CRITERIA_EPS+cv2.TERM_CRITERIA_MAX_ITER, 30, 1e-6))

```

On the call cv2.fisheye.calibrate I get the following error message:

fisheye.cpp:742: error: (-215:Assertion failed) objectPoints.type() == CV\_32FC3 || objectPoints.type() == CV\_64FC3 in function ‘calibrate’

When not using the fisheye calibration but the ‘normal’ camera function(so the call cv2.calibrateCamera) everything works fine.

I’m working on macOS 12.2.1, python 3.10.3 with cv version 4.5.5

Any ideas, suggestions are welcome!

Thanks in advance

---

<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 22, 2022, 12:54pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/2 "2022-03-22T12:54:54Z")

</div>

> [@Francois](#):
>
> `world_points`

what’s the dtype and shape of that?

---

<div class="post-metadata">

**Author:** ![Francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Francois](https://forum.opencv.org/u/Francois)\
**Post date:** [March 22, 2022, 1:35pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/3 "2022-03-22T13:35:38Z")

</div>

sorry I wasn’t finished yet, a bit struggling with the navigation…

---

<div class="post-metadata">

**Author:** ![Francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Francois](https://forum.opencv.org/u/Francois)\
**Post date:** [March 29, 2022, 8:36am UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/4 "2022-03-29T08:36:01Z")

</div>

The world\_points are defined as:

world\_points=np.zeros((1,10,3),np.float32)

---

<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 29, 2022, 9:21am UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/5 "2022-03-29T09:21:51Z")

</div>

if you have

> [@Francois](#):
>
> world\_points=np.zeros((1,10,3),np.float32)

then this assertion couldn’t have failed because that shape and dtype satisfies the assertion.

> [@Francois](#):
>
> fisheye.cpp:742: error: (-215:Assertion failed) objectPoints.type() == CV\_32FC3 || objectPoints.type() == CV\_64FC3 in function ‘calibrate’

please check `.shape` and `.dtype` directly before the `calibrate` call.

---

<div class="post-metadata">

**Author:** ![Francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Francois](https://forum.opencv.org/u/Francois)\
**Post date:** [March 30, 2022, 9:38am UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/6 "2022-03-30T09:38:17Z")

</div>

Hi,

I did so, the result is  
tye=numpy.ndarray (with dtype =float32) with shape (1,10,3), so I would expect this to work??? Not sure how to proceed…  
kind regards

Francois

---

<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 30, 2022, 9:01pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/7 "2022-03-30T21:01:52Z")

</div>

> [@Francois](#):
>
> Not sure how to proceed…

I’m out of ideas too. puzzling.

please prepare a “[minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)”. simplify the code. pack all required data into the code.

---

<div class="post-metadata">

**Author:** ![Adrien\_Kinart](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/adrien_kinart/32/6494_2.png) [@Adrien\_Kinart](https://forum.opencv.org/u/Adrien_Kinart)\
**Post date:** [November 14, 2022, 12:50pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/8 "2022-11-14T12:50:58Z")

</div>

I ma experiencing the same issue. Did you find a solution to your issue?

---

<div class="post-metadata">

**Author:** ![newbox](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@newbox](https://forum.opencv.org/u/newbox)\
**Post date:** [April 28, 2023, 4:20pm UTC](https://forum.opencv.org/t/issue-with-cv2-fiseye-calibrate-fisheye-cpp-error-215-assertion-failed-objectpoints-type-cv-32fc3-objectpoints-type-cv-64fc3-in-function-calibrate/8049/9 "2023-04-28T16:20:12Z")

</div>

I encountered a similar problem, and found [this page](https://github.com/opencv/opencv/issues/5534) helpful.

it says:

> objpoints has to be resized in python from (\<num points in set\>, 3) to (\<num points in set\>, 1, 3) to pass the objectPoints.type() == CV\_64FC3 check
