Updated by Alexander Shishkov almost 13 years ago
I couldnt find this elsewhere, so apologies if it's already been fixed. Applies to Linux x64, Opencv 2.3.1, svn6514
In the API, ProjectPoints2 claims that object points can be 3xN or Nx3 (for one-channel), likewise image points can be 2xN or Nx2.
This python code, taken from https://code.ros.org/trac/opencv/browser/trunk/opencv/tests/python/test.py?rev=2296, succeeds in one case and fails in the other (commented lines).
<pre><code class="cpp"> <pre>
import cv
intrinsic_mat = cv.CreateMat(3, 3, cv.CV_32FC1);
distortion_coeffs = cv.CreateMat(1, 4, cv.CV_32FC1);
cv.SetZero(intrinsic_mat)
intrinsic_mat[0,2] = 320.0
intrinsic_mat[1,2] = 240.0
intrinsic_mat[0,0] = 320.0
intrinsic_mat[1,1] = 320.0
intrinsic_mat[2,2] = 1.0
cv.SetZero(distortion_coeffs)
distortion_coeffs[0,0] = 1e-1
fptypes = [cv.CV_32FC1, cv.CV_64FC1]
for t0 in fptypes:
for t1 in fptypes:
for t2 in fptypes:
for t3 in fptypes:
rotation_vector = cv.CreateMat(1, 3, t0)
translation_vector = cv.CreateMat(1, 3, t1)
object_points = cv.CreateMat(7, 3, t2)
image_points = cv.CreateMat(7, 2, t3)
# object_points = cv.CreateMat(3, 7, t2) # Fails
# image_points = cv.CreateMat(2, 7, t3)
cv.ProjectPoints2(object_points, rotation_vector, translation_vector, intrinsic_mat, distortion_coeffs, image_points)
</code></pre> </pre>
In the API, ProjectPoints2 claims that object points can be 3xN or Nx3 (for one-channel), likewise image points can be 2xN or Nx2.
This python code, taken from https://code.ros.org/trac/opencv/browser/trunk/opencv/tests/python/test.py?rev=2296, succeeds in one case and fails in the other (commented lines).
<pre><code class="cpp"> <pre>
import cv
intrinsic_mat = cv.CreateMat(3, 3, cv.CV_32FC1);
distortion_coeffs = cv.CreateMat(1, 4, cv.CV_32FC1);
cv.SetZero(intrinsic_mat)
intrinsic_mat[0,2] = 320.0
intrinsic_mat[1,2] = 240.0
intrinsic_mat[0,0] = 320.0
intrinsic_mat[1,1] = 320.0
intrinsic_mat[2,2] = 1.0
cv.SetZero(distortion_coeffs)
distortion_coeffs[0,0] = 1e-1
fptypes = [cv.CV_32FC1, cv.CV_64FC1]
for t0 in fptypes:
for t1 in fptypes:
for t2 in fptypes:
for t3 in fptypes:
rotation_vector = cv.CreateMat(1, 3, t0)
translation_vector = cv.CreateMat(1, 3, t1)
object_points = cv.CreateMat(7, 3, t2)
image_points = cv.CreateMat(7, 2, t3)
# object_points = cv.CreateMat(3, 7, t2) # Fails
# image_points = cv.CreateMat(2, 7, t3)
cv.ProjectPoints2(object_points, rotation_vector, translation_vector, intrinsic_mat, distortion_coeffs, image_points)
</code></pre> </pre>