Coder Social home page Coder Social logo

Comments (11)

Yawgmoth90 avatar Yawgmoth90 commented on June 16, 2024 1

Yeah! I already tried inserting sleeps up to 10 seconds, with no success.

from python-gphoto2.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024 1

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.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024

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.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024

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.

Yawgmoth90 avatar Yawgmoth90 commented on June 16, 2024

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.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024

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.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024

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.

Yawgmoth90 avatar Yawgmoth90 commented on June 16, 2024

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.

Yawgmoth90 avatar Yawgmoth90 commented on June 16, 2024

Great, thanks for the explanation! I am closing the issue here at this point :)

from python-gphoto2.

maxholgasson avatar maxholgasson commented on June 16, 2024

Great, thanks for the explanation! I am closing the issue here at this point :)

Hey, would you share your working code?

from python-gphoto2.

jim-easterbrook avatar jim-easterbrook commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.