Access to advanced features (Allied Vision Tec)

47 views
Skip to first unread message

Malte

unread,
Jul 30, 2010, 7:03:14 AM7/30/10
to pydc1394
Hi,

I am currently trying to access some advanced features offered by my
Allied Vision Tec Camera (Stingray 145b). I installed the libdc1934 by
avt [1], but the functions I am interested in seem to be in the
standard library as well.[2]
I am especially interested in dc1394_avt_get_timebase() and
dc1394_avt_set_timebase() as I need to increase the shutter time
(shuttertime = shuttervalue * timebase + offset) to above the current
limits (Max shuttervalue = 4095, timebase = 20µs, offset 70µs).
I checked the _dc1394core.py to see if those functions appear
anywhere, but it doesn't seem like it. I was wondering, if anyone
would be able to wrap those features in pydc or give me pointers on
how to do it myself. I have never wrapped C-code before, let alone
written in C...
Many regards,
Malte


[1] http://www.alliedvisiontec.com/de/produkte/software/linux/avt-fire4linux.html
[2] http://damien.douxchamps.net/ieee1394/libdc1394/v2.x/api/avt/

SirVer

unread,
Aug 3, 2010, 9:43:46 AM8/3/10
to pydc1394
Hi Malte,

the avt functions are not wrapped currently in pydc1394; they should
be rather easy to do though. Have a look at _dc1394core.py and how the
functions defined there are used in camera.py. With this and the
ctypes documentation you should be able to run along. Feel free to ask
any questions here and remember to make your code available for
merging :).

Holger
> [1]http://www.alliedvisiontec.com/de/produkte/software/linux/avt-fire4li...
> [2]http://damien.douxchamps.net/ieee1394/libdc1394/v2.x/api/avt/

Malte

unread,
Aug 4, 2010, 6:39:33 AM8/4/10
to pydc1394
Hi,

I managed to implement the two functions I needed. Sadly, I was unable
to do this in a very elegant way (not due to the lack of trying). I
tried wrapping "typedef struct __dc1394_avt_adv_feature_info_struct"
from avt.h in the _dc1394core.py to make it somehow similar to the
other code, but failed miserably. That's why I didn't attach a code
with which to check for available advanced AVT-features. So anybody
calling the function should know that it is available. If someone
could help out with hints on how to do it, I could try again, but for
now I am satisfied with the working timebase functions.

So there is no support for the other functions, as I don't see the
added value at the moment.
I don't know how to add stuff in launchpad/bazaar so I just attach the
changes to the end of the mail.

Malte

Additions:
In camera.py
in
class Camera(object):
###AVT cameras only
#register settings and the corresponding times
#the corresponding times are from the manual AVT-Stingray, v4.3.0,
p.291
#value 0 | 1 microsecond
#value 1 | 2 microseconds
#value 2 | 5 microseconds
#value 3 | 10 microseconds
#value 4 | 20 microseconds
#value 5 | 50 microseconds
#value 6 | 100 microseconds
#value 7 | 200 microseconds
#value 8 | 500 microseconds
#value 9 | 1000 microseconds
#calculation if the resulting shutter time, see the manual of the
camera
#grab the value for the timebase
def get_avt_timebase( self ):
if not self._cam:
raise RuntimeError, "The camera is not opened!"
val = c_uint32()
_dll.dc1394_avt_get_timebase( self._cam, byref(val))
return val.value
#set the timebase value
def set_avt_timebase( self , value):
if not self._cam:
raise RuntimeError, "The camera is not opened!"
val = c_uint32(value)
if val.value >= 0 and val.value <= 9:
_dll.dc1394_avt_set_timebase( self._cam, val)
else:
print "Timebase value can only be in the range of 0-9"

in _pydc1394core.py:

##################################
#avt-specific functions from avt.h
##################################
_dll.dc1394_avt_get_timebase.argtypes = [ POINTER(camera_t),
POINTER(c_uint32) ]
_dll.dc1394_avt_get_timebase.restype = error_t
_dll.dc1394_avt_get_timebase.errcheck = _errcheck

_dll.dc1394_avt_set_timebase.argtypes = [ POINTER(camera_t),
c_uint32 ]
_dll.dc1394_avt_set_timebase.restype = error_t
_dll.dc1394_avt_set_timebase.errcheck = _errcheck

SirVer schrieb:

Tomio

unread,
Aug 4, 2010, 10:17:43 AM8/4/10
to pydc1394
What about puting this into an extra file _dc1394avt.py and add an
extra features class which can be called in if the camera vendor is
avt? This would make the system modular, so the other extra features
can be added in a similar way.

And it would keep the core lib cleaner; there are some tedious lookind
definitions in those extra .h files 8).

Malte

unread,
Aug 4, 2010, 10:33:50 AM8/4/10
to pydc1394
On 4 Aug., 16:17, Tomio <tomio2...@googlemail.com> wrote:
> What about puting this into an extra file _dc1394avt.py and add an
> extra features class which can be called in if the camera vendor is
> avt? This would make the system modular, so the other extra features
> can be added in a similar way.

Hi,

I agree, keeping the vendor specific stuff in a separate files and
extra feature classes would be much better, but with my coding skills,
it would take ages to implement bugfree. So if anyone would feel up to
it...
(Until then I will just add my few lines to every new revision of the
code. :) )

Malte
Reply all
Reply to author
Forward
0 new messages