Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error: (-215) on solvePnP

The following code produce the error (cv2 on Python 2.7):

error: (-215) npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP

I can't figure out why.

This is the code:

import os, sys
import math
import numpy as np
import cv2
img_file = os.path.join(img_folder,'1.jpg')
img        = cv2.imread(img_file,0)
h,w = img.shape

obj_pts = np.array([[10,60,0],
                    [10,60,12.6],
                    [24,60,0],
                    [24,60,12.6],
                    [24,74,0],
                    [24,74,12.6],
                    [30,70,0],
                    [30,70,8.8],
                    [47.7,70,0],
                    [47.7,70,8.8]
                   ], dtype=np.float32)

img_pts = np.array([[800,970],
                    [689,329],
                    [1380,1175],
                    [1363,458],
                    [1842,881],
                    [1875,256],
                    [1977,1051],
                    [1994,592],
                    [2959,1347],
                    [3052,852]
                   ], dtype=int)
img_pts = np.fliplr(img_pts)
if True:
    ppa     = (w/2., h/2.)
    fm        = 7.5/1e3
    sensor  = (7.14e-3, 5.36e-3)
    focal   = w* (fm / sensor[0])
    cam_mat = np.array( [[focal, 0, ppa[0]],
                         [0, focal, ppa[1]],
                         [0, 0, 1]], dtype = np.float64
                      )
    dist_coeffs = np.zeros((5,1))
    rvec = np.zeros((3,1))
    tvec = np.zeros((3,1)) 
    flag = cv2.SOLVEPNP_ITERATIVE # tried with SOLVEPNP_EPNP, same error.
    retval,  rvec, tvec = cv2.solvePnP(obj_pts, img_pts, cam_mat, dist_coeffs, rvec, tvec, flags=flag)

error: (-215) on solvePnP

The following code produce the error (cv2 on Python 2.7):

error: (-215) npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP

I can't figure out why.

This is the code:

import os, sys
import math
import numpy as np
import cv2
img_folder = ('/home/username/images/')
img_file  = os.path.join(img_folder,'1.jpg')
img        = cv2.imread(img_file,0)
h,w = img.shape

obj_pts = np.array([[10,60,0],
                    [10,60,12.6],
                    [24,60,0],
                    [24,60,12.6],
                    [24,74,0],
                    [24,74,12.6],
                    [30,70,0],
                    [30,70,8.8],
                    [47.7,70,0],
                    [47.7,70,8.8]
                   ], dtype=np.float32)

img_pts = np.array([[800,970],
                    [689,329],
                    [1380,1175],
                    [1363,458],
                    [1842,881],
                    [1875,256],
                    [1977,1051],
                    [1994,592],
                    [2959,1347],
                    [3052,852]
                   ], dtype=int)
img_pts = np.fliplr(img_pts)
if True:
    ppa     = (w/2., h/2.)
    fm        = 7.5/1e3
    sensor  = (7.14e-3, 5.36e-3)
    focal   = w* (fm / sensor[0])
    cam_mat = np.array( [[focal, 0, ppa[0]],
                         [0, focal, ppa[1]],
                         [0, 0, 1]], dtype = np.float64
                      )
    dist_coeffs = np.zeros((5,1))
    rvec = np.zeros((3,1))
    tvec = np.zeros((3,1)) 
    flag = cv2.SOLVEPNP_ITERATIVE # tried with SOLVEPNP_EPNP, same error.
    retval,  rvec, tvec = cv2.solvePnP(obj_pts, img_pts, cam_mat, dist_coeffs, rvec, tvec, flags=flag)

error: (-215) on solvePnP

The following code produce the error (cv2 on Python 2.7):

error: (-215) npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function solvePnP

I can't figure out why.

This is the code:

import os, sys
import math
import numpy as np
import cv2
img_folder = ('/home/username/images/')
img_file   = os.path.join(img_folder,'1.jpg')
img        = cv2.imread(img_file,0)
h,w = img.shape

obj_pts = np.array([[10,60,0],
                    [10,60,12.6],
                    [24,60,0],
                    [24,60,12.6],
                    [24,74,0],
                    [24,74,12.6],
                    [30,70,0],
                    [30,70,8.8],
                    [47.7,70,0],
                    [47.7,70,8.8]
                   ], dtype=np.float32)

img_pts = np.array([[800,970],
                    [689,329],
                    [1380,1175],
                    [1363,458],
                    [1842,881],
                    [1875,256],
                    [1977,1051],
                    [1994,592],
                    [2959,1347],
                    [3052,852]
                   ], dtype=int)
img_pts = np.fliplr(img_pts)
if True:
    ppa     = (w/2., h/2.)
    fm       = 7.5/1e3
    sensor  = (7.14e-3, 5.36e-3)
    focal   = w* (fm w*(fm / sensor[0])
    cam_mat = np.array( [[focal, 0, ppa[0]],
                         [0, focal, ppa[1]],
                         [0, 0, 1]], dtype = np.float64
                      )
    dist_coeffs = np.zeros((5,1))
    rvec = np.zeros((3,1))
    tvec = np.zeros((3,1)) 
    flag = cv2.SOLVEPNP_ITERATIVE # tried with SOLVEPNP_EPNP, same error.
    retval,  rvec, tvec = cv2.solvePnP(obj_pts, img_pts, cam_mat, dist_coeffs, rvec, tvec, flags=flag)