Comments (11)
Yeah! I already tried inserting sleeps up to 10 seconds, with no success.
from python-gphoto2.
Eureka! ("I have found it!")
A bit of Googling found a message to the gphoto2-devel mailing list that describes a very similar problem. See https://sourceforge.net/p/gphoto/mailman/message/11167963/
An extract: "The list of files in the camera folder never updates. Or rather, it updates once after the first image capture because the folder is initialized with flag files_dirty=1, triggering an update in function gp_filesystem_number (libgphoto2/gphoto2-filesys.c). The update sets files_dirty=0 and then the file list never updates again, causing failure because the next image can't be found."
This would cause exactly your problem - and reinitialising the camera no doubt fetches the updated list.
from python-gphoto2.
Are you allowing enough time for the camera to save the JPEG file? Try adding a few seconds sleep to your loop. (If it solves the problem you can then reduce the sleep time.)
from python-gphoto2.
In that case I don't know what to suggest. (I don't think it matters, but I wonder if it would make any difference if you created a context and passed it to each function? I don't understand what "context" is for and why it's optional.)
I can't believe this is specifically a python-gphoto2 problem. It might be interesting to try writing an equivalent C program, using libgphoto2 directly, and see how its behaviour differs.
PS I'm about to go out for the evening, so I won't be able to respond immediately.
from python-gphoto2.
Passing the context didn't help, nor did using another pc with Arch and libgphoto2.5.16. I agree it's probably a libgphoto problem, so I'll just stick with the camera.exit() workaround.
Thank you for the answers!
from python-gphoto2.
Does it work OK if you transfer the CR2 file instead of the JPG? My Canon 100D embeds JPGs (full resolution but coarser quantisation) in the CR2 file - I don't know if your 6D does the same and if you could use them instead.
from python-gphoto2.
One more thought. As it works if you re-initialise the camera that suggests something needs to be freed or released between captures. The Python gphoto2 objects only release their C counterparts when the Python object is deleted or reassigned. You could try adding a couple of del
statements to your loop as follows:
import gphoto2 as gp
import os
camera = gp.Camera()
camera.init()
for i in range(2):
file_path = camera.capture(gp.GP_CAPTURE_IMAGE)
file_path_jpg = file_path.name.replace("CR2", "JPG")
camera_file = camera.file_get(file_path.folder, file_path_jpg, gp.GP_FILE_TYPE_NORMAL)
del file_path
target = os.path.join("/tmp", file_path_jpg)
camera_file.save(target)
del camera_file
camera.exit()
from python-gphoto2.
Got the same result even when deleting the Python objects. Unfortunately I can't just copy the CR2 and get the full-res JPG because I need to minimize the delay between shots (that includes computing the histogram). Hence the best option would be to shoot raw+small jpg(720x480), then copy the jpg to the RPi and use it for the histogram.
from python-gphoto2.
Great, thanks for the explanation! I am closing the issue here at this point :)
from python-gphoto2.
Great, thanks for the explanation! I am closing the issue here at this point :)
Hey, would you share your working code?
from python-gphoto2.
I don't know if anyone has this working yet. That will depend on the bug in libgphoto2 being fixed.
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.