0

I have an application that used to work. I recently had a full reinstall and tried to get the application working again, but I've run up against the problem in the title. I would appreciate any advice on next steps to investigate or try to get it working.

What happens:

ctypes_opencv.cvLoadImage('tmp.bmp', 1) #or a fully specified path

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python32_32bit\lib\site-packages\ctypes_opencv\highgui.py", line 289, in cvLoadImage
    z = pointee(_cvLoadImage(filename, iscolor))
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type

I tried using highgui.py's _cvLoadImage directly and got the same error. I don't think it's getting to the pointee() function.

I haven't been able to find anything I can pass to the function to make it not give me a TypeError. Hopefully I'm missing something obvious, but I haven't changed the code that worked previously.

The setup of this system:

  • windows 7
  • python 3.2.3 32bit (previous installation was 3.1.x 32bit but I couldn't find an installer for it this time)
  • opencv 1.0 (I never had luck with ctypes_opencv and opencv > 1.0)
  • ctypes_opencv 0.8.0
Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
KobeJohn
  • 7,390
  • 6
  • 41
  • 62

1 Answers1

0

Aaargh. I figured it out. ctypes_opencv apparently doesn't accept unicode strings. So using a bytes literal works.

ctypes_opencv.cvLoadImage(b'tmp.bmp', 1) 

I hadn't worried about trying that yet since it used to work with my 3.1.x installation. Weren't all strings already unicode from the beginning of 3.x? I wrote the code myself so I am sure it hasn't been changed since I used it last.

Community
  • 1
  • 1
KobeJohn
  • 7,390
  • 6
  • 41
  • 62
  • if anybody can give a better explanation of where I went wrong, I'll mark yours as the solution :) Easy rep! – KobeJohn Apr 20 '12 at 06:25