Author Topic: lua test_lens_focus()  (Read 551 times)

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3063
lua test_lens_focus()
« on: April 30, 2018, 02:02:17 AM »
What started out with a simple demonstration of how long it takes various lenses to complete the lua lens focus tests turned into something much bigger that probably needed a new topic so here it is.

[EDIT] All these tests were run on the lua_fix branch, not a unified (nightly) build so this is using the newer code base.

I thought it might be interesting to run through all my lenses and post how long it takes to complete the lens test. Since I've also got some EF-M lenses and wanted to run everything on the same body I put on the EF-M to EF adapter along with a plug in power supply on one of my EOSMs and started testing. First issue I came up with was that the Canon default settings puts the camera into Continuous AF mode. This needs to be disabled or the camera and the script will be playing tug of war with the focus.



The next issue I came up with was that some of my lenses didn't work on the EOSM. At first I thought it was because it was because I was using a third party EF-M to EF adapter or because I was using the 2.0.2 firmware and one of the lenses I was testing got a fix with the 2.0.3 update but it is more likely that neither of these were part of the problem. Why did I come up with that conclusion? Because none of the EF-M lenses could pass the lua focus tests.

The lens test starts with a prompt to put the lens in AF mode and to do a half-shutter press. The bulk of the testing happens after the autofocus confirmation so make sure you've got something you can focus on before starting the test.

LensEOSM Time700D Time
Canon EF-S 10-18mm f/4.5-5.6 IS STMNG0:45
Canon EF-S 18-135mm f/3.5-5.6 IS USM   NG1:05
Canon EF-S 17-55mm f/2.8 IS USM   0:501:00
Canon EF 28-105mm f/3.5-4.5 II USM1:001:10
Canon EF 50mm f/1.8 STM3:224:30
Canon EF-M 22mm f/2 STMNGn/a
Canon EF-M 18-55mm f/3.5-5.6 IS STMNGn/a
Canon EF-M 11-22mm f/4.5-5.6 IS STMNGn/a

The reason I started this was because we were testing the 1200D and had problems getting through the focus tests. I have experienced some lenses taking much longer than others to get through the tests but wanted to provide some more specifics so off came the lid on another can of worms.

By the way, while running through these tests sometimes the test wouldn't run the first time. Maybe I didn't hit the half-shutter at the right time or had the camera pointing at something that it couldn't auto focus on, I'm not sure. The lesson here was that if it doesn't run successfully the first time, try it a few more times before reporting that something is broken.

Curious what a successful lua focus test log looks like? This is a run of only the lens focus test.

Code: [Select]
===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2018-4-29 15:44:22
===============================================================================

Module tests...

Testing lens focus functionality...
Autofocus outside LiveView...
Focus distance: 1300
Autofocus in LiveView...
Please trigger autofocus (half-shutter / AF-ON / * ).
Autofocus triggered.
Autofocus completed.
Focus distance: 1450
Focusing backward...
Focus distance: 655350
Focus motor position: 0
Focusing forward with step size 3, wait=true...
.....
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 3, wait=true...
....
Focus distance: 655350
Focus motor position: 0
Focus range: 5 steps forward, 4 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.
Focusing forward with step size 3, wait=false...
........
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 3, wait=false...
.........
Focus distance: 655350
Focus motor position: 0
Focus range: 8 steps forward, 9 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.
Focusing forward with step size 2, wait=true...
.........................
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 2, wait=true...
........................
Focus distance: 655350
Focus motor position: 0
Focus range: 25 steps forward, 24 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.
Focusing forward with step size 2, wait=false...
.........................................
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 2, wait=false...
.........................................
Focus distance: 655350
Focus motor position: 0
Focus range: 41 steps forward, 41 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.
Focusing forward with step size 1, wait=true...
...............................................................................................
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 1, wait=true...
..............................................................................................
Focus distance: 655350
Focus motor position: 0
Focus range: 95 steps forward, 94 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.
Focusing forward with step size 1, wait=false...
...
Focus distance: 340
Focus motor position: 0
Focusing backward with step size 1, wait=false...
...
Focus distance: 655350
Focus motor position: 0
Focus range: 109 steps forward, 115 steps backward.
Motor steps: 0 forward, 0 backward, 0 lost.

Focus test completed.

Done!

An unsuccessful run the lens doesn't move and the log doesn't give much indication of what went wrong:

Code: [Select]
===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2018-4-29 15:38:31
===============================================================================

Module tests...

Testing lens focus functionality...
Focus distance: 160
Autofocus in LiveView...
Please trigger autofocus (half-shutter / AF-ON / * ).
19...18...17...Autofocus triggered.
Autofocus completed.
Focus distance: 1940
Focusing backward...
5D3.* 7D.206 700D.115 EOSM.203

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3063
Re: lua test_lens_focus()
« Reply #1 on: May 03, 2018, 03:06:37 AM »
This issue with lua not being able to focus certain lenses is showing up on several tests. I thought I remembered that it used to work on the EOSM but going back to the very early days of lua integration and knowing now that Continuous AF needs to be disabled, it looks like it never worked with EF-M lenses. Here's a pull request from a while back -- Focus backend updates - precise focus position and other tweaks that shows it wasn't for a lack of trying.
5D3.* 7D.206 700D.115 EOSM.203

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3063
Re: lua test_lens_focus()
« Reply #2 on: May 06, 2018, 01:29:23 AM »
The plot thickens--

LensEOSM700D650D100D
Canon EF-S 10-18mm f/4.5-5.6 IS STM
NG
OK
NG
NG
EF 50mm f/1.8 STM
OK
OK
OK
OK
Canon EF-S 18-135mm f/3.5-5.6 IS USM
NG
OK
?
?
5D3.* 7D.206 700D.115 EOSM.203