Open wferi opened 4 years ago
I'd gladly experiment with some changes given a little guidance about which parts of the code I should touch. Could somebody please link to a patch implementing a similar model-specific tweak for example? Thanks.
The exit -> init cycle should not be necessary. Also various people capture repeatedly images with Sony cameras...
does
gphoto2 --capture-image-and-download -F 5 -I 3
work better, e.g. capture 5 images?
Yes, that command captures 5 images all right.
libusb_bulk_transfer reporting PTP No Device could mean the sony is crashing and you seem to describe this behaviour.
What is weird that gphoto2 itself does not crash when doing the same thing.
can you insert a gp_camera_wait_for_event call in your code? like in .e.g. sample-tether.c
CameraEventType evttype;
void *evtdata;
retval = gp_camera_wait_for_event (camera, 1000, &evttype, &evtdata, context);
if (retval != GP_OK)
break;
(this would wait at most 1 second)
Inserting a gp_camera_wait_for_event()
call between the two capture_to_file()
calls helps! Here is the timestamped condensed output:
$ stdbuf -oL ./sample-capture | ts -s %.S
00.000019 Camera init. Takes about 10 seconds.
00.077421 The supplied vendor or product id (0x0,0x0) is not valid.
00.119391 Capturing.
01.280457 Reading PTP event failed: Timeout reading from or writing to the port (-10)
[221 similar lines suppressed]
02.286139 Reading PTP event failed: Timeout reading from or writing to the port (-10)
02.748454 Retval: 0
02.748575 Pathname on the camera: //capt0000.jpg
02.748608 Retval: 0
02.753854 Retval: 0
02.754143 Deleting.
02.754230 Retval: 0
02.772695 Capturing.
04.066512 Reading PTP event failed: Timeout reading from or writing to the port (-10)
[228 similar lines suppressed]
05.017670 Reading PTP event failed: Timeout reading from or writing to the port (-10)
05.516857 Retval: 0
05.517091 Pathname on the camera: //capt0001.jpg
05.517182 Retval: 0
05.523909 Retval: 0
05.524146 Deleting.
05.524238 Retval: 0
Thanks for looking into this!
And the returned evttype
is 4, that is, GP_EVENT_CAPTURE_COMPLETE
.
In other words, the following patch fixes sample-capture
for me:
diff --git i/examples/sample-capture.c w/examples/sample-capture.c
index 17d9ec6ec..df03a1baf 100644
--- i/examples/sample-capture.c
+++ w/examples/sample-capture.c
@@ -100,6 +100,8 @@ main(int argc, char **argv) {
FILE *f;
char *data;
unsigned long size;
+ CameraEventType evttype;
+ void *evtdata;
gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
gp_camera_new(&camera);
@@ -116,6 +118,10 @@ main(int argc, char **argv) {
exit (1);
}
capture_to_file(camera, context, "foo.jpg");
+ retval = gp_camera_wait_for_event (camera, 1000, &evttype, &evtdata, context);
+ if (retval != GP_OK)
+ return 1;
+ printf("Event type: %d (GP_EVENT_CAPTURE_COMPLETE is %d)\n", evttype, GP_EVENT_CAPTURE_COMPLETE);
capture_to_memory(camera, context, (const char**)&data, &size);
Hi, After applying the
patch
sample-capture
works fine when built and invoked as:However, if I apply the
patch instead and compile as above I get:
That is,
sample-capture
takes a picture and saves it, then the camera appears to switch off and reinitialize itself (just like with the stocksample-capture
). The camera can't really do anything after this until it's manually power-cycled, though. However, with thepatch the
./sample-capture
command successfully captures twice and can even be repeated.Did I try to use the API wrong? Exactly when is the exit/init pair necessary? Any idea what else could be wrong? If the previous approach should work, what would help diagnosing the issue? Since tag v2.5.24 commit 25c7db3b seems somewhat related, but in the opposite direction... Thanks, Feri.