saviopalmieri / ctypes-opencv

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

cvWrite raises TypeError #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Simple script similar to example in documentation:
  from ctypes_opencv import *
  mat = cvCreateMat( 3, 3, CV_32F )
  fs = cvOpenFileStorage("example.yml", None, CV_STORAGE_WRITE)
  cvSetIdentity(mat)
  cvWrite( fs, "A", mat, cvAttrList())

generates following error:
  Traceback (most recent call last):
    File "cvtest2.py", line 7, in <module>
      cvWrite( fs, "A", mat, cvAttrList() );
  ctypes.ArgumentError: argument 3: <type 'exceptions.TypeError'>: wrong type

I'm using opencv-1.1.0-pre build with gentoo ebuild and ctypes-opencv from svn.

Original issue reported on code.google.com by rozstroj...@gmail.com on 11 Aug 2009 at 5:36

GoogleCodeExporter commented 8 years ago
Thanks. I'll take a look asap. A quick look reveals that the 3rd argument of the
cvWrite() function must be a pointer while 'mat' is a CvMat structure. It 
should work
if you replace 'mat' with 'byref(mat)', where 'byref' comes from the 'ctypes'
package. However, I'll investigate the cvWrite() function and see which way is 
best
to wrap this 3rd argument.

Minh-Tri

Original comment by pmtri80@gmail.com on 11 Aug 2009 at 6:20

GoogleCodeExporter commented 8 years ago
I've fixed the cvWrite() function in the main trunk. The 3rd argument is now of 
type
CvArr_r rather than type c_char_p. I agree it should be more appropriate that 
way.
Your example should work now.

Minh-Tri

Original comment by pmtri80@gmail.com on 12 Aug 2009 at 5:01

GoogleCodeExporter commented 8 years ago
It works. Thanks.

Original comment by rozstroj...@gmail.com on 12 Aug 2009 at 7:12