Author Topic: Movie autofocus experiments  (Read 33444 times)

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Movie autofocus experiments
« on: July 17, 2012, 03:53:50 AM »
I guess , this function's position like "50D video shooting". Basically we can't use MovieAF in our old cameras.But this function will provide capability for it. So more supporter will participate to this project.

Anyway, I'm interested in this function, and now I'm acquire and tuning the codes. AF moving is more faster than original. Still not perfect  but working. and It's a extremely noisy and battery eater (lol
But it is not converge to AF point. So this function need to apply more good formula for calculating focus distance from live view buffer. Or need a converge code.

Does any other developer existing who is interested in this function  ?

I can coding by C , but I'm not expert for analyzing graphic.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Movie autofocus experiments
« Reply #1 on: July 17, 2012, 05:40:09 PM »
Post what you find. I like more functions even if people don't use them. I'm bad at C but seems I'm good at digging stuff up.

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Movie autofocus experiments
« Reply #2 on: July 17, 2012, 06:10:54 PM »
I agree, just post what you find. Someone may find it useful
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Movie autofocus experiments
« Reply #3 on: July 17, 2012, 06:13:54 PM »
The main problem here is: in what direction should the lens move? Contrast detection can't tell this.

Also, there's no absolute measure of focus peaking; that's why trap focus, magic zoom confirmation and so on are based on pure guesswork.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #4 on: July 17, 2012, 06:33:15 PM »
I need a lot of time for writing English(lol .
I got 2 reply during writing this document. First, I replay to Alex.

Alex, I also think so, when reading a code. But my sony NEX3 is sometime move the AF point to most far/near. But almost good for me. So I think it's not important thing.
For example, I'm sometime use a stabilizer and crane. I can't touch focus ring when the camera on these equipments. It's better than nothing.
And I understood that I need to guesswork on movie_af for searching focus peak.


1% and nanomaid my confusing points under follow:
----
I just reading the original code today.Now I need to understand all of original code.

1: Live view buffre is YUV422 . correct?
2: I don't know how to get contrast from YUV 422 buffer(Y is luma, but we can use this for contrast comparering?)
3: In focus.c , it's using buf
  • but not defined . where defined it. I guess it's a Live ViewBuffer.

    (buf
  • is defined anyware, so grep is not working for finding it.)


My understanding for contrast AF.
Most higher contrast = in focus
Is this a correct thing?

Basically, I'm usually writing a TCP/IP code . So I have no experience to write a graphic handling codes.I need more study for understanding graphic handling and algorithms.

P.S. already midnight in my country. Time difference is a little hard to collaborate with international community. Also I'm writting a Japanese FAQ on wiki side. Become a little slow for this activity..

P.S.2 Thank you for reading my poor English.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Movie autofocus experiments
« Reply #5 on: July 17, 2012, 06:42:02 PM »
@miyake-san:

If you can find a good heuristic, no problem.

1: Live view buffre is YUV422 . correct?
Yes.

2: I don't know how to get contrast from YUV 422 buffer(Y is luma, but we can use this for contrast comparering?)
Canon has a few focus metrics in PROP_LV_FOCUS_DATA (see focus.c:1058). You can use them as they are, you can combine them, or you can compute your own metrics. Ideally, some function with 0 = out of focus and 100 = perfect focus would be best (ML tries to approximate something like this, but not good enough).

3: In focus.c , it's using buf
Not sure what you mean; it's old code that was 550D-specific, focus method was changed since then to be portable among all cameras... not an easy job at all. I've tried at some point to make it work via ifdef, but after a day of fiddling with it I gave up.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #6 on: July 17, 2012, 06:57:24 PM »
Alex-san

hmm, I see.
It's long term project for me.
I need to read and understand focus.c and focus_peak function.

If I made a good code , I will post the diff file to this community.

Thanks.


vBlack

  • New to the forum
  • *
  • Posts: 3
Re: Movie autofocus experiments
« Reply #7 on: July 19, 2012, 01:12:59 PM »
As I have seen

here:
or here:
the old movie-AF worked IMHO quite well! (I don't think that the t4i-AF is much better)

So why don't you just re-add the AF that has been there!


regards vBalck

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #8 on: July 19, 2012, 04:34:55 PM »
I just understood old one is not unified.
So it's not a easy to fit current unified codes.

Currently, the code is not working with unified code.(hangup)
I just disable some lines now, then I can test few movie AF functions.

I guess YouTube video is most better case, and author hide a bad behavior.
Need more codes for stable operation, I think. So it's disabled now.

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Movie autofocus experiments
« Reply #9 on: July 19, 2012, 04:48:16 PM »
Keep in mind canon had to modify the 650D CMOS to use phase-detect AF. IIRC we are stuck with contrast-detect which works fine in static scenes (photos)
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Movie autofocus experiments
« Reply #10 on: July 19, 2012, 05:17:15 PM »
Hmm... it does look passable.

My main concern: What does AF and constant focusing do to our lenses. I don't think they were designed for this. Maybe for HSM its not so bad... but regular lenses?

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #11 on: July 19, 2012, 07:21:52 PM »
1%
I just testing my movie AF codes.
I'm using sigma 30mmF1.4 and 18-200mm. These are extremely noisy(lol
So basically speed is not so bad, but we can't use sound with movie AF without extra audio recorder or separated microphone.

I've lost my move af code yesterday by my miss operation.Now I recover and just adding few codes.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Movie autofocus experiments
« Reply #12 on: July 19, 2012, 07:27:04 PM »
When you make it, I'll try it. My non HSM lenses are very noisy but this was a given. I'm just scared for the AF motor :)

Who isn't going to use a boom or at least a shotgun mic (which should reject af noise mostly)?

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #13 on: July 19, 2012, 07:32:45 PM »
help me.
I'm finding to PROP_LV_FOCUS_DATA's meaning.
It has 8 integer blocks. Where describe it means.
Thanks

vBlack

  • New to the forum
  • *
  • Posts: 3
Re: Movie autofocus experiments
« Reply #14 on: July 19, 2012, 09:55:21 PM »
I just understood old one is not unified.
So it's not a easy to fit current unified codes.

Ok, sorry!
I am very new to ML!
I didnt know that there were so much changes!

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #15 on: July 19, 2012, 10:07:20 PM »
@vBlack
Never mind.
I am newbie too.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #16 on: July 20, 2012, 07:02:14 PM »
Today's experiment result
 
movie_af=1 : HOLD=>not working
movie_af=2 : Cont=>not working
movie_af=3 : CFPk=>working. but still not unstable(not stop when focus is almost good distance)

movie_af=1and 2 is got "Focus error". focus_done is not comming specified waiting time.
I guess, more dependency needed when we use LensFocus().

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12564
Re: Movie autofocus experiments
« Reply #17 on: July 20, 2012, 07:07:31 PM »
That's good progress.

Main difference is the task where focus commands are sent from. 1 and 2 are running in Canon's PropMgr task - their event notification and settings changing system. 3 is running from a ML user task and uses a custom metric for estimating focus (formula somewhat similar to focus peaking) - on 550D, that metric refreshes faster than Canon's, but it's less accurate. On 60D, Canon's focus info refreshes very quickly, so probably it's the same on 600D.

I suggest passing the focus requests from property handler to a user task in ML. You can use plain boolean variables (not elegant, but easy to understand and does the job), or you can use message queues (elegant, probably achieves more consistent timing, there is an example of such communication in menu.c - between button handler task and menu_redraw_task).

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #18 on: July 20, 2012, 07:19:09 PM »
Thanks
I almost understood what you are explaining.

I already knew 1st sentence when I read code and some web document.
2nd is very helpful for me.

my working is here
https://bitbucket.org/miyake_t/magic-lantern-miyake/overview

Anyway, already sleepy today.  Envy European and American peoples. We Japanese have a lot of time difference. orz...

ilguercio

  • Hero Member
  • *****
  • Posts: 845
Re: Movie autofocus experiments
« Reply #19 on: July 20, 2012, 07:40:54 PM »
Keep on going, more features are always a plus.
;)
Canon EOS 6D, 60D, 50D.
Sigma 70-200 EX OS HSM, Sigma 70-200 Apo EX HSM, Samyang 14 2.8, Samyang 35 1.4, Samyang 85 1.4.
Proud supporter of Magic Lantern.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #20 on: July 21, 2012, 08:15:12 AM »
msg_queue imported.
and a little bit step up.

movie_af=1 : HOLD=>working. focus unstable, had "Focus error" . * Crash free now!"
movie_af=2 : Cont =>same as =1
movie_af=3 : CFPk =>working. focus unstable

focusunstable = (not stop when focus is almost good distance)

I can't see crash screen when I select 1 and 2.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #21 on: July 22, 2012, 05:45:04 PM »
Today's experiment result

PROP_LV_FOCUS_DATA has 8 int value

buf[0] // has dynamic value but ?
buf[1] // has dynamic value but ?
buf[2] // higher dynamic value
buf[3] // lower  dynamic value
buf[4] // always same value on 600D
buf[5] //always zero
buf[6] //always zero
buf[7] //clocking? almost 0 but sometime had a value

buf[2] and buf[3] values are moving when we touch focus ring.
buf[2,3] is higher value when I got good focus.
So I added focus threshold value in menu. The thresh value from 10000-19000.
threshold evaluation code will do the "stop focus" action when the buf[2,3] is higher than specified value.

Then sometime AF is suspend when I got focused . But the buf[2,3]'s value is depend on the scene. It means a ISO, material, how far.  So I need one more function for calculating threshold dynamically.
 
P.S. Let me know how to say the situation which is "focus is perfect" in English.
I'm using "focused", is it correct?   Can I use "focus peek" for this?


MEMO
????????
miss the point
???????
out of focus
????????
defocused image
??????
????
defocus
???????
????
refocus
?????
be brought to a focus
come into focus????????????????
??????
in focus

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Movie autofocus experiments
« Reply #22 on: July 22, 2012, 07:25:43 PM »
Did you have pics, I think they didn't show up. I merged in the latest AF stuff I saw. Once it stops it will be good.

I tested today and it stops more often. Worked well for a little while.

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Movie autofocus experiments
« Reply #23 on: July 23, 2012, 01:17:45 PM »
Current movie AF status.

Focus stepping part is not optimized yet.
But a little bit good to suspend focus action when come into focus.
Sometime you can see STOP LED.

one focus action with one LED brink.

and current good parameter for me is:
noise 2
aggre 8
thresh 4

Michael Zöller

  • Administrator
  • Senior
  • *****
  • Posts: 304
  • 5D Mark II
Re: Movie autofocus experiments
« Reply #24 on: July 23, 2012, 01:30:26 PM »
miyake, thank you so much for investigating ML autofocus options!!  8) Good luck!!
neoluxx.de
EOS 5D Mark II | EOS 600D | EF 24-70mm f/2.8 | Tascam DR-40