Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Focus #24

Open
thiagohersan opened this issue Oct 10, 2014 · 8 comments
Open

Auto Focus #24

thiagohersan opened this issue Oct 10, 2014 · 8 comments

Comments

@thiagohersan
Copy link

Not an issue, but I added some logic to your magic to make the camera try to focus before taking a picture (the equivalent of pressing the shutter button down halfway).

You can see the diff here.

If this is something you might want in the addon we can negotiate a PR (what I mean is: I might need to clean up the code, or make it more understandable, or merge my takePhotoAF() function into takePhoto() : )

Let me know.

@kylemcdonald
Copy link
Owner

cool! but when the camera is in autofocus mode, doesn't it do this every time you take a picture anyway?

is this so that you have control on every shot for whether to autofocus or not?

@thiagohersan
Copy link
Author

Yes ! It's so you have control !

Right now if the camera is in AF mode and focus fails, you don't get a picture ...

This allows you to take pictures without trying to focus, or to take the picture despite AF failing.

Maybe it can be a flag on the takePicture function... and I'm not sure if it makes sense to expose whether focus failed or not...

@kylemcdonald
Copy link
Owner

great :)

  1. i'm interested in adding this
  2. it definitely needs to be a flag, let's call it attemptAutoFocus
  3. being able to know when AF failed is good, but not essential
  4. if focusFailed() and focusFrame() are not meant to be public they should be private or protected

if you can do these things i'd be happy to merge your work!

@ofZach
Copy link

ofZach commented Mar 24, 2015

@thiagohersan I'm not sure if the logic for focus is right -- I think it's better to look at justFocus != 0... also, I've found that to keep my camera out of an infinite focusing loop I basically either do:

a) justFocus != 0
send the shutter off command, focus = OK, needToCheck = false

b) justFocus == 0
focusFailed()

this keeps me from stalling out, some of the other logic about 17/16 etc I think is based on the fact that justFocus seems to give back the number of focus frames or some other info, but if you look at the docs, it looks like it should be interpreted more simply

  justFocus -- In focus: 1 Out of focus: 0

I'm still not super sure how to read this kEdsPropID_FocusInfo struct (the documentation is super thin), but at any rate, thought I should flag that for me, != 0 is a pretty good check and keeps me from getting stuck in a weird state, where I continually re-focus.

(I'm working on this because without auto focus, I get stuck taking continually a picture when the focus is not good)

thanks!

@thiagohersan
Copy link
Author

Hi @ofZach .

I think you're right regarding the numbers for justFocus. I remember that depending on the condition and state of the camera I would get very different numbers, and the SDK doc was not very helpful. So, that makes sense.

What I needed was something that would try to focus, if it succeed, then take many pictures, if it didn't successfully focus, then just take one picture and try the whole thing again at a later time.

My code might be a bit specific to that situation, and I meant to clean it up and make more generic functions to enable taking pictures without trying to focus, or to take the picture despite AF failing.... but.... my camera got stolen and I haven't replaced it.

@ofZach
Copy link

ofZach commented Mar 24, 2015

oh sorry to hear that! I've found your code very helpful -- especially the take photo without focus (since the way the logic works with my camera, I'd get stuck in a pretty painful loop trying to take a picture when it can't focus). I will try to poke around more and see what I can find out about the API for focusing...

@plural
Copy link

plural commented Oct 2, 2015

I have been playing with this addon tonight and i think the fix for failed autofocus is much simpler than @thiagohersan's proposed patch. In the if(needToTakePhoto) { try { section, you can replace TakePicture with 2 kEdsCameraCommand_PressShutterButton calls. If the AF fails, the exposure won't even be attempted and for good measure you can depress the shutter in the catch.

I can try to get a patch out shortly for this.

@ofZach
Copy link

ofZach commented Dec 4, 2015

@plural I'd be interested in seeing this patch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants