Putting Canon S110 into MF or AFL - Script Writing - CHDK Forum

Putting Canon S110 into MF or AFL

  • 37 Replies
  • 8610 Views
Putting Canon S110 into MF or AFL
« on: 28 / January / 2014, 03:02:11 »
Advertisements
Hi guys!
I've been trying for a long time to put my Canon S110 into MF or AFL state using chdkptp  command
(e.g. chdkptp -c -erec -e"shoot -tv=1/200 -sv=800 -av=0 -dl -rm" ) with no success.
Tried using lua commands such as set_prop or set_aflock etc. and till now - nothing.

My purpose is locking the focus, setting it to infinity and preventing AF activity so it won't consume time.
I need this command to be as fast a possible so I can generate it inside a loop with the smallest interval between iterations.

Any suggestions?
[PLZ, try helping me with ptpchdk, since I already tried other options and they had other drawbacks]

Thanks :) Nadav

*

Offline reyalp

  • ******
  • 11976
Re: Putting Canon S110 into MF or AFL
« Reply #1 on: 29 / January / 2014, 00:44:17 »
Unfortunately, overriding focus is something of a complicated topic. See  http://chdk.wikia.com/wiki/CHDK_Manual_Focus_and_Subject_Distance_Overrides

and http://chdk.setepontos.com/index.php?topic=11078.0 for ongoing work toward fixing this.

The current s110 code appears to be set up so that focus override only works in MF mode. To get into MF mode, you could either
1) set it up using the normal camera controls
2) try to script this using key presses. This is probably hard, because the number of presses required depends on the starting state.
3) use eventprocs. For this, you need to set "Enable Lua Native Calls" in the misc menu, then call
call_event_proc("SS.Create")
once after the camera starts.
Call call_event_proc("SS.MFOn") to enable MF, and call_event_proc("SS.MFOff") to disable it.
Don't forget what the H stands for.

Re: Putting Canon S110 into MF or AFL
« Reply #2 on: 31 / January / 2014, 14:37:27 »
Quote
3) use eventprocs. For this, you need to set "Enable Lua Native Calls" in the misc menu, then call
call_event_proc("SS.Create")
once after the camera starts.
Call call_event_proc("SS.MFOn") to enable MF, and call_event_proc("SS.MFOff") to disable it.

I tried what you said on the third option, and when I ran it I received the following message:
ERROR: :80: attempt to index global 'SS' (a nil value)
user code: 1


Basically this camera is supposed to be mounted on a UAV operated by an external PC running chdkptp instructions.
I can't trust key presses flow, and about the first option - setting it up using the camera menu - I'm not sure it's possible at all, Haven't seen anything related to this subject in the camera's menu.

Can you help me with the call event procedures?

Re: Putting Canon S110 into MF or AFL
« Reply #3 on: 31 / January / 2014, 14:46:14 »
Quote
3) use eventprocs. For this, you need to set "Enable Lua Native Calls" in the misc menu, then call
call_event_proc("SS.Create")
once after the camera starts.
Call call_event_proc("SS.MFOn") to enable MF, and call_event_proc("SS.MFOff") to disable it.

I tried what you said on the third option, and when I ran it I received the following message:
ERROR: :80: attempt to index global 'SS' (a nil value)
user code: 1

Did you cut and paste the code exactly?   There is a period  "." between the SS and MFOn.

Code: [Select]
call_event_proc("SS.Create")
call_event_proc("SS.MFOn")
« Last Edit: 31 / January / 2014, 14:49:22 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Putting Canon S110 into MF or AFL
« Reply #4 on: 31 / January / 2014, 15:00:03 »
Ok, it seems like the problem was because I used a per of " nested inside another per of ".
So now, when I use 'SS.Create' & 'SS.MFOn' it's seems like working well...
And now what? Is the focus now on manual? How do I set a value to it?

Thanks a lot WATERWINGZ!

Re: Putting Canon S110 into MF or AFL
« Reply #5 on: 31 / January / 2014, 15:51:26 »
Is the focus now on manual?
Yes.

Quote
How do I set a value to it?
set_focus(value)  were value is in mm
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 11976
Re: Putting Canon S110 into MF or AFL
« Reply #6 on: 31 / January / 2014, 16:31:47 »
Ok, it seems like the problem was because I used a per of " nested inside another per of ".
So now, when I use 'SS.Create' & 'SS.MFOn' it's seems like working well...
You should check the return values from event procs, if you are using chdkptp, you could do
=return call_event_proc("SS.Create"), call_event_proc("SS.MFOn")
which should give you something like

1:return:0
1:return:0

If the value after return: is -1 then something is wrong. You only need to do this once to make sure the eventprocs are valid on your camera, once you know they are right your UAV code doesn't need to check the return every time.

edit:
Another thing to watch out for, if the camera goes into power save mode (display off) it may turn MF off, so you sould have to call SS.MFOn again. The same may be true if you switch to playback mode and then back to record.
« Last Edit: 31 / January / 2014, 16:33:39 by reyalp »
Don't forget what the H stands for.

Re: Putting Canon S110 into MF or AFL
« Reply #7 on: 03 / February / 2014, 15:28:25 »
Awesome! Thank you very much the tips :)
So now MF is working well but I still can't get the interval to be fast enough... It's 2.5 secs and I want to reduce it to around 1 sec.

I'm running the following commands.
An init command runs once in the beginning:
Code: [Select]
$init = $exec." -c -erec -e\"luar call_event_proc('SS.Create'); call_event_proc('SS.MFOn'); set_prop(220,2); set_focus(150);\" ";

The capture command runs inside a loop with 0.25 second sleep between each iteration (prevents failures)
Code: [Select]
$captureCommand = $exec." -c -e\"shoot -tv=1/1000 -sv=50 -av=2 -dl\" ";
Do you think all -tv -av -sv etc. increases time consumption?
How can I get rid of it and set it only once in the $init command?

Thanks again   :D

Nadav


*

Offline reyalp

  • ******
  • 11976
Re: Putting Canon S110 into MF or AFL
« Reply #8 on: 03 / February / 2014, 22:18:45 »

The capture command runs inside a loop with 0.25 second sleep between each iteration (prevents failures)
Code: [Select]
$captureCommand = $exec." -c -e\"shoot -tv=1/1000 -sv=50 -av=2 -dl\" ";
Do you think all -tv -av -sv etc. increases time consumption?
No. These take a minimal amount of time. If you put your camera in manual mode, it may spend less time doing AE. When you use CHDK override in an automatic mode, the camera still does all the normal auto exposure process, and then CHDK replaces the values with the override values later.

Some other notes on shooting speed can be found in http://chdk.setepontos.com/index.php?topic=6231.msg98677#msg98677
Quote
How can I get rid of it and set it only once in the $init command?
As above, this isn't needed, the time to set and apply the override values is miniscule. But for completeness: Normally, script exposure settings only apply while the script is running. PTP commands work by sending script to the camera to execute, so if you set the exposure with on call and then shoot later, the setting would be lost. So to set them once, you would need to set them using either the camera UI, or using CHDK exposure overrides in the menu or with set_config_value, or in manual mode using the USER_TV / USER_AV propcases.

A few things you could do to increase the shooting rate:
1) use remoteshoot instead of shoot. This takes most of the same options but downloads directly over USB instead of saving on the card and then downloading. Note this means the images will NOT be saved on the card.
2) Instead of launching, connecting, shooting and disconnecting every shot, just start chdkptp once and pipe the shoot or remoteshoot commands to it. This saves you the connection overhead, and also probably avoids the problem mentioned in:
Quote
The capture command runs inside a loop with 0.25 second sleep between each iteration (prevents failures)
3) If you only need fixed exposure and focus, you can try the experimental chdkptp module mentioned here: http://chdk.setepontos.com/index.php?topic=6231.msg109228#msg109228 to do remoteshoot in continuous mode. This should be substantially faster. This requires using the "start once and pipe" approach mentioned in #2

edit:
Note the set_focus value is in mm, so unless you are flying really low set_focus(150) probably isn't what you want. If you are flying 15 cm off the deck, carry on  8)
« Last Edit: 03 / February / 2014, 22:23:55 by reyalp »
Don't forget what the H stands for.

Re: Putting Canon S110 into MF or AFL
« Reply #9 on: 05 / February / 2014, 08:31:35 »
With each answer I receive from you I learn more than I manged to learn from any link or message in the forum - most of the time it's just an overkill that I'm too dummy to understand :)

Quote
1) use remoteshoot instead of shoot. This takes most of the same options but downloads directly over USB instead of saving on the card and then downloading. Note this means the images will NOT be saved on the card.

I did and it works!
Do you know how do I set cont to be INFINITY? (is it possible?)

Quote
2) Instead of launching, connecting, shooting and disconnecting every shot, just start chdkptp once and pipe the shoot or remoteshoot commands to it. This saves you the connection overhead, and also probably avoids the problem mentioned in:
I don't see what you mean by pipeline (I'm familiar with the term but prob not in this context)... can you give me an example?

In addition to that, Do you know if it's possible to somehow ignore return values and\or prevent it from being printed to the console (e.g. on "chdkptp -c" i get the message "connected: Canon PowerShot S110, max packet size 512").


 

Related Topics