Comments (12)
The Python version of gp_camera_wait_for_event returns event type and event data as in your line type, data = camera.wait_for_event(1000, context)
, hence it only takes the two arguments timeout and context. (I've attempted to explain this in the README: https://github.com/jim-easterbrook/python-gphoto2#c-interface)
Returning instantly with loads of PTP Property d105 changed
style messages is normal. Once you've received all of those you'll start getting actual events.
PS Don't try and use ctypes
stuff with python-gphoto2. It uses real Python types for everything.
from python-gphoto2.
Thanks for answer. The question is, that "type" is always 0.
from python-gphoto2.
If you want to try and decipher the camera.i file you also need to look at the %typemap
stuff - it's where SWIG is really powerful. I use typemaps to tell SWIG that CameraEventType * eventtype, void ** eventdata
in function arguments don't take them as inputs but apend them to the return value.
https://github.com/jim-easterbrook/python-gphoto2/blob/master/src/gphoto2/camera.i#L253
from python-gphoto2.
"type" is an enum - SWIG provides no means to translate back from the integer value to a meaningful name. 0 is GP_EVENT_UNKNOWN.
http://www.gphoto.org/doc/api/gphoto2-camera_8h.html#a438ab2ac60ad5d5ced30e4201476800b
from python-gphoto2.
Thanks a lot again. But why can it be always UNKNOWN? Wrong library path, version mismatch, etc?
from python-gphoto2.
"PTP Property d105 changed" doesn't fit any of the other types and isn't handled. gp_camera_wait_for_event is (currently) only looking for timeout, file added, folder added, and capture complete events. Anything else is unknown and unhandled.
from python-gphoto2.
Yes, this is all the log, I get, when pressing shutter:
gp_camera_wait_for_event: 0 PTP Property d105 changed
gp_camera_wait_for_event: 0 PTP Property d108 changed
gp_camera_wait_for_event: 0 PTP Property d106 changed
gp_camera_wait_for_event: 0 PTP Property d107 changed
gp_camera_wait_for_event: 0 PTP Property d109 changed
gp_camera_wait_for_event: 0 PTP Property d10a changed
gp_camera_wait_for_event: 0 PTP Property d10b changed
gp_camera_wait_for_event: 0 PTP Property d10c changed
gp_camera_wait_for_event: 0 PTP Property d10d changed
gp_camera_wait_for_event: 0 PTP Property d10e changed
gp_camera_wait_for_event: 0 PTP Property d10f changed
gp_camera_wait_for_event: 0 PTP Property d11b changed
gp_camera_wait_for_event: 0 PTP Property d114 changed
gp_camera_wait_for_event: 0 PTP Property d116 changed
This is a log, I get from sample-tether.c:
Unknown event: PTP Property d1c3 changed.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d1d3 changed.
Unknown event: PTP Property d1c0 changed.
Unknown event: Button 2.
Unknown event: PTP Property d102 changed.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d103 changed.
Unknown event: OLCInfo event mask=10f.
Unknown event: PTP Property d1c0 changed.
Unknown event: PTP Property d1d3 changed.
Unknown event: OLCInfo event 0x0800 content 1b4f604ab8ffe7ff.
Unknown event: OLCInfo event mask=900.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d101 changed.
Unknown event: OLCInfo event mask=4.
Unknown event: PTP Property d1c3 changed.
Unknown event: Button 4.
Unknown event: OLCInfo event mask=1.
Unknown event: Camera Status 1.
Unknown event: PTP Property d11b changed.
Unknown event: OLCInfo event 0x0010 content 04029b2e.
Unknown event: OLCInfo event mask=10.
Unknown event: PTP Property d1d3 changed.
Unknown event: PTP Property d1c3 changed.
Unknown event: Button 2.
Unknown event: OLCInfo event 0x0800 content 0000000000000000.
Unknown event: OLCInfo event mask=801.
Unknown event: PTP Property d1c3 changed.
Unknown event: Button 3.
Unknown event: OLCInfo event mask=1.
Unknown event: PTP Property d1c0 changed.
Unknown event: OLCInfo event mask=100.
Unknown event: PTP Property d1d3 changed.
Unknown event: PTP Property d1c0 changed.
Unknown event: OLCInfo event mask=100.
File added on the camera: //capt0000.jpg
Downloading capt0000.jpg...
Deleting capt0000.jpg on camera...
Unknown event: PTP Property d103 changed.
Unknown event: OLCInfo event mask=8.
Capture Complete.
Unknown event: OLCInfo event 0x0010 content 04019b2e.
Unknown event: OLCInfo event mask=10.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d101 changed.
Unknown event: OLCInfo event mask=4.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d101 changed.
Unknown event: PTP Property d103 changed.
Unknown event: OLCInfo event mask=c.
Unknown event: PTP Property d1c3 changed.
Unknown event: PTP Property d101 changed.
Unknown event: Button 1.
Definitely more, but why?
from python-gphoto2.
You appear to have only got as far as "gp_camera_wait_for_event: 0 PTP Property d116 changed". I'd expect more events to follow.
from python-gphoto2.
I've added a simple event logging example in commit c0a3847.
from python-gphoto2.
I checked again, it works.
Because of time.sleep in cycle, I missed a lot of calls, stupid error.
PS: I also checked direct ctypes approach, also works ;)
Maybe will be useful for somebody:
# ./ctypesgen.py -llibgphoto2.so -L/usr/local/lib /usr/include/gphoto2/gphoto2.h /usr/include/gphoto2/gphoto2-context.h /usr/include/gphoto2/gphoto2-camera.h -o gphoto.py
import gphoto as gp2
camera = gp2.POINTER(gp2.Camera)()
ret = gp2.gp_camera_new(gp2.byref(camera))
context = gp2.gp_context_new()
ret = gp2.gp_camera_init(camera, context)
print "gp_camera_init", ret
text = gp2.CameraText()
ret = gp2.gp_camera_get_summary(camera, gp2.pointer(text), context)
print "gp_camera_get_summary", ret, text.text
try:
while True:
evttype = gp2.c_int(0)
evtdata = gp2.POINTER(None)()
# evtdata = gp2.c_void_p()
ret = gp2.gp_camera_wait_for_event(camera, 1000, gp2.pointer(evttype), gp2.byref(evtdata), context)
print "gp_camera_wait_for_event", ret, evttype
# time.sleep(0.5)
except KeyboardInterrupt:
pass
ret = gp2.gp_camera_exit(camera, context)
ret = gp2.gp_camera_free(camera)
from python-gphoto2.
Giving the ctypesgen module the same name as the Python-gphoto2 package is going to cause some confusion!
from python-gphoto2.
Agree, changed.
from python-gphoto2.
Related Issues (20)
- Missing pre-req's(?) after building libgphoto2 from source on Raspberry Pi HOT 3
- Can not set datetime on Canon EOS 1200D HOT 4
- equivalent of gphoto2 --reset HOT 1
- delete a file HOT 2
- gp_camera_get_single_config HOT 2
- Socket error after gp_camera_exit in windows/msys2 HOT 15
- Faster way to copy files from camera HOT 7
- Sony FX3 overshoot HOT 1
- `delete_file()` does not delete file HOT 9
- Segmentation Fault segfault on gp.Camera.autodetect() on Github Actions Runner HOT 21
- LGPL vs. GPL license? HOT 8
- Test Virtual Camera HOT 4
- Missing bindings for gp_port_new, gp_port_open, and gp_port_reset? HOT 2
- capture_preview() broken in v2.5.0 HOT 4
- having trouble getting gphoto2 on rpi HOT 3
- use python-gphoto2 in Windows system HOT 1
- Always connected capture anytime HOT 1
- Github Actions Python 3.12 environment. HOT 1
- Is live data acquisition available in the library? HOT 1
- Error When Installing with "Local" libgphoto2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-gphoto2.