Scripting in CHDKptp - Script Writing - CHDK Forum

Scripting in CHDKptp

  • 15 Replies
  • 456 Views
Scripting in CHDKptp
« on: 02 / May / 2020, 09:15:58 »
Advertisements
How can I use lua commands in the CHDKptp console? Somehow anything I try (getting/setting exposure parameters, focus, zoom) is accepted as an error.
« Last Edit: 02 / May / 2020, 09:28:42 by nubicon »

*

Offline reyalp

  • ******
  • 12537
Re: Scripting in CHDKptp
« Reply #1 on: 02 / May / 2020, 15:03:19 »
Please post an example of a specific command you used and the resulting error.

You might also find some useful information in
https://app.assembla.com/spaces/chdkptp/wiki/CLI_Quickstart
https://app.assembla.com/spaces/chdkptp/wiki/Scripting_Guide
Don't forget what the H stands for.

Re: Scripting in CHDKptp
« Reply #2 on: 02 / May / 2020, 16:21:12 »
Please post an example of a specific command you used and the resulting error.

You might also find some useful information in
https://app.assembla.com/spaces/chdkptp/wiki/CLI_Quickstart
https://app.assembla.com/spaces/chdkptp/wiki/Scripting_Guide

Thanks. This helps.

Now =set_focus() and =return get_focus() work. Even during recording a video(at least in MF). So will this really disable AF ?

Strangely enough if I set_focus(20000) the get_focus() returns -1.

If you want to focus on an object 2m ahead would you use half_press or set_focus(2000)? I ask b/c I got a feeling that the script focus is not really accurate. But maybe it's b/c the DOF of the camera (so that focus(1) and focus(20) look very similar).

BTW I asked before about controlling exposure during video recording and you said that this is on the risky side. Is the problem with setting the ISO value? or the shutter speed?
Is there's a way at least to disable the auto exposure hunting?

And last question - how can I get rid of the annoying menu that appears randomly in <ALT> mode?

Hope this is not too much to ask for.

*

Offline reyalp

  • ******
  • 12537
Re: Scripting in CHDKptp
« Reply #3 on: 02 / May / 2020, 17:32:47 »
Now =set_focus() and =return get_focus() work. Even during recording a video(at least in MF). So will this really disable AF ?
Behavior depends on the camera, but if you can set MF in video, then AF should indeed be disabled. In MF mode, =set_focus() should take effect immediately.
Quote
Strangely enough if I set_focus(20000) the get_focus() returns -1.
This isn't surprising. -1 means infinity (or beyond). Where it switches to -1 depends on the camera and zoom level. At wide angle, "infinity" is usually quite close.

Quote
If you want to focus on an object 2m ahead would you use half_press or set_focus(2000)? I ask b/c I got a feeling that the script focus is not really accurate.
The set_focus value is in mm, so you would use set_focus(2000) to focus at 2m, and indeed, the value isn't necessarily well calibrated.
Quote
But maybe it's b/c the DOF of the camera (so that focus(1) and focus(20) look very similar).
The camera probably can't focus at 1mm, or even 20mm. 50 is often the minimum, but it depends on the camera.

You could use autofocus and AF lock instead. Usually in the canon firmware, you get AF lock by holding half press and then clicking the focus mode button (left on many cams)
You could do this in chdkptp with something like
Code: [Select]
=press'shoot_half' sleep(1000) click'left'
Whether it works in video probably depends on the camera.

Quote
BTW I asked before about controlling exposure during video recording and you said that this is on the risky side. Is the problem with setting the ISO value? or the shutter speed?
I wouldn't say it's risky in terms of hurting the camera. Crashing or not working, maybe.

Quote
Is there's a way at least to disable the auto exposure hunting?
You may be able to use  AE lock, depending on the camera. The Canon firmware shortcut is usually hold half press and click the +/- button, but I think most cameras don't support it in video. You can try =set_aelock(1).

Quote
And last question - how can I get rid of the annoying menu that appears randomly in <ALT> mode?
If you mean the help screen, go to CHDK settings, Menu, and uncheck "Show <ALT> Help Screen"
Don't forget what the H stands for.


Re: Scripting in CHDKptp
« Reply #4 on: 02 / May / 2020, 20:15:45 »
Quote
BTW I asked before about controlling exposure during video recording and you said that this is on the risky side. Is the problem with setting the ISO value? or the shutter speed?
I wouldn't say it's risky in terms of hurting the camera. Crashing or not working, maybe.
Somebody was asking about this today on one of the Facebook CHDK pages.  They were trying to use videxp3.lua on a modern camera without a lot of success.

CHDK Wikia Link : Manual Exposure Control for Video Recording

Quote
Quote
And last question - how can I get rid of the annoying menu that appears randomly in <ALT> mode?
If you mean the help screen, go to CHDK settings, Menu, and uncheck "Show <ALT> Help Screen"
One of those default settings I've always changed right away each time I setup a new version of  CHDK on my cameras.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Scripting in CHDKptp
« Reply #5 on: 02 / May / 2020, 22:32:30 »
I'm impressed, reyalp! Thanks a lot.

I think something behaves strangely by I'll check this more.

Re: Scripting in CHDKptp
« Reply #6 on: 03 / May / 2020, 08:25:17 »
That's what happens - disabling AF AE works but this script crashes the camera just after the recording starts. Every part alone works fine.
Code: [Select]
sleep(1000)
set_autostart(0)
   set_mf(1)
   sleep(500)
   press "shoot_half"
   sleep(2000)
   click "left"
   sleep(400)
   release "shoot_half"
sleep(800)
set_aelock(1)

----------------------------------- this part alone works
 set_record(true)  --record
 while ( get_mode() == false ) do sleep(100) end
 sleep( 1000)
 play_sound(1) 
 click("video")
« Last Edit: 03 / May / 2020, 10:49:28 by nubicon »

*

Offline reyalp

  • ******
  • 12537
Re: Scripting in CHDKptp
« Reply #7 on: 03 / May / 2020, 13:47:28 »
Can you post a romlog from the crash: https://chdk.fandom.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

I'm not clear how the quoted script is supposed to work.
All the stuff related to MF, AF lock, AE lock should happen after you've switched to rec mode.
If you use set_mf, then the AF lock shortcut should be pointless, unless set_mf doesn't work on this camera, in which case it's the set_mf part that's pointless.

To figure out which specific step is crashing, you could using prints, like
print("set mf")
set_mf(1)

You can use https://chdk.fandom.com/wiki/CHDK_scripting#print_screen to log to a file, or just put a sleep between the print and the action so you have time to read it.
Don't forget what the H stands for.


Re: Scripting in CHDKptp
« Reply #8 on: 03 / May / 2020, 17:48:56 »
The script works without
Code: [Select]
set_record(true)  --record
while ( get_mode() == false ) do sleep(100) end
but crashes (after starting to record) when I move to play mode (I need this part). And sometimes during the recording.

The AF lock doesn't work without moving to Manual focus( in script and also manually).
« Last Edit: 03 / May / 2020, 17:56:40 by nubicon »

*

Offline reyalp

  • ******
  • 12537
Re: Scripting in CHDKptp
« Reply #9 on: 03 / May / 2020, 18:29:37 »
The script works without
Code: [Select]
set_record(true)  --record
while ( get_mode() == false ) do sleep(100) end
but crashes (after starting to record) when I move to play mode (I need this part). And sometimes during the recording.
The crash is
Code: [Select]
ASSERT!! AudioHandle.c Line 224
Occured Time  2020:05:03 13:00:14
Task ID: 18022441
Task name: PhySw
SP: 0x0057B590
This seems to be from CHDK script (PhySw task) and AudioHandle.c Line 224 appears to related to play_sound. Possibly the number used is bad, or there is something else preventing it from working.

Quote
The AF lock doesn't work without moving to Manual focus( in script and also manually).
This doesn't make sense to me. The point of AF lock is to autofocus, and then lock the focus at the autofocused distance. If the camera is already in MF, the autofocus isn't going to happen.

On cameras that have MF in the canon firmware, the AF lock shortcut generally just switches to MF mode after focusing.

On my sx160, which is a similar generation camera to your sx260, pressing the shortcut while in MF mode just exits MF.

And again, I'm not clear if you are actually running the script as you posted it, but anything to do with AF lock, or MF only makes sense after the camera is in rec mode (rec refers to shooting mode, as opposed image playback, not video recording). If you are running the script in the order you posted, all the stuff before set_record is wrong. If you aren't using PTP, the first half press might cause the camera to switch to rec.

If you are running something different from the script posted, I'd suggest posting what you are actually running.
« Last Edit: 03 / May / 2020, 18:38:47 by reyalp »
Don't forget what the H stands for.

 

Related Topics