vendredi 10 février 2017

Python get specific SWIG information

Vote count: 0

So I'm using gphoto2 library for Python 2.7 to get the information from my camera. The example script shows:

import gphoto2 as gp

try:
    context = gp.gp_context_new()
    if hasattr(gp, 'gp_camera_autodetect'):
        cameras = gp.check_result(gp.gp_camera_autodetect(context))
        for name, value in cameras:
            print('camera number', n)
            print(name)
            print(value)

And this will print out the inforamtion. What I'm trying to do is get the information from the cameras variable.

What I'm trying to do is get the information from the first camera. printing it will give me very little to work with:

print cameras
>>> <Swig Object of type 'CameraList *' at 0x768d40a0>

I have thought about printing it differently:

print cameras[1].name
>>> IndexError: CameraList index out of range

I'm not sure how to handle this... I've only just read about SWIG but am still trying to get the gist of it. Any help would be grately appreciated.

asked 41 secs ago

Let's block ads! (Why?)



Python get specific SWIG information

Aucun commentaire:

Enregistrer un commentaire