Comments (8)
Do you get the same behaviour with a C program? I'm not aware of anything in the Python interface that would add a delay, so your problem may be with libgphoto2 itself.
I don't think the image is being downloaded during your 1.2 second delay, I think the camera is busy saving it to its SD card (and so not responding to USB). If you don't need to store the image on the SD card you could try capturing to memory instead. (It might also be worth trying a faster SD card.)
PS. Rather than using a loop with a short timeout I'd prefer to use a separate thread to wait for the camera to have an image. I do this with any sort of blocking operation in an interactive program.
from python-gphoto2.
I'm also using a Canon EOS 600D and seeing unexpected behaviour trying to use gp_camera_wait_for_event.
It seems to just return right away. i.e. it never waits!
Python 3.4.5 (default, Feb 21 2017, 16:14:02)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gphoto2 as gp
>>> context = gp.Context()
>>> camera = gp.Camera()
>>> camera.wait_for_event(1000,context)
[0, None]
>>> gp.gp_camera_wait_for_event(camera,1000,context)
[0, 0, None]
>>> gp.version.gp_library_version(1)
['2.5.14', 'all camlibs', 'gcc (C compiler used)', 'ltdl (for portable loading of camlibs)', 'EXIF (for special handling of EXIF files)']
Any pointers?
from python-gphoto2.
How soon is "right away"? You're specifying a timeout of only 1 second.
from python-gphoto2.
much less than 1sec. fwiw specifying much longer makes no difference.
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gphoto2 as gp, time
>>> context = gp.Context()
>>> camera = gp.Camera()
>>> start = time.time()
>>> camera.wait_for_event(10000,context)
[0, None]
>>> time.time() - start
0.2146010398864746
subsequent calls return much quicker - assume the first call has to do a bit more work initiinlaising the "connection"
>>> start = time.time()
>>> camera.wait_for_event(10000,context)
[0, None]
>>> time.time() - start
0.014323234558105469
from python-gphoto2.
I don't know then. The return value of 0 is GP_EVENT_UNKNOWN
- the documentation says "unknown and unhandled event. argument is a char* or NULL" so maybe there's a string there that the Python interface is currently ignoring.
It would appear that you need to poll camera.wait_for_event in a loop until you get an event of interest. It might be worth asking for clarification on the libgphoto mailing list though.
from python-gphoto2.
ok thanks, I remember finding that 0 meant gp.GP_EVENT_UNKNOWN come to think of it and wondered similar..
from python-gphoto2.
>>> while True:
... foo = camera.wait_for_event(10000,context)
... if foo[0] != 0:
... print(foo)
... break
...
[2, <Swig Object of type 'CameraFilePath *' at 0x767ac7c0>]
:)
from python-gphoto2.
I've just added code to handle any string when GP_EVENT_UNKNOWN
is returned. Trying it on my EOS 100D I get the following
Type "help", "copyright", "credits" or "license" for more information.
>>> import gphoto2 as gp
>>> ctx = gp.Context()
>>> cam = gp.Camera()
>>> cam.init(ctx)
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d105 changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d108 changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d106 changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d107 changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d109 changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d10a changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d10b changed']
>>> cam.wait_for_event(1000, ctx)
[0, 'PTP Property d10c changed']
>>>
I suspect I might run out of such events eventually.
[Edit - yes, I did. After which it was blocking as it should.]
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.