Precision shoot time in the EXIF - page 2 - Script Writing - CHDK Forum supplierdeeply

Precision shoot time in the EXIF

  • 14 Replies
  • 10134 Views
*

Offline reyalp

  • ******
  • 14118
Re: Precision shoot time in the EXIF
« Reply #10 on: 03 / August / 2014, 18:03:37 »
Advertisements
I'm not sure what you are refering to when mentionning the 'shoot hooks', could you point me to some documentation?
See the link waterwingz posted. Not that just using the message system to trigger a shoot_full should be within a few tens of ms of physically clicking the shutter, shoot hooks would only be required if you need to do better than that.

The rsint command and multicam modules in chdkptp both have examples of using shoot hooks and the message system.

Using the CLI shoot command or sending shoot() is much slower, since it does the whole focus / preshoot process. If you start and connect a chdkptp process for each shot that adds further delay.
Don't forget what the H stands for.

Re: Precision shoot time in the EXIF
« Reply #11 on: 03 / August / 2014, 18:22:19 »
Using the shoot command from chdkptp is how we tested it. I guess that was the wrong way.

What would be the correct sequence of commands through ptp to do the initial setup (focus preset to infinity if that's possible), let the camera do the preshoot process in advance, shoot, and ultimately retrieve the name of the picture then go back to ready state?

I don't have the need for a few tenth of milliseconds better than physically clicking the shutter, so I guess I can escape the need for hooks.

*

Offline reyalp

  • ******
  • 14118
Re: Precision shoot time in the EXIF
« Reply #12 on: 03 / August / 2014, 19:18:49 »
What would be the correct sequence of commands through ptp to do the initial setup (focus preset to infinity if that's possible), let the camera do the preshoot process in advance, shoot, and ultimately retrieve the name of the picture then go back to ready state?
This is going to depend on your camera and specific requirements, but my general approach would be to use a message script like rsint and multicam.

You can see msg_shell in rlibs.lua for a more basic example. You can extend this on the fly by sending lua code.

Essentially, at startup you would send a script to the camera using chdkptp, like
Code: [Select]
!con:exec('msg_shell:run()',{rlibs={'msg_shell','serialize_msgs'}})
This starts the msg_shell script and doesn't wait for it to quit. msg_shell sits in a loop waiting for commands sent as messages. The serialize_msgs library allows you to send lua values directly from the camera to Lua scripts running in chdkptp.

Now you can switch to record mode set your focus and exposure settings by sending the exec command, which treats the rest of the message as lua code to execute:
Code: [Select]
> putm exec switch_mode_usb(1)
> putm exec set_mf(1)
> putm exec set_focus(-1)
...
To shoot repeatedly with the same settings, you can just let the script hold shoot_half, and send click'shoot_full_only' for each shot (shoot_full_only is needed because for historical reasons shoot_full implicitly releases shoot_half)
Code: [Select]
> putm exec press'shoot_half'
> putm exec click'shoot_full_only'
> putm exec click'shoot_full_only'
...
> putm exec release'shoot_half'
To retrieve the name of the image, you need to do something a bit more complicated than click 'shoot_full_only': You will need to wait for the shot to be completed by using the raw shoot hook or checking the file counter, and you will need to have your code send back a message like
Code: [Select]
write_usb_msg(string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count()))
You can retrieve the message with the getm cli command, like
Code: [Select]
> getm
4:user:'A/DCIM/103CANON/IMG_3115.JPG'

To combine this with a shot, I'd use something like this (formatted for clarity, if sent it chdkptp putm exec it would be all one line)
Code: [Select]
local prev=get_exp_count()
click'shoot_full'
repeat sleep(10) until get_exp_count() ~= last
write_usb_msg(string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count()))
Rather than using getm, you probably want to use chdkptp side code to wait the message to arrive, and have your controller wait for it to appear on stdout before issuing the next shoot_full_only.
Code: [Select]
> !printf('file:%s\n',con:wait_msg({unserialize=true,mtype='user'}).value)
file:A/DCIM/103CANON/IMG_3119.JPG

In a real application, you'd probably want to create a lua module that has most of this code already in and just have a few functions to call. The multicam module may be a useful example. The rlib part at the bottom defines the camera side code.

Overriding focus is a somewhat complicated and camera dependent subject by itself, and IIRC elph110 may have unresolved issues, so I'm going to leave that for another post.
Don't forget what the H stands for.

Re: Precision shoot time in the EXIF
« Reply #13 on: 03 / August / 2014, 19:35:43 »
Overriding focus is a somewhat complicated and camera dependent subject by itself, and IIRC elph110 may have unresolved issues, so I'm going to leave that for another post.
The elph110 (aka ixus125) shares the dubious honor with the S100 of being a camera that does not currently want to focus at infinity using the CHDK set_focus() command.  See this thread :

http://chdk.setepontos.com/index.php?topic=11078.msg113891#msg113891

The mf testing done recent also shows that model crashing when attempting to focus after a set_aflock() command is issued.

However,  it seems possible that in an UAV application,  if the script waits until the camera is airborne (or does a series of half-shoots and checks the resulting subject distance to be sure it's airborne)  then issuing a set_aflock() at that point should make it essentially focus at infinity and stay locked there for the duration of the flight.


« Last Edit: 03 / August / 2014, 19:38:21 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 14118
Re: Precision shoot time in the EXIF
« Reply #14 on: 03 / August / 2014, 19:52:24 »
FWIW, according to the manual, elph110 does have a "focus at infinity" mode available in the canon UI. To set it, you'd probably need to do it on the actual camera or with key clicks sent from script.

My experience with other Canon cameras is that the firmware treats this as a suggestion rather than a hard limit, so it still might be bad results if the half press is done with something close to the camera.
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal