jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
362 stars 59 forks source link

Trouble with Nikon D700 #21

Closed Elmout33 closed 7 years ago

Elmout33 commented 8 years ago

Hi, I try to make a simple code but it's not working for now ...

My code is this : context = gp.Context() camera = gp.Camera() camera.init(context) camera_file = gp.check_result(gp.gp_camera_capture_preview(camera, context)) file_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))

display image

data = memoryview(file_data) print(type(data), len(data)) print(data[:10].tolist()) image = Image.open(io.BytesIO(file_data)) image.show() gp.check_result(gp.gp_camera_exit(camera, context)) context2 = gp.Context() camera2 = gp.Camera() camera2.init(context2) print('Capturing preview image 2') camera_file2 = gp.gp_camera_capture_preview(camera2, context2) file_data2 = gp.gp_file_get_data_and_size(camera_file2[1])

display image

data2 = memoryview(file_data2[1]) print(type(data2), len(data2)) print(data2[:10].tolist())

image2 = Image.open(io.BytesIO(file_data2[1]))

image2.show()

gp.gp_camera_exit(camera2, context2) return 0

But only 1 capture was made and I have the following error : WARNING: gphoto2: (gp_port_usb_close [libusb.c:321]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE. Checking camera config Capturing preview image WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c8 receiving resp failed: PTP Device Busy (0x2019) <type 'memoryview'> 15147 [255, 216, 255, 219, 0, 132, 0, 4, 6, 6] WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x90c2 receiving resp failed: Change Camera Mode Failed (0xa003) WARNING: gphoto2: (gp_port_usb_close [libusb.c:321]) Invalid parameters: 'port && port->pl->dh' is NULL/FALSE. Capturing preview image 2 WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9201 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9203 receiving resp failed: Not in Liveview (0xa00b) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9201 receiving resp failed: PTP Device Busy (0x2019) WARNING: gphoto2: (ptp_usb_getresp [usb.c:438]) PTP_OC 0x9203 receiving resp failed: Not in Liveview (0xa00b)

What I am doing wrong ? Can you help me ?

Thank you !

jim-easterbrook commented 8 years ago

I think this is a problem with libgphoto2 itself, rather than the Python interface, so you might get more help from the gphoto2 user mailing list. I did a quick web search and found this (http://gphoto-software.10949.n7.nabble.com/Switching-back-to-ive-view-mode-after-image-capture-RTIAcquire-td15391.html) which sounds similar to your problem.

Have you tried it without exiting the first camera & context, i.e. carry on using the same camera and context for the second capture? Alternatively, have you tried deleting the first camera and context objects as soon as they are finished with?

Elmout33 commented 8 years ago

The link you gave don't give the answer ... just a similar problem :(

And yes I try to make with one "camera" and one "context" but I have the same problem ...

What's "deleting" ? I used the gp_camera_exit function wich is made for, not ?

jim-easterbrook commented 8 years ago

The lack of an answer is why I don't have an answer.

gp_camera_exit releases the camera (only one program can control a camera at any one time) but the camera and context objects (and the C structs they are proxies of) still exist. The Python del statement can be used to delete them, freeing up any resources they are holding on to. https://docs.python.org/2.7/tutorial/datastructures.html#the-del-statement

Elmout33 commented 8 years ago

I found a solution on the net : make a Time.sleep(0,05) and its good !!

But when i try to make a real capture the focus is not make ....

And idea ?

Thank you !

Le samedi 20 août 2016, Jim Easterbrook notifications@github.com a écrit :

The lack of an answer is why I don't have an answer.

gp_camera_exit releases the camera (only one program can control a camera at any one time) but the camera and context objects (and the C structs they are proxies of) still exist. The Python del statement can be used to delete them, freeing up any resources they are holding on to. https://docs.python.org/2.7/tutorial/datastructures.html#the-del-statement

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jim-easterbrook/python-gphoto2/issues/21#issuecomment-241203495, or mute the thread https://github.com/notifications/unsubscribe-auth/AEJay_HExcIhSBA0vto7LGdfIBAecmcPks5qhxC7gaJpZM4JpEsA .

Cordialement, Sylvain Lerouge

jim-easterbrook commented 8 years ago

I've not done any capturing with my Canon cameras, and have no experience with Nikon. Have you tried doing what you want with the gphoto2 command line tool? If that works then you'll know it's possible and you just have to find the magic combination of libgphoto2 calls that's needed.