EDSDK freezes on exit?

So after trying pretty much all the different Canon SDK wrappers, I finally got EDSDK to do what I needed to do. Basically it’s a little app that shows a preview through the camera lens and then takes photos.

My problem is that when I try to hit escape to exit the program, it hangs / freezes. I think this is because it’s waiting for the camera object to finish up, but it never finishes. Wouldn’t be a huge problem except that this is for a permanent installation and I don’t want people to have to force quit it every time they want to restart.

I can get around this by calling _Exit but I’ve heard that referred to as “the nuclear option” and want to make sure I’m not doing anything bad, preventing it from freeing memory permanently or something.

Which wrapper are you using btw? I tried several of those out there but without much success.

are you using ofxEdsdk? I’ve had luck with two things:

a) changing the waitForThread to this:

 Camera::~Camera() {
	waitForThread(true, 1000);

from

	waitForThread();

b) using some of the focus work in another branch of ofxEdsdk:

specifically, in my case, my camera would sometimes lock when it coudln’t focus and you try to get it to take a photo. There’s a not very useful error handling in the current ofxEdsdk thread model so things get a little wonky when a camera can’t do what you want and you keep asking it to (you try to take a picture, it try to focus and can’t, and you keep asking it to take the picture without backing off or canceling the request). In my case, I just attempt to focus and take a photo without focusing as a two step operation and it works every time, and seems snappier as well:

    camera.focusFrame();
    ofSleepMillis(50);
    camera.takePhotoNonAF();

where do i find waitForThread?

i’m using ofxEdsdk…

found the line
Camera();
~Camera();
in ofxEdsdk.h
but no waitForThread(true, 1000)

it’s this line that needs to be changed:

Hi,

I had the same issue.
Documented here
https://github.com/kylemcdonald/ofxEdsdk/issues/30

I’ve used the same trick as Zach.

Unfortunatly this trick only works if you never call the update() function.
Unless it freeze on exit…

I don’t have the use of liveView or the need of the update function in my project so I have stopped investigating…

On Windows I’m using CannonCameraWrapper and on Mac I’m using EDSDK. I can probably help you get stuff set up if you have specific questions, or I could post some snippets up here.

Are you using ofxEdsdk or straight canon EDSDK?

I used to use ofxEdsdk until recently but now I cannot make it work properly. Instead I started using canon EDSDK obj-C example straight away to do what I need to.

Of all wrapper I tried (both on Mac or Windows), I couldn’t get to have both the picture taken and the live view in the same app…which is what i need.

Hmm, that’s what my app is doing. Yeah I’m using ofxEDSDK. I did discover that a memory card needs to be in the camera for it to work

Yeah I realised it needs a memory card as well.

The problem I have recently happen when I have the live view from the camera and then I take a picture. After that the addon hang and cannot do anything else. Tried to understand where the problem is coming from but got very confused quickly with the Canon SDK.

Which SDK and addon version/branch are you using? Tried lots of different one but couldn’t “solve” my problem.

I had this problem with freezing. For me it happened because the picture taking fails (ie, with a NG for autofocus) and then the code keeps trying to take a picture because of how the thread / logic is. I solved my problem by using autofocus work from thiago but modifying it slightly:

(I changed the logic in these lines to what is and isn’t a good focus attempt):

in my code, when i got to take a picture I attempt to focus (it’s the same as pressing the button half way), wait a bit, then snap with no focus (so the picture event never fails).

IMO the ofxEdSdk needs a more general failure technique, so that if a command fails, it doesn’t continually send the command. That’s what’s causing the freeze, at least for me…

Hell zach,

I tried so many things, I am not sure I tried this autofocus trick. I will have it a go and let you know.

Hello Zach,

So I tried from your repository but I still have the same problem.
Actually the picture is taken correctly and downloaded as expected. But then the addon seems to stop responding and the image displayed is completely frozen. From there if I try to take another picture , I get as message:

[verbose] camera state event kEdsStateEvent_CaptureError: 44313
[ error ] Error while taking a picture: [unrecognized EdsError] inside SendCommand()
[verbose] camera state event kEdsStateEvent_CaptureError: 36097
[ error ] Error while taking a picture: EDS_ERR_TAKE_PICTURE_AF_NG inside SendCommand()
[ error ] There was an error closing the live view stream: EDS_ERR_DEVICE_BUSY inside SetPropertyData()

Sounds to me that my problem is different than yours.

I was also seeing this error “EDS_ERR_TAKE_PICTURE_AF_NG” – when I took a picture without focus this went away:

my code was something similar to:

            camera->focusFrame();
            ofSleepMillis(100);
            camera->takePhotoNonAF();

Ok, thanks for this. I tried what you proposed. But result is the same: view is frozen.

This time I get the following if I try to take another picture:

focusing
[verbose] camera state event kEdsStateEvent_ShutDownTimerUpdate: 0
[ error ] Error while completely pressing shutter button: EDS_ERR_DEVICE_BUSY inside SendCommand()
16
1
[verbose] camera state event kEdsStateEvent_ShutDownTimerUpdate: 0
[verbose] camera state event kEdsStateEvent_ShutDownTimerUpdate: 0

I also tried without focusing at all before taking the picture but result is the same.