Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: miyake on July 17, 2012, 03:53:50 AM

Title: Movie autofocus experiments
Post by: miyake 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.
Title: Re: Movie autofocus experiments
Post by: 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.
Title: Re: Movie autofocus experiments
Post by: nanomad on July 17, 2012, 06:10:54 PM
I agree, just post what you find. Someone may find it useful
Title: Re: Movie autofocus experiments
Post by: a1ex 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.
Title: Re: Movie autofocus experiments
Post by: miyake 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
Title: Re: Movie autofocus experiments
Post by: a1ex 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.
Title: Re: Movie autofocus experiments
Post by: miyake 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.

Title: Re: Movie autofocus experiments
Post by: vBlack on July 19, 2012, 01:12:59 PM
As I have seen

here: http://www.youtube.com/watch?v=7ROVTq4QGDM

or here: http://www.youtube.com/watch?v=pI2cCgdCFXc

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
Title: Re: Movie autofocus experiments
Post by: miyake 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.
Title: Re: Movie autofocus experiments
Post by: nanomad 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)
Title: Re: Movie autofocus experiments
Post by: 1% 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?
Title: Re: Movie autofocus experiments
Post by: miyake 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.
Title: Re: Movie autofocus experiments
Post by: 1% 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)?
Title: Re: Movie autofocus experiments
Post by: miyake 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
Title: Re: Movie autofocus experiments
Post by: vBlack on July 19, 2012, 09:55:21 PM
Quote from: miyake 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.

Ok, sorry!
I am very new to ML!
I didnt know that there were so much changes!
Title: Re: Movie autofocus experiments
Post by: miyake on July 19, 2012, 10:07:20 PM
@vBlack
Never mind.
I am newbie too.
Title: Re: Movie autofocus experiments
Post by: miyake 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().
Title: Re: Movie autofocus experiments
Post by: a1ex 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).
Title: Re: Movie autofocus experiments
Post by: miyake 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...
Title: Re: Movie autofocus experiments
Post by: ilguercio on July 20, 2012, 07:40:54 PM
Keep on going, more features are always a plus.
;)
Title: Re: Movie autofocus experiments
Post by: miyake 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.
Title: Re: Movie autofocus experiments
Post by: miyake 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
Title: Re: Movie autofocus experiments
Post by: 1% 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.
Title: Re: Movie autofocus experiments
Post by: miyake 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
Title: Re: Movie autofocus experiments
Post by: Michael Zöller on July 23, 2012, 01:30:26 PM
miyake, thank you so much for investigating ML autofocus options!!  8) Good luck!!
Title: Re: Movie autofocus experiments
Post by: Malcolm Debono on July 23, 2012, 01:43:27 PM
That test already looks pretty good. Good luck!
Title: Re: Movie autofocus experiments
Post by: miyake on July 23, 2012, 01:46:54 PM
Anyway, It's really hard to shoot live-view from another camera.
My arm had a limit to hold those two cameras.

Please tell me how to shoot live view from another camera with valiangle(lol
Title: Re: Movie autofocus experiments
Post by: a1ex on July 23, 2012, 01:57:39 PM
Maybe it's a good idea to just record a movie.

If you want the overlays, it is technically possible to burn them into the movie frame, though it's very hard to do so without flicker.
Title: Re: Movie autofocus experiments
Post by: miyake on July 23, 2012, 02:15:27 PM
If we can record overlays. we can easy to debug .Because  the value is too fast to showing.
Slomo will help to understand , relation of the debug value and real live view display such as focus, expo, and so on.
One more thing, If the problem is not reproduce our side, but we can see real problems from recorded files.
Title: Re: Movie autofocus experiments
Post by: Alia5 on July 23, 2012, 02:52:54 PM
Wow thats awesome!
Very great work!

For the two Cameras: Use a piece of metal and connect it to both Tripod-mounts ;)
Title: Re: Movie autofocus experiments
Post by: miyake on July 23, 2012, 04:00:44 PM
@Alice,

Screw is mm. not inch in my country. But the camera is inch....
So it's hard to find 1/4 inch screw and nat....

orz.. OTZ...
Title: Re: Movie autofocus experiments
Post by: 3pointedit on July 25, 2012, 10:00:04 AM
To shoot screen I bought a 7" magic arm and attached it to the flash bracket.  Then screwed in a my small camera to shoot the screen.
Title: Re: Movie autofocus experiments
Post by: miyake on July 25, 2012, 10:49:29 AM
OHhhhhhh! great idea. I already have it. But i didn't think it.
Thankyou!
Title: Re: Movie autofocus experiments
Post by: nanomad on July 25, 2012, 12:07:44 PM
You can also attach the camera to a HDMI TV and use that as long as you shoot indoor  ;)
Title: Re: Movie autofocus experiments
Post by: miyake on July 25, 2012, 01:30:52 PM
Oh NO....
My sony NEX3 is need 45cm(18inch).
my magic arm is only 6inch...  orz...

@nanomaid
I'm thinking it. But HDMI cable is a little bit expensive. It's only for showing status of this debugging.

Title: Re: Movie autofocus experiments
Post by: 3pointedit on July 25, 2012, 01:32:42 PM
 :P Oh too bad, doesnt the camera do macro?
Title: Re: Movie autofocus experiments
Post by: Alia5 on July 25, 2012, 04:12:43 PM
Quote from: miyake on July 25, 2012, 01:30:52 PM

@nanomaid
I'm thinking it. But HDMI cable is a little bit expensive. It's only for showing status of this debugging.

but you could also use the cinch cable (yellow red white) included with the 600D ;)
Title: Re: Movie autofocus experiments
Post by: miyake on July 25, 2012, 04:27:50 PM
Quote from: 3pointedit on July 25, 2012, 01:32:42 PM
:P Oh too bad, doesnt the camera do macro?

I have only standard lens.  But Alia5 is good information to me!!

@Alia5
Thanks !!!!  I just forget the analog cable!
First, I need to find 600D paper box.

Oh,,, But how can I record SD video?(lol


It's like mebius.
Title: Re: Movie autofocus experiments
Post by: miyake on July 25, 2012, 04:30:41 PM
It's just a time to buy Atomos Ninja ?


I need to pay the money for buying HDMI cable.
I think it's best for  me....
Title: Re: Movie autofocus experiments
Post by: Alia5 on July 25, 2012, 04:45:03 PM
Quote from: miyake on July 25, 2012, 04:27:50 PM
I have only standard lens.  But Alia5 is good information to me!!

@Alia5
Thanks !!!!  I just forget the analog cable!
First, I need to find 600D paper box.

Oh,,, But how can I record SD video?(lol


It's like mebius.


you could either set your second camera in front of your tv >.<
Or if you have a TV-Tuner in your pc with compisite video input (like me) you can record that^^
Title: Re: Movie autofocus experiments
Post by: 1% on July 25, 2012, 04:59:44 PM
TV capture card as said above with the SD/Headphone cable. 

HDMI cable to tv and 2nd camera pointed at TV. I think hdmi capture is $$$.
Title: Re: Movie autofocus experiments
Post by: miyake on July 29, 2012, 05:33:10 PM
experiment movie

walk with current movie af


noisy!!!!!(lol
and current movie AF can't identify focus peek of infinity focus.
Title: Re: Movie autofocus experiments
Post by: Alia5 on July 29, 2012, 07:45:07 PM
i just compiled from your source and played a bit...

wichever values i choose, focusing never stops when it should in continous mode

also we could maybe tell the camera in wich direction to focus. so we could press a button to focus in or out when not in continous mode

sadly i dont have much time now to look at the code :(
Title: Re: Movie autofocus experiments
Post by: listenpreis on July 29, 2012, 10:05:27 PM
Hehe, nice! Looks like Skynet's Terminator T1 (alpha)  8)
Title: Re: Movie autofocus experiments
Post by: funkysound on July 31, 2012, 09:22:31 PM
Quote from: miyake 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.

Miyake - your english seems to be much better than mine (hamburg germany) - anyway, I very much respect your work on the 600d audio and that´s what matters most - thanks!  :) :D
Title: Re: Movie autofocus experiments
Post by: miyake on August 01, 2012, 05:49:02 PM
@Alice5
Let's hack together!!

@listenpreis
T1 is 1984
T2 is 1994
So our MovieAF 2 will out at 2022. Yea! :D

@funkysound
C is more easy for me.  ;D
Title: Re: Movie autofocus experiments
Post by: Alia5 on August 02, 2012, 04:51:43 PM
Quote from: miyake on August 01, 2012, 05:49:02 PM
@Alice5
Let's hack together!!

If i had time to do so -.-
Also my coding is miserable

Oh and it's Alia5 not Alice5, but never mind ;)
Title: Re: Movie autofocus experiments
Post by: miyake on August 03, 2012, 03:09:09 PM
@Alia5
We never use alphabet in Japanese life. sorry for it.
Anyway, You do not find free time. You should make a time. ;)  :D :D :D
Title: Re: Movie autofocus experiments
Post by: Alia5 on August 03, 2012, 07:36:09 PM
never mind ;)

you're probably right ;).
but lets get back to topic here
Title: Re: Movie autofocus experiments
Post by: vBlack on August 19, 2012, 11:05:36 PM
Anything new here?
Title: Re: Movie autofocus experiments
Post by: miyake on August 20, 2012, 07:43:41 AM
Nothing any updates.
Because I'm making a X5(600D) audio function and "On camera bin selector" now.
Title: Re: Movie autofocus experiments
Post by: 1% on September 26, 2012, 02:11:06 AM
I found this in firmware:

NSTUB(0xFF107464, str:[GMT]_GMT_CONTINUOUSAF_Start)

Title: Re: Movie autofocus experiments
Post by: miyake on September 26, 2012, 04:37:32 AM
d
Title: Re: Movie autofocus experiments
Post by: 1% on September 26, 2012, 05:27:00 AM
I suck at assembly too.

pel.hu/armu/ is another thing like ida.
Title: Re: Movie autofocus experiments
Post by: miyake on September 26, 2012, 05:32:51 AM
d
Title: Re: Movie autofocus experiments
Post by: 1% on September 26, 2012, 06:19:50 AM
Go to import IDC file.
Title: Re: Movie autofocus experiments
Post by: miyake on September 26, 2012, 07:28:36 AM
d
Title: Re: Movie autofocus experiments
Post by: 1% on September 26, 2012, 07:52:49 AM
Probably not enough time and focus on stability for official releases. But lots of good things in the pipeline and I'm always trying to be up to date. So 600D will be better than it is already and many puzzles from before are getting solved.
Title: Re: Movie autofocus experiments
Post by: miyake on September 26, 2012, 09:08:16 AM
d
Title: Re: Movie autofocus experiments
Post by: 1% on September 26, 2012, 03:58:22 PM
Firmware starts at .0xff010000. I actually have to go and work today, so had to sleep last night. No getting out of it. :(