get exposure without shoot_half - Script Writing - CHDK Forum

get exposure without shoot_half

  • 12 Replies
  • 3052 Views
get exposure without shoot_half
« on: 24 / November / 2012, 19:57:41 »
Advertisements
Hello!

Is there a way to get the exposure values set (the get_av96, get_tv96, etc ...) without doing a press or click shoot_half?

In M mode the camera seems to be constantly measuring the exposure since there is a little bar on the right that moves up and down to tell me how close I am to the exposure value. So I thought it might be possible. I tried a loop that gets and prints the values and set the camera into M mode manually and no luck. Any other way?

Edit: I'm on an S100.

Thanks!

*

Offline reyalp

  • ******
  • 12690
Re: get exposure without shoot_half
« Reply #1 on: 24 / November / 2012, 20:31:55 »
There is no known way to do this. The exposure related propcases appear to only be updated on halfpress. The fact that camera does continuously adjust the live view brightness in auto modes suggests that something like Bv should available somewhere in real time, but reverse engineering would be required to find it.

In the 1.2 development version, you can use get_live_histo to get a histogram of the viewport buffer Y (luminance) values at any time from lua script. Brief documentaiton:
Code: [Select]
histogram,total=get_live_histo()
returns a histogram of Y values from the viewport buffer (downsampled by HISTO_STEP_SIZE)
histogram[Y value] = count, so it is zero based unlike a normal lua array
total is the total number of pixels, may vary depending on viewport size

In auto modes, you probably can't relate this to actual exposure values outside of half press, since the camera adjusts the display brightness on the fly and you don't know what exposure settings that would correspond to. You might be able to in manual mode, since the display should reflect your manually set exposure values (assuming it's not off scale).
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: get exposure without shoot_half
« Reply #2 on: 24 / November / 2012, 20:45:00 »
If you want to take a series of pictures with the same focus and exposure, you can use press("shoot_full_only"). Here's how I take a series of pictures as fast as possible:
Code: (lua) [Select]
nxp=get_exp_count()
press("shoot_half")
for i=1,10 do
    press("shoot_full_only")
    while(nxp==get_exp_count())do
      sleep(10)
    end
    release("shoot_full_only")
-- sleep(1000) --would delay 1 second between shots
end
release("shoot_half")
Is this what you were looking for?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: get exposure without shoot_half
« Reply #3 on: 25 / November / 2012, 00:06:43 »
I did not know there was an 'get_exp_count()'... thats clever!

Being able to pull the histogram is also cool.

I am asking more out of curiosity. The problem I am having is related to manual focus on the S100.

I wanted to work around two limitations the S100 had when trying to take night photos. The first is not going about 16", the second is forcing ISO 80 at anything about 1".

So, I do the usual:

- Set the av96 and sv96 (wide open and usually 200 or 400)
- half_press, sleep a bit (useful to make sure camera is stead too!)
- get the bv96
- release half_press (I have to do this or else the set_tv96_direct does not work)
- use the bv96 and my settings to compute the real tv96
- set the all the exposure values
- shoot() or click shoot_full or click shoot_full_only

This works great. The problem is, I often forget to set the manual focus and focus to infinity (and so sometimes the release happens before it is done focusing, so the exposure values are just some default).

So, I want to force manual focus and infinity focus in the script. But it just does not seem to work on the S100.

I tried so many different orders, combinations, placements of set_prop(6,4), set_prop(65, -1), set_aflock(1), set_focus(65535), click/press/release/etc in the script ... and I did not keep track :( ... so I need to start over. (Sympathy grab: I did about 50 SD card ejects, script updates, card inserts... and then realized I should have kept track instead of brute forcing and trying lots of things).

set_prop(6,4) and set_prop(65, -1) seem 'correct' because I can set the camera to manual focus and do get_props on them and I get those values (and they change when I change the settings).

I have looked at many other scripts, but most of them do a half_press, and loop until they've got focus, then aflock (I have this in a intervaolmeter script). I want to set the focus and aflock before any presses. Or just force manual focus and not have the camera even try.

TL;DR -> just whining and letting off steam :D ... I'll get it working eventually.

EDIT: so I guess my question is, how do I debug why the set props are not working. I've submitted a patch before to get the ring func button doing what it should... but this seems different.

« Last Edit: 25 / November / 2012, 00:37:18 by martinl »


*

Offline reyalp

  • ******
  • 12690
Re: get exposure without shoot_half
« Reply #4 on: 25 / November / 2012, 00:54:22 »
I tried so many different orders, combinations, placements of set_prop(6,4), set_prop(65, -1), set_aflock(1), set_focus(65535), click/press/release/etc in the script ... and I did not keep track :( ... so I need to start over. (Sympathy grab: I did about 50 SD card ejects, script updates, card inserts... and then realized I should have kept track instead of brute forcing and trying lots of things).
Just a note, you can use the CHDK PTP interface http://chdk.wikia.com/wiki/PTP_Extension to upload scripts directly, or test script code interactively.
Quote
EDIT: so I guess my question is, how do I debug why the set props are not working. I've submitted a patch before to get the ring func button doing what it should... but this seems different.
There's a lot of things that just can't be set by property cases. The CHDK focus override uses other internal canon functions. If it doesn't work, then it needs to be debugged. Problems with this function are pretty common. It also might work only an AF or MF mode.

If you want to focus at infinity using MF, you may be able to do this using scripted key presses. You should be able to read back the propcase to know when you are in MF mode. From the manual, it appears you can use the left and right keys to adjust focus instead of the ring. If you hold down right for long enough, it should go to the end of the range and stop.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: get exposure without shoot_half
« Reply #5 on: 25 / November / 2012, 00:56:32 »
On my cameras, if I press half_shoot in auto focus mode, then press <left>, it will go into manual focus mode. This trick works in Lua. I'm not sure it works on your camera, but it's worth a try.

The attached script attempts to go into manual focus mode with the above trick. If it works, it sets the focus based on a parameter, and does another half_shoot. If you're not in manual focus mode when you do set_focus(d), it doesn't work, or crashes the camera on my sx260.

========

The problem with set exposure functions is that you have to do them before half_shoot, but you only get bV after half shoot. So you need 2 half shoots per picture, or you're setting exposure based on the previous picture. That's not good.

After much experimenting, I figured out the solution for tV and sV:

Code: (lua) [Select]
--put this at the start of your program
props=require("propcase")
pTV=props.TV
pTV2=props.TV2
pSV=props.SV -- real sv
pDELTA_SV=props.DELTA_SV
props=nil -- frees memory

-- then to take a picture, try this

press("half_shoot)
repeat sleep(50) until get_shooting()
bv=get_bv96()

--compute your tv and sv values, and still in half_shoot, do this:

  set_prop(pTV,tv) -- actual
  set_prop(pTV2,tv) -- EXIF data

  set_prop(pDELTA_SV,sv-get_prop(pSV)+get_prop(pDELTA_SV)) -- sets actual exposure
  set_prop(pSV,sv) -- sets EXIF data
  click("shoot_full")
  while(get_shooting())do sleep(50) end
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: get exposure without shoot_half
« Reply #6 on: 25 / November / 2012, 10:04:17 »
(Sympathy grab: I did about 50 SD card ejects, script updates, card inserts... and then realized I should have kept track instead of brute forcing and trying lots of things).
Just a note, you can use the CHDK PTP interface http://chdk.wikia.com/wiki/PTP_Extension to upload scripts directly, or test script code interactively.
Thinking back to how I almost destroyed my SD940 doing my initial port and my small stack of SD card with broken "lock" switches from too many card insert/ejects,  I realized it might be good to document how to use chdkptp with batch files for code & script development.  So I started this User page - I'll move it into the wiki when its more complete. 

http://chdk.wikia.com/wiki/User:Waterwingz/Using_PTP_for_Development

Its very command line oriented (so far) - if I get around to doing an AutoIT version at some point I guess that would be even better.   Thanks to reyalp for the guts of all the posted scripts.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1269
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: get exposure without shoot_half
« Reply #7 on: 25 / November / 2012, 10:30:17 »
Thinking back to how I almost destroyed my SD940 doing my initial port and my small stack of SD card with broken "lock" switches from too many card insert/ejects,  I realized it might be good to document how to use chdkptp with batch files for code & script development.  So I started this User page - I'll move it into the wiki when its more complete.
With the ptpCamGui you can also upload all related CHDK files: scripts, single module files, diskboot.bin, ps.fi2/ps.fir or automatically extracted zip files from autobuild servers or local host. The GUI has a developer environment for Lua scripts. You can test scripts without upload to the camera.

msl
CHDK-DE:  CHDK-DE links


Re: get exposure without shoot_half
« Reply #8 on: 25 / November / 2012, 10:55:19 »
With the ptpCamGui you can also upload all related CHDK files: scripts, single module files, diskboot.bin, ps.fi2/ps.fir or automatically extracted zip files from autobuild servers or local host. The GUI has a developer environment for Lua scripts. You can test scripts without upload to the camera.
Very nice.  I'll add a link to my wiki page. 

Right now I've  focused on batch file / scripts - mostly because when I'm coding I can cycle through the work flow from the command line much faster that clicking through a Gui.  The keyboard command buffer is a wonderful thing.

But pointing people to a Gui version makes sense too.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: get exposure without shoot_half
« Reply #9 on: 25 / November / 2012, 14:35:34 »
Whoa! Lots of suggestions! Thanks everyone!

I will try out the ptp stuff soon... I use mostly the command line in Linux. I have some other ptp questions... but I'll get to those later.

Quote
The attached script attempts to go into manual focus mode with the above trick. If it works, it sets the focus based on a parameter, and does another half_shoot. If you're not in manual focus mode when you do set_focus(d), it doesn't work, or crashes the camera on my sx260.

The Focuser script seems to work! Thanks! I will muck with it some and get it integrated.


Quote
After much experimenting, I figured out the solution for tV and sV

I tried your snippet and it works to. My sequence above only worked because I did a release on the shoot_half... that let me then set the tv. But your snippet makes it so that release is not necessary.

Thank again!


 

Related Topics