1

I am following the OpenCV tutorial http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_calib3d/py_calibration/py_calibration.html

Instead of running it with a chess board, I got my 3D point coordinates from a LAS file. Here is my code:

import cv2
import numpy as np

obj_point = [(630931.35,4833642.85,157.67),(630948.03,4833662.76,73.94), (631156.3, 4833904.18, 43.89),(630873.71, 4833790, 44.85), (631381.3, 4834152.6, 79.41)]
img_point = [(1346.82,843.206),(1293.03,808.146),(1041.92, 585.168), (1150.21, 894.724), (756.993,345.904) ]

obj_point = np.array(obj_point,'float32')
img_point = np.array(img_point,'float32')

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(obj_point, img_point, (1125, 1725),None,None) 

I got the following error message:

For non-planar calibration rigs the initial intrinsic matrix must be specified in function cvCalibrateCamera2

Thx in advance!

Free Tyler1
  • 149
  • 1
  • 2
  • 7

2 Answers2

1

You need to use the flag CV_CALIB_USE_INTRINSIC_GUESS

PSchn
  • 718
  • 4
  • 14
  • Hey thanks for the answer! Do you know what does the value of "ret" stand for? Is it re-projection error? – Free Tyler1 Aug 22 '16 at 18:29
  • Read [here](http://stackoverflow.com/questions/29628445/meaning-of-the-retval-return-value-in-cv2-calibratecamera)... short version: yes ;) – PSchn Aug 22 '16 at 18:42
0

Go through following code. It may resolve your problem.

3dPts = 3dPts.astype('float32')
2dPts = 2dPts.astype('float32')

imgsize=(640, 480)
# This can be omitted and can be substituted with None below.
camera_matrix = cv2.initCameraMatrix2D([3dPts],[2dPts]), imgsize)  

cv2.calibrateCamera([3dPts], [2dPts], imgsize, camera_matrix, None, 
                    flags=cv2.CALIB_USE_INTRINSIC_GUESS)
Kamble Tanaji
  • 487
  • 6
  • 12