PDA

View Full Version : Either IC_SetFormat or IC_GetFormat behaving unexpectedly



marimar128
September 14, 2014, 22:06:08
I'm using:
IC Imaging Control C DLL 3.3.0.8 (http://www.theimagingsource.com/en_US/support/downloads/details/icimagingcontrolcwrapper/) (tisgrabber_x64.dll)
Windows 7 64-bit
DMK 23GP031 connected over ethernet

I'm issuing a series of DLL calls. Many of them seem to work, but I'm not getting the results that I expect when I call SetFormat or GetFormat. Specifically, GetFormat always returns 5 (which corresponds to NONE in the COLORFORMAT enum). Am I using SetFormat and GetFormat correctly?

This troubles me, because according to the documentation:

A sink type must be set before images can be snapped.
Is this true? If so, it seems to me that I need to get this working correctly. A small piece of example code in C that demonstrates proper use of opening the camera, setting the format, and snapping an image, without invoking graphical dialogs, might be helpful.

I'm using Python to issue these DLL calls. I don't expect anyone else to be familiar with Python, but the code is very simple, and corresponds in an obvious way to C code. I have used Python to talk to many other DLLs for other types of hardware; it is possible Python is the source of the problem, but in the past, it's always my mistakes, or rarely, a bug in the underlying DLL. Hopefully Python will not be a "language barrier" which prevents us from resolving this problem.

Here is my example code, which triggers the unexpected behavior:


import ctypes as C

def test_dll(dll):
"""
A sequence of DLL calls. Written in python, but should look very
similar to C code.
"""
result = dll.init_library(0)
print result # 1

handle = dll.create_grabber()

result = dll.open_by_name(handle, 'DMK 23GP031 20310114')
print result # 1

result = dll.is_valid(handle)
print result # 1

num_formats = dll.get_video_format_count(handle)
print num_formats # 46

example_format = dll.get_video_format(handle, 0)
print example_format # Y16 (96x96)

sink_format = dll.get_format(handle)
print sink_format # 5

result = dll.set_format(handle, 0)
print result # 1

sink_format = dll.get_format(handle)
print sink_format #5, but shouldn't it be 0 now?

result = dll.set_format(handle, 6)
print result # 0, good that this fails.

"""
Tell python the function prototypes, so it can call the DLL correctly
"""

class GrabberHandle_t(C.Structure):
_fields_ = [('unused', C.c_int)]
GrabberHandle = C.POINTER(GrabberHandle_t)

dll = C.windll.LoadLibrary('tisgrabber_x64')

dll.init_library = dll.IC_InitLibrary

dll.create_grabber = dll.IC_CreateGrabber
dll.create_grabber.argtypes = []
dll.create_grabber.restype = GrabberHandle

dll.open_by_name = dll.IC_OpenDevByUniqueName
dll.open_by_name.argtypes = [GrabberHandle, C.c_char_p]
dll.open_by_name.restype = C.c_int

dll.is_valid = dll.IC_IsDevValid
dll.is_valid.argtypes = [GrabberHandle]
dll.is_valid.restype = C.c_int

dll.get_video_format_count = dll.IC_GetVideoFormatCount
dll.get_video_format_count.argtypes = [GrabberHandle]
dll.get_video_format_count.restype = C.c_int

dll.get_video_format = dll.IC_GetVideoFormat
dll.get_video_format.argtypes = [GrabberHandle, C.c_int]
dll.get_video_format.restype = C.c_char_p

dll.get_format = dll.IC_GetFormat
dll.get_format.argtypes = [GrabberHandle]
dll.get_format.restype = C.c_int

dll.set_format = dll.IC_SetFormat
dll.set_format.argtypes = [GrabberHandle, C.c_uint32]
dll.set_format.restype = C.c_int

test_dll(dll)

Stefan Geissler
September 24, 2014, 14:41:51
Did we already handled this by email?

strator
May 27, 2015, 01:00:45
Dear Stefan,

would you be so kind to answert this question, please? I have exactly the same problem and
your response is not helpful at all.

Best regards
Torsten

Stefan Geissler
June 8, 2015, 12:40:20
I never got an email from this customer, therefore, I did not answer this.