morefigs / py-ic-imaging-control

Python wrapper for the IC Imaging Control SDK from The Imaging Source (TIS)
MIT License
33 stars 22 forks source link

Setting exposure property causes TypeError #20

Open flysorter opened 7 years ago

flysorter commented 7 years ago

This is similar, I realize to issue #17, but reading through that thread didn't actually give me the information required to fix the problem.

So I've got the library installed on a Windows 10 x64 machine, with the TISGrabber_x64.dll in its default location. I can list cameras, get handles, and snap images. But problems arise when I try to set the exposure property via the API:

import pyicic.IC_ImagingControl

ic_ic = pyicic.IC_ImagingControl.IC_ImagingControl()
ic_ic.init_library()
cam_names = ic_ic.get_unique_device_names()
cam = ic_ic.get_device(cam_names[0])
cam.open()
cam.exposure.value = -7

This returns

Traceback (most recent call last):
  File "C:/Users/dzucker/Desktop/cameratest.py", line 10, in <module>
    cam.exposure.value = -7
  File "build\bdist.win-amd64\egg\pyicic\IC_Property.py", line 81, in value
    if self.auto_available:
  File "build\bdist.win-amd64\egg\pyicic\IC_Property.py", line 29, in auto_available
    c_int(self._prop_index))
ArgumentError: argument 1: <type 'exceptions.TypeError'>: wrong type

I'm not very familiar with Python DLL wrappers, so I haven't been able to debug very well (my apologies). As near as I can tell, this comes about because of the implementation of the IC_IsCameraPropertyAutoAvailable function in IC_GrabberDLL.py, but it appears to match up with the function prototype in the SDK docs (which is int AC IC_IsCameraPropertyAutoAvailable ( HGRABBER | hGrabber, CAMERA_PROPERTY iProperty)

I guess the error message is complaining that argument 1 isn't of the correct type, which would be the grabber handle. If I look at the _handle variable in an interactive shell, it shows up as:

<pyicic.IC_GrabberDLL.LP_GrabberHandle object at 0x00000000031255C8>

Seems plausible, no?

Any ideas? Thanks!

flysorter commented 7 years ago

I found the bug responsible for this issue, in IC_GrabberDLL.py. The argtypes for is_camera_property_auto_available was a set (using curly braces) instead of a tuple (parentheses).

I changed the code in a fork and sent a pull request. (#21)