saviopalmieri / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

ctypesArgumentError when calling cvCalibrateCamera2 #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. find chessboardcorners with cvFindChessboardCorners()
2. try to calibrate camera with cvCalibrateCamera2()
3.

What is the expected output? What do you see instead?
I expected camera intrinsics and distortion coeffs returned. Instead, I 
got:
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't 
know how to convert parameter 1

What version of the product are you using? On what operating system?
OpenCV 1.0 with ctypes-opencv 0.7.2 on Windows XP

Please provide any additional information below.
Actually this is rather weird because I could calibrate camera without a 
problem last time. I was calling calibrate camera in a window method, and 
then decided to make my own camera class which has calibration-related 
methods in it. However, the error message implies that I passed a 
parameter of wrong type. Argument 1, object_points, should be cvMat, which 
it exactly is. This is full traceback message:

Traceback (most recent call last):
  File "D:\workspace\Doonoon\gui\Doonoon_frame.py", line 383, in Calibrate
    cam.calibrate()
  File "D:\workspace\Doonoon\gui\Doonoon_frame.py", line 161, in calibrate
    ( intrinsic, distortion ) = cvCalibrateCamera2( byref
(self.object_points), self.image_points, self.point_counts, cvGetSize( 
img ), self.intrinsic_matrix, self.distortion_coeffs, None, None, 0 )
ctypes.ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't 
know how to convert parameter 1

This is what I got when I print argument 1 (objects_points)

CvMat
(type=1111638021,step=12,refcount=66116416,hdr_refcount=1,data=<opencv.cxco
re.CvMatData object at 0x0236FD50>,r=<opencv.cxcore.CvMatRows object at 
0x0236FB70>,c=<opencv.cxcore.CvMatCols object at 0x0236FE40>)

This is the code in which the matrices are generated and used:

    self.intrinsic_matrix  = cvCreateMat( 3, 3, CV_32FC1 )
    self.distortion_coeffs = cvCreateMat( 4, 1, CV_32FC1 )
    self.point_counts      = cvCreateMat( self.n_boards, 1, CV_32SC1 )
    self.image_points      = cvCreateMat( self.n_boards * self.board_n, 2, 
CV_32FC1 )
    self.object_points     = cvCreateMat( self.n_boards * self.board_n, 3, 
CV_32FC1 )
    ...
    ...
      for j in range( self.board_n ):
        #print i, j
        self.image_points[i,0] = corners[j].x
        self.image_points[i,1] = corners[j].y
        self.object_points[i,0] = j / self.board_w
        self.object_points[i,1] = j % self.board_w
        self.object_points[i,2] = 0.0
        i+= 1
        j+= 1
      self.point_counts[self.success_count,0] = self.board_n
    ...
    ...
    self.intrinsic_matrix[0,0] = 1.0
    self.intrinsic_matrix[1,1] = 1.0
    ( intrinsic, distortion ) = cvCalibrateCamera2( self.object_points, 
self.image_points, self.point_counts, cvGetSize( img ), 
self.intrinsic_matrix, self.distortion_coeffs, None, None, 0 )

Sound like a troubleshooting than an issue. Sorry for that. Thanks.

Original issue reported on code.google.com by jikhan.j...@gmail.com on 8 Mar 2009 at 7:13

GoogleCodeExporter commented 8 years ago
Ummm.. my bad. It was not cvCalibrateCamera2() that caused the error. I handed 
wrong 
type of image (PIL image) to cvGetSize() function. 

Original comment by jikhan.j...@gmail.com on 20 Mar 2009 at 10:49

GoogleCodeExporter commented 8 years ago
Glad to know you have fixed the issue. Sorry I couldn't have helped earlier. I 
am
still busy with work these days.

Original comment by pmtri80@gmail.com on 25 Mar 2009 at 1:12