Shot Histogram Request - page 15 - CHDK Releases - CHDK Forum

Shot Histogram Request

  • 467 Replies
  • 129032 Views
*

Offline lapser

  • *****
  • 1093
Over 10 Thousand Pictures!
« Reply #140 on: 13 / March / 2013, 16:30:41 »
Advertisements
I left the SX50 running overnight hooked to A/C power without a script error, using wait_shot_ready(). It worked! It may be the most boring time lapse ever, but it demonstrates that the program is ready to take out in the field somewhere and do some real time lapsing.

I also updated my keep the backlight off logic, and got it working really well. I decided to butcher kbd.c this time, instead of action_stack, so the turn off backlight call will come sooner after the camera turns it on.

This way, I discovered that the backlight stays off completely when used with "shoot_full_only" in single shot mode. There's a brief flash with my time lapse script in continuous mode. I'll do some new power tests, but I think this will save a significant amount of power over trying to keep the backlight off with Lua or Basic alone. Here's the backlight code:

Code: [Select]
//kbd.c
long kbd_process()
{
    static int key_pressed;

    if(camera_info.state.backlight_off)
    {
        if (camera_info.state.state_kbd_script_run)TurnOffBackLight();
        else
        {
          camera_info.state.backlight_off=0;
          TurnOnBackLight();
        }
    }

//luascript.c
static int luaCB_set_backlight( lua_State* L )
{
  camera_info.state.backlight_off = (luaL_checknumber(L,1)==0);
  if (!camera_info.state.backlight_off) TurnOnBackLight(); //turns off in kbd.c
  return 0;
}


//in lua_script_run()
  if (Lres == LUA_YIELD)return SCRIPT_RUN_RUNNING; //yielded
  camera_info.state.backlight_off=0; //error or finished script
  TurnOnBackLight(); //makes error visible

Here's the Lua script that's tests the backlight off code:

Code: (lua) [Select]
--[[
@title Shoot Test
--]]
bl=1 -- backlight on
print("<set> to toggle backlight")
print("<menu> to exit")
print("using shoot()")
repeat
  shoot()
  wait_click(1)
  if(is_key("set"))then
    bl=bitxor(bl,1) -- 0 or 1
    set_backlight(bl)
  end
until is_key("menu")

bl=1
set_backlight(1)

print("using shoot_full_only")
press("shoot_half")
repeat sleep(10) until get_shooting()
repeat
  sleep(2000)
  click("shoot_full_only")
  wait_click(1)
  if(is_key("set"))then
    bl=bitxor(bl,1) -- 0 or 1
    set_backlight(bl)
  end
until is_key("menu")


And finally, here's the most boring time lapse ever:
http://www.youtube.com/watch?v=f3y4dd4OXCo#ws
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Shot Histogram Request
« Reply #141 on: 13 / March / 2013, 17:24:16 »
I'll do some new power tests, but I think this will save a significant amount of power over trying to keep the backlight off with Lua or Basic alone.
Based on my testing here,

http://chdk.setepontos.com/index.php?topic=9049

you gain about 20% on you battery life by turning the backlight off.   I would expect results from your mods to be about the same.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #142 on: 13 / March / 2013, 19:51:25 »
you gain about 20% on you battery life by turning the backlight off.   I would expect results from your mods to be about the same.
You're probably right, but this way doesn't even flash the backlight in half_shoot. I'm shooting at 1 shot per second with no focusing or pre-shot metering, so maybe the backlight flashing will be a larger part of the power drain.

Anyway, this will let scripts keep the backlight off with just set_backlight now. I added the code to ubasic, and tested it with a basic script. I'll do some more checking and testing tomorrow, and submit a patch file for you to test, and possibly add to the trunk.

I'm off to climb a butte and see if I can get a shot of the comet and crescent moon in between clouds tonight.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #143 on: 14 / March / 2013, 21:22:30 »
Nice day but boring sunset on Spencer's Butte last night, so I turned the camera to time lapse the people, and got something more interesting. For one thing, dogs are very busy creatures!

No script interrupted errors, but I did have a slow ending of the script and strange behavior of the camera afterwards. That happened once before. I'm pretty sure it's related to stopping the script in the middle of build_shot_histogram(), and clearing some of the pointers or something while they're being used. That would trash random memory. It's pretty simple to prevent, so I'll add that code next.

I finished the keep backlight off code, including getting it to work with ubasic. reyalp didn't think it's worth putting in the trunk, so I'll drop it for now. I need it in my timelapse code because I have to use wait_shot_ready() instead of a Lua sleep loop to wait for the shot. This is the only way to avoid the script interrupt bug at the moment. So I can't keep the backlight off with just Lua.

By turning off the backlight in CHDK, the timing keeps it completely off between shots, which avoids the flashing seen with a Lua loop. I think this might be important for a camera in a car, as mentioned in this recent post:

I want to extend drivelapse.bas to turn off the LCD display to save battery and avoid distraction while the script is running (and then turn it back on when the script ends). Is this possible?
So the code is ready to fix this problem if it's needed.

Here's the time lapse from last night:

http://www.youtube.com/watch?v=am_JqGg7CeU#ws
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Offline reyalp

  • ******
  • 14082
Re: Shot Histogram Request
« Reply #144 on: 14 / March / 2013, 23:30:59 »

So the code is ready to fix this problem if it's needed.
If you post a patch, then it it would be available to anyone who want it, regardless of whether I think it should be in the trunk or not.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #145 on: 15 / March / 2013, 00:16:13 »
If you post a patch, then it it would be available to anyone who want it, regardless of whether I think it should be in the trunk or not.
That's a good idea. But now that I've figured out that the script interrupt bug is related to Lua yield(), and a way around it, my time lapse / shot meter code is working reliably. I think I'll work on cleaning up the code and improving my Lua time lapse script, and post the whole thing as one big patch and a finished script.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #146 on: 16 / March / 2013, 18:43:26 »
I cleaned up the time lapse script yesterday, adding a few more options to the parameter list. One was the option to enter the minimum and maximum ISO. I was using sv96, but those are hard numbers to figure out, so I changed it to enter ISO, and convert with my new conversion routines.

In order to be able to enter "Market" ISO, I had to convert it to "Real" sv96.

By setting the camera to ISO 100 (market), and running a script that does:
get_sv96()
I discovered that 100 Market is 411 sv96. If you then do:
sv96_to_iso(411)
you get 65 ISO, which is the "Real" ISO.

If you convert 100 (real) ISO to sv96,
iso_to_sv96(100)
you get 470. This is 59 more than 411, which is the sv96 offset to use. So here's how I get "real" sv96 from the "market" ISO input

@param z ISO Max
@default z 800
@param s ISO Min
@default s 100

svdiff=59 -- real to market difference
svmin=iso_to_sv96(s)-svdiff
svmax=iso_to_sv96(z)-svdiff

To print out the Market ISO for each shot, I use:
sv96_to_iso(sv+svdiff)

I've got some rounding error problems in my iso conversion I need to work on. Entering ISO 800 ends up ISO 802 after being converted to sv96 and back. So I think I need a scale factor for ISO, i.e. ISO 8000 for ISO 800, or maybe ISO 800000.

The sky was relatively clear for a few hours at sunset last night, so I hauled 2 big tripods, a Gorillapod, 3 cameras, external batteries, extra warm clothes, water, headlamp, and a cheeseburger up to the top of Spencer's Butte. Unfortunately, the ribbon of clouds on the western horizon blocked the view of the comet. Fortunately, the clouds were really beautiful.

http://www.youtube.com/watch?v=uRio1KM-LuM#
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Shot Histogram Request
« Reply #147 on: 17 / March / 2013, 05:19:42 »
Too bad you did not capture comet, yesterday I could capture a comet for the first time but I really struggled. With the naked eye is completely invisible without binoculars would not could to find. I made two pictures, one with the A590, and another through a telescope with the EOS 1100D.


*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #148 on: 17 / March / 2013, 12:30:37 »
I could capture a comet for the first time but I really struggled.
That makes me feel better. I never would have found the comet even if the horizon was clear, so at least I had a pretty cloud to catch in the time lapse.

I did try a time lapse of the moon with the SX50 at 50X zoom. The pistol grip ball head that came with the tripod isn't steady enough, especially since there was some wind blowing. I ordered the Manfrotto 486RC2 from Amazon. Here's the video:

http://www.youtube.com/watch?v=xFPNoiwaWsQ#ws
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline lapser

  • *****
  • 1093
Idea: wait_for("LuaFunc") function
« Reply #149 on: 17 / March / 2013, 12:49:59 »
Working around the Lua yield() bug with wait functions works great so far. But I had an idea of a way to generalize it so you don't need a different wait function for each test condition. What if you used lua_pcall() to call a Lua function from the action stack wait? The Lua function would return TRUE if the test condition was met, or FALSE to continue waiting. It would be equivalent to:

repeat sleep(10) until func()

you would call this with:

wait_for("func")

it could be modified to work like this:

wait_for("get_shooting",false)

As far as I know, pcall() doesn't do lua_yield() so it should work around the bug. A secondary benefit would be to make the lua script a little more concise when writing wait loops.

wait_for("reyalp_likes_it", false)
what_for("reyalp_says", no) --?
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics