Setting focus from scripts or menus - page 55 - General Discussion and Assistance - CHDK Forum

Setting focus from scripts or menus

  • 601 Replies
  • 211949 Views
Re: Setting focus from scripts or menus
« Reply #540 on: 20 / March / 2015, 18:37:08 »
Advertisements
I ran mftest.lua from CHDK 1.3.0 on my Powershot D30.
Here are the results:


Canon Powershot D30 w/ CHDK 1.3.0

Re: Setting focus from scripts or menus
« Reply #541 on: 20 / March / 2015, 19:02:25 »
I ran mftest.lua from CHDK 1.3.0 on my Powershot D30.
Thanks for doing that.  All four test runs indicate that you should be able to set focus without using set_aflock() or set_mf(). It also indicates that you can use set_mf(1) to enable manual focus.

What is curious is that the first three trials show that set_aflock(1) does not work but it did in the fourth trial.  The camera looks like it's in a funny focus mode during that 4th trial - prop.FOCUS_STATE and prop.REAL_FOCUS_MODE are 4 in that trial but 1 in the first three.  A 4 usually means MF mode - almost like it got stuck there after the third trial.

Unfortunately this makes things inconclusive.  Especially as you reported issues with making MF work without using set_mf(1).

UPDATE : apparently this is cross posted - which as usual will confuse things.  The anomaly of the fourth run is because the OP set MF manually on the camera prior to running the trial.  http://chdk.setepontos.com/index.php?topic=12290.msg121240#msg121240
« Last Edit: 20 / March / 2015, 19:09:52 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline JvdP

  • ***
  • 174
Re: Setting focus from scripts or menus
« Reply #542 on: 05 / August / 2015, 16:30:20 »
I've ran the MF_test.lua on my 240 HS and here are the results ... Drumroll ...

Code: [Select]
Wed Aug  5 22:25:56 2015,MF Test 2.12 Log
ixus240_elph320hs,102a,CHDK,1.4.0-4203
Mode:P,Continuous_AF:0,Servo_AF:0
tests : set_focus:1, set_aflock:1, levents:1, event_procs:1, bypass:1
test,set,actual,result,prop.FOCUS_STATE,prop.AF_LOCK,prop.FOCUS_MODE,prop.REAL_FOCUS_MODE
1) Testing initial conditions
...interlock bypass function available
...start, , , ,0,0,0,0
...shot1,984,385,failed,1,0,0,0
2) Testing set_focus() only
...start, , , ,1,0,0,0
...shot1,300,299,passed,1,0,0,0
...shot2,700,692,passed,1,0,0,0
3) Testing set_aflock()
...start, , , ,1,0,0,0
...set_aflock(1), , , ,1,1,0,0
set_prop.AF_LOCK(1)
...start, , , ,1,1,0,0
...shot1,400,385,passed,1,1,0,0
...shot2,800,385,failed,1,1,0,0
...set_prop.AF_LOCK(0), , , ,1,0,0,0
...set_aflock(0), , , ,1,0,0,0
4) Testing levent PressSw1AndMF
...start, , , ,1,0,0,0
post_levent
...start, , , ,1,0,0,0
...shot1,500,497,passed,1,0,0,0
...shot2,900,863,passed,1,0,0,0
...toggle_Sw1AndMF, , , ,1,0,0,0
5) Testing SS.Create
...start, , , ,1,0,0,0
...SS.Create success
...>testing SS.MFOn
...SS.MFOn failed
...>testing PT_MFOn
...PT_MFOn success
...start, , , ,0,0,1,0
...shot1,600,580,passed,0,0,1,0
...shot2,1000,984,passed,0,0,1,0
...disable_PT.MFOn, , , ,0,0,0,0
6) Testing RegisterShootSeqEvent
...RegisterShootSeqEvent failed
7) Done

Now take a look, take a look
Tell me what do you see? what do you see?

Bonus points for knowing the song that has these lyrics (no Google allowed ;-) )

By the way, this post is related to my issues over at the 240 porting thread. I can set focus but I can't hold focus in the next shot. How could I hold focus? Or should I just set focus before each shot?
« Last Edit: 05 / August / 2015, 16:42:27 by JvdP »

Re: Setting focus from scripts or menus
« Reply #543 on: 05 / August / 2015, 17:20:08 »
How could I hold focus? Or should I just set focus before each shot?

I tried to fix possible problems with enabling MF and thereby keeping focus settings between shoot()s in a generic way by falling back to pressing camera buttons from the script here:
http://chdk.setepontos.com/index.php?topic=12290.msg121313#msg121313

I haven't figured out yet why this automated menu navigation only works sometimes with my Powershot D30 and that's the only CHDK-able camera I have. Maybe this helps you if you adjust the function set_mf_somehow (line 69) to your camera's sequences.
Canon Powershot D30 w/ CHDK 1.3.0


*

Offline JvdP

  • ***
  • 174
Re: Setting focus from scripts or menus
« Reply #544 on: 06 / August / 2015, 12:28:28 »
I'm not sure but I don't think my camera (IXUS 240/ELPH 320 HS) supports manual focus. I haven't seen it in the Canon menu's. So unfortunately this method doesn't work either.

Re: Setting focus from scripts or menus
« Reply #545 on: 06 / August / 2015, 22:43:28 »
I'm not sure but I don't think my camera (IXUS 240/ELPH 320 HS) supports manual focus. I haven't seen it in the Canon menu's. So unfortunately this method doesn't work either.
According to the test results you posted earlier it does. 
Code: [Select]
2) Testing set_focus() only
...start, , , ,1,0,0,0
...shot1,300,299,passed,1,0,0,0
...shot2,700,692,passed,1,0,0,0

4) Testing levent PressSw1AndMF
...start, , , ,1,0,0,0
post_levent
...start, , , ,1,0,0,0
...shot1,500,497,passed,1,0,0,0
...shot2,900,863,passed,1,0,0,0
...toggle_Sw1AndMF, , , ,1,0,0,0
5) Testing SS.Create
...start, , , ,1,0,0,0
...SS.Create success
...>testing SS.MFOn
...SS.MFOn failed
...>testing PT_MFOn
...PT_MFOn success
...start, , , ,0,0,1,0
...shot1,600,580,passed,0,0,1,0
...shot2,1000,984,passed,0,0,1,0
...disable_PT.MFOn, , , ,0,0,0,0

It won't do it with the Canon menus - they leave those sort of features out on less expensive cameras - but the Canon firmware supports it. And that is why you use CHDK.
« Last Edit: 06 / August / 2015, 22:46:15 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online reyalp

  • ******
  • 14121
Re: Setting focus from scripts or menus
« Reply #546 on: 26 / September / 2016, 00:16:48 »
I did some more sd override / focus at infinity testing on G7X. Previous related discussion https://chdk.setepontos.com/index.php?topic=12062.msg125970#msg125970 (and probably some other threads, feel free to add links)

I compared the values of PROPCASE_SUBJECT_DIST* (1 and 2 always appear to be the same), get_focus() and GetFocusLensCurrentPosition

This was done by setting the camera to MF, setting the MF distance to the nearest value, and running the attached script. The script uses levent button presses to move the canon MF UI through the available range. This is only applicable to cameras with native MF. The idea to understand the range of SD and position values available through the Canon UI.

The attached CSVs include results from my cameras. I'm not particularly looking for more results from other cameras, but it might be interesting if you have multiple cameras of the same model, especially if they exhibit different focus behavior.

Observations:
There are "position" values accessible through the Canon MF interface which are inaccessible by "subject distance" value: e.g. on G7x at the wide end, there are ~14 steps beyond where the "subject distance" values go to -1. At the near end, there are ~6 values that correspond to the same subject distance.

This supports earlier reports that there are cases where set_focus() simply cannot set the value required to obtain good focus, even thought Canon AF or MF UI can. It also means that get_focus() may not be usable to tell when the right value is set.

I confirmed by manual testing that values beyond where SD goes to -1 are actually different focus.

The point where SD goes to -1 corresponds to the focus bar being full at infinity in the UI on G7x. However, there is a triangle above the bar for most of the remaining steps. At wide angle on my camera, the actual best infinity focus seems to be one or two steps before the bar is full.

The "position" values available through the Canon UI vary depending on zoom.

Setting specific position values via UI clicks is finicky (see the do_move() function in the script). It took a lot of fiddling to get repeatable values from the script, but it seems consistent on my cameras now. I have not yet tried using functions that set by position.

The subject distance values you can set with set_focus correspond to a nearby position value. e.g on G7x calling set_focus with any value from 12000 to 23000 gives position 313, sd 17553. 24000 and above result in position 312 and sd -1

Notes
I'm assuming that GetFocusLensCurrentPosition represents a real hardware value, and the "subject distance" values are derived values, but this could be wrong.

GetFocusLensCurrentPosition is registered by Mecha.Create. There two equivalent functions registered by FA.Create + InitializeAdjustmentFunction: GetCurrentFocusLensPosition and GetCurrentFocusPosition. They all call the same underlying firmware function on G7X (and probably other cams)
Don't forget what the H stands for.

*

Offline Sdack

  • ***
  • 195
Re: Setting focus from scripts or menus
« Reply #547 on: 28 / November / 2017, 01:07:37 »
While trying to find the setting for hyperfocal on my Ixus 160, I stumbled across this thread.

Attached is the output of your test script, which for some reason didn't get named correctly. 

My naive read of the result is that for best results I need to run this command set_prop.AF_LOCK(1)
Cheers
Sdack
PS. I still haven't found the syntactical answer to hyperfocal ie. set_focus(>>insert hyperfocal magic here<<)


*

Offline srsa_4c

  • ******
  • 4451
Re: Setting focus from scripts or menus
« Reply #548 on: 28 / November / 2017, 16:35:34 »
PS. I still haven't found the syntactical answer to hyperfocal ie. set_focus(>>insert hyperfocal magic here<<)
See http://chdk.wikia.com/wiki/Script_commands#get_dofinfo
Also see http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page in case you have more questions.

Note, however, that the camera's idea of focus distance can be way off, so test that first.

*

Online reyalp

  • ******
  • 14121
Re: Setting focus from scripts or menus
« Reply #549 on: 28 / November / 2017, 21:19:42 »
set_prop.AF_LOCK(1)
The function is set_aflock(1)
From the script output, it looks like set_mf(1) should also work.

If you can verify that focus override does not work without using one of these, we should update the port, since the it currently is set as if focus override worked in regular AF.

You can test this by aiming the camera at a subject it doesn't have trouble focusing on, and then using set_focus() to set the opposite extreme. So if your test object is nearby, you could do something like the following in chdkptp

=set_focus(50000) shoot()

and the resulting image should be badly out of focus if SD override worked, or in focus if it didn't.

Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal