Setting focus from scripts or menus

  • 546 Replies
  • 27049 Views
  • Publish
    Setting focus from scripts or menus
    « on: 30 / December / 2013, 14:07:09 »
    Advertisements
    Phase 2 Instructions Here ->  Manual Focus Test Phase 2 Instructions
    script download link >   MF_test.lua
    links to results so far > Google Docs Spreadsheet

    I've been working for some time now on CHDK's ability to set the camera's focus.  Different cameras seem to need different things.  I've recorded some of my findings here : CHDK Wiki Page

    What I think I have discovered is that there are three types of cameras when it comes to using the set_focus() script commmand.
    • Cameras that will set_focus() with no setup or other scripting commands needed.
    • Cameras that will set_focus() if they have a Canon native MF (manual focus) mode and that mode is enabled.
    • Cameras that will set_focus() when the camera is in Canon's AFL (auto focus lock) mode .

    Obviously,  the first group of cameras (mostly older models) needs no further investigation.  And I've learned that the second group of cameras can be placed in MF mode in a script by calling post_levent_for_npt("PressSw1AndMF") (props to philmoz for discovering that and reporting it in the forum).  But cameras in the third group have proven problematic. 

    Some cameras in the third group will focus if a set_aflock(1) command is issued prior to a set_focus() command but some will not.  Those that will not need to be placed into Canon AFL mode from the camera keyboard prior to shooting.  This is a problem as the only way to do that from a script is with click() commands, which are carmera dependent.

    But I've had a breakthrough!   I've discovered that on my cameras, set_aflock(1) does not set the AF lock property case value. However, if I set it from the script using set_prop(props.AF_LOCK,1)  when set_aflock(1) is called then the camera LCD show the Canon AFL icon and I can use set_focus() from within my script!  No manual keyboard setting required. [see the note below]

    This is quite exciting as it means we are very close to being able to use set_focus() in any script with no prior camera setup required.

    Still, it would be good to know which cameras can use what modes and how the overlap.  So I've attached a small test script in the hope that people will run it and post the resulting mf_test.csv file here for analysis.  I'll compile all submissions and sumarize here and on the wiki page I mentioned above.

    So please test your camera and report back here with an attached mf_test.csv file. Simple instructions are in the title block of the script.

    TIA

    WW


    Note: (technical discussion)

     It turns out that a big part of the problem was caused by somewhat arbitrary setup values used in camera.h and how they interact in CHDK's  shooting_can_focus() C function:
       CAM_HAS_MANUAL_FOCUS
       CAM_CAN_SD_OVERRIDE
       CAM_CAN_SD_OVER_NOT_IN_MF
       CAM_CAN_SD_OVER_IN_AF_LOCK
       CAM_CAN_SD_OVER_IN_AF_LOCK_ONLY

    These control whether SD override is available on the CHDK menus and whether to prevent attempts to set focus if the camera is not in AFLock mode. Setting focus when not in AFLock mode causes some cameras to crash.   The CHDK code looks at several property case values to determine whether to allow set_focus() or not.  One of those property case values is the AFL value, which what not being set by set_aflock() so my camera would not accept the set_focus() command.  In IRC discussions with reyalp,  we've agreed that these need to be reviewed and clarified and then some cameras may need their configuation modified.

    An easy fix to the current code for set_aflock() is to have it also set the AFLock property case value appropriately so that it does not need to be done in the script.

    An outstanding issue is how the SD override functions in the CHDK menus can be fixed.  Currently some cameras need to be placed in AFL mode manually before the menu SD overrides will work.  And some apparently just crash.

    I'm sure I've missed some other things here.  IIRC, philmoz posted that on some cameras,  the set_aflock() needs to be make while a "half-press" is active for example.  Other comments and observations are welcome!

    Note :
     - updated script to v2.1 to correctly handle missing propcases for propset3 cameras.
     - updated script to v2.2 to allow individual tests to be enabled/disabled and added another MF enable method
     - updated script to v2.3 for log file robustness, focus lock checking before shooting, ranges moved to not overlap or be too close for G1x, SS.MFOn enable by default
     - updated scritp to v2.4 to expand focus test criterion to pass if actual is within 20% for actual (from 10%)
     - updated script to v2.7 with multiple changes supporting provisional CHDK set_focus_interlock_bypass mode
     - updated script to v2.8 to fix wrong report if cam can't focus and to forcibly disable CHDK menu override and SD overide modes
     - updated script to v2.9 to add restore() function (from msl)
     - updated script to v2.10 to cause script to halt immediately if Lua Native Calls are not enabled
     - updated script to v2.11 to allow individual disable of event_proc tests
     - updated script to v2.12 to check that CHDK 1.3.0 rev 3303 or later is loaded
    « Last Edit: 29 / March / 2014, 09:59:23 by waterwingz »

  • Publish
    Note : script attached above updated to v2.1 to correctly handle missing propcases for propset3 cameras.

  • Publish
    Hello,

    testet on SX230HS 1.00c

    By

  • Publish
    testet on SX230HS 1.00c
    Thanks for that.  First camera that I've seen that will focus in MF mode but not set_aflock().  Very good to know that !


    *

    Offline JvdP

    • ***
    • 174
  • Publish
    My Ixus 240 HS passes the first test but just crashes (shuts off without retracting lens) during the second test. The .csv is empty. Here is the ROM crashlog:

    Code: [Select]
    ASSERT!! FocusLensController.c Line 829
    Occured Time  2013:12:05 21:01:05
    Task ID: 18153512
    Task name: CaptSeqTask
    SP: 0x0055FB74
    StackDump:
    0x00000000
    0xFF1DE614
    0x0000033D
    0x00000DAC
    0x00000001
    0x00000DAC
    0x00000001
    0x00000000
    0x19980218
    0x19980218
    0x19980218
    0xFF1DEF2C
    0x000000EA
    0x000149E8
    0x00000DAC
    0xFF48559C
    0x00000000
    0x000000EA
    0x000149E8
    0x00000000
    0x00003540
    0xFF4855F4
    0x000000EA
    0x002A6A84
    0x00000000
    0x00283070
    0x000000EA
    0x000000EA
    0x0028E7D9
    0x002A6A84
    0x002A6A84
    0x0028F595
    0x0009DDA4
    0x0009DC94
    0x00298818
    0x00000000
    0x00000045
    0x20434453
    0x00000020
    0x0009DDA4
    0x0009DC94
    0x00000000
    0x00003540
    0x00000000
    0x19980218
    0x19980218
    0x19980218
    0x00000045
    0x00285618
    0x0009DCA8
    0x0053FF38
    0x19980218
    0x19980218
    0x19980218
    0x19980218
    0x19980218
    0x0068738C
    0x19980218
    0x19980218
    0x00000208
    ShootConDump:
    01 02 07 08 09 0a 0c 0b 00 00
    CameraConDump:
    07 0a 02 0d 09 01 0f 0f 0f 0f
    00017590: UI:_MuteOff
    00017590: UI:DSIC:44,0
    00017590: UI:ShootState:0xA
    00017590: UI:ShtCon_StartReview
    00017590: UI:ShootState:0xC
    00017590: SS:ExitShoot
    00017760: UI:ShootSeqToUI:0x2007:adr:0x3e8f,Para:16015
    00017760: UI:ShootSeqToUI:0x2001:adr:0,Para:0
    00017760: UI:_EntryPrepareRecreviewOff
    00017760: UI:ShootState:0xB
    00017760: UI:ShtCon_StopReview
    00017760: UI:_fReservedExitSequence=TRUE
    00017760: SS: Raw[1]
    00017760: SS: Raw[1]
    00017760: SS: Raw[1]
    00017770: UI:Sht_CancelStrobeChargeTimer
    00017770: UI:DSIC:4c,0
    00017770: UI:_CaptureStanbyForReview
    00017770: UI:DSIC:47,0
    00017770: UI:DSIC:46,0
    00017780: UI:ShootSeqToUI:0x201e:adr:0x3e8f,Para:16015
    00017780: UI:ShootSeqToUI:0x2029:adr:0x3e8f,Para:16015
    00017780: UI:_ExitSequence
    00017780: UI:Sht_CancelStrobeChargeTimer
    00017780: UI:DSIC:4c,0
    00017780: SS:CancelPre
    00017790: SS:NextAvail(6),ReviewAvail(5)
    00017990: UI:DSIC:48,0
    00018350: SS:ChargeComplete
    00018350: UI:DispSwCon_MuteOffPhysicalScreen
    00018350: UI:Window MuteOff
    00018350: UI:MuteOffPhysicalScreen
    00018350: UI:ShootState:0x0
    00018350: UI:ShtCon_Deactivate
    00018350: UI:DSIC:14,0
    00018350: UI:DSIC:60,0
    00018350: UI:DispSwCon_TurnOnDisplayDevice
    00018350: UI:ScreenLock
    00018460: UI:Display_CaptInfo
    00018460: UI:ScreenUnLock
    00018490: UI:DispSw: Unlock
    00018490: UI:DispSwCon:Unlock
    00018490: UI:TerminateDeliverToZoomController
    00018490: UI:OPTICAL_ZOOM_POS
    00018490: UI:UnpressZoomLever
    00018490: UI:ScreenLock
    00018490: UI:Reduce ScreenUnLock
    00018490: UI:ScreenLock
    00018490: UI:Reduce ScreenUnLock
    00018490: UI:_EntryIdleShoot
    00018490: UI:ShootState:0x0
    00018500: UI:DisplayPhysicalScreenCBR
    00018500: UI:Re ScreenUnLock
    00018500: UI:ScreenUnLock
    00018510: UI:DisplayPhysicalScreenCBR
    00018790: SS:AFL
    00019670: SS:AFL*
    00021710: UI:Button:0x000009A1:PressSwOne
    00021710: UI:DSIC:25,0
    00021710: SS:PreBuf
    00021710: UI:ShootState:0x1
    00021710: UI:ShtCon_Activate
    00021710: UI:DispSw: Lock
    00021710: UI:ShtCon_PrepareCapture
    00021710: UI:DSIC:61,0
    00021710: UI:ScreenLock
    00021720: UI:ScreenUnLock
    00021720: UI:ScreenLock
    00021720: UI:Reduce ScreenUnLock
    00021720: UI:LogicalEvent:0x3135:adr:0,Para:0
    00021720: SS:LoadTest:10
    00021720: SS:PreCapt
    00021730: UI:ShootState:0x2
    00021730: UI:ClearEventComp
    00021740: UI:DisplayPhysicalScreenCBR
    00021740: UI:Re ScreenUnLock
    00021740: UI:ScreenUnLock
    00021750: UI:DisplayPhysicalScreenCBR
    00021860: UI:ShootSeqToUI:0x203b:adr:0x40,Para:64
    00021860: UI:DSIC:69,0
    00021890: UI:ScreenLock
    00021890: UI:ScreenUnLock
    00021950: UI:DisplayPhysicalScreenCBR
    « Last Edit: 30 / December / 2013, 15:04:08 by JvdP »

  • Publish
    My Ixus 240 HS passes the first test but just crashes (shuts off without retracting lens) during the second test.
    Thanks for posting that - no idea what's happening there.  Or at least not yet. 

    But I think its good that we are going down the road of doing this testing for as many cameras as possible.  :D

    Just ran the script on my sx50.  All three tests fail!   The camera appears to go into AFL mode successfully - the AFL letter on the Canon OSD appear.  But it can't set forus.  And MF fails totally.   But this might be due to how the #defines in platform_camera.h are setup - I need to look at that.


  • Publish
    BTW .... I've already got results for the A1200,  IXUS120_SD940 and G10

    The A1200 will only focus with set_aflock(). The other two will focus in all three test cases.

    *

    Offline JvdP

    • ***
    • 174
  • Publish
    Glad to help, wish I owned more camera's I could test. I have three but all three are IXUS 240 HS  ::)


    *

    Offline msl

    • *****
    • 1177
    • A720 IS, SX220 HS 1.01a
      • CHDK inside
  • Publish
    Results for A720  & SX220
    German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
    Note: SDM violates the GPL rules!

    *

    Offline reyalp

    • ******
    • 9959
  • Publish
    Huge thanks to waterwingz for braving this mess.

    Here are results from my cams.

    The current trunk elph130 crashed on the first test. I know from earlier testing that it requires AF lock, but as we discussed last night it turns out the defines aren't set up right. The attached log has
    #undef CAM_CAN_SD_OVER_NOT_IN_MF
    added.
    Don't forget what the H stands for.

     

    Related Topics