Shot Histogram Request - page 16 - CHDK Releases - CHDK Forum supplierdeeply

Shot Histogram Request

  • 467 Replies
  • 129049 Views
*

Offline reyalp

  • ******
  • 14082
Re: Shot Histogram Request
« Reply #150 on: 17 / March / 2013, 16:15:58 »
Advertisements
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.
I don't like this at all. It's ugly and pcall imposes severe limits on what chdk functions the called code can use.

Fixing the bug would be a much better solution. If the bug is in fact caused by repeated yields, that should be a significant step toward nailing down the root cause.
Quote
A secondary benefit would be to make the lua script a little more concise when writing wait loops.
This is not a benefit, it's the opposite. Making scripts use less characters is not a goal of the script inteferace. Wait loops are a clear description of what is going on, and are far more flexible than your approach.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #151 on: 17 / March / 2013, 19:09:23 »
I don't like this at all. It's ugly...
Ha, I knew you'd say that. My job is to throw up new ideas. Your job is to tell me to throw away what I throw up.

And Jo mamma's ugly too!  :D
Quote
Fixing the bug would be a much better solution. If the bug is in fact caused by repeated yields, that should be a significant step toward nailing down the root cause.
Agreed.

Will you take a look at this Lua bug report and see if you think it could be related?

http://www.lua.org/bugs.html#5.2.0-4
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline srsa_4c

  • ******
  • 4451
Re: Shot Histogram Request
« Reply #152 on: 17 / March / 2013, 19:43:31 »
Working around the Lua yield() bug
... it seems to be a bug in lua yield(). I'll see if I can try Phils lua updated branch when I get the time.
I hope you don't mind my question, but have you tried that branch already?

The bug you're mentioning has this note:
Quote
Wrong handling of nCcalls in coroutines.
reported by Alexander Gavrilov on 18 Apr 2012. existed since 5.2.0. fixed in 5.2.1.

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #153 on: 18 / March / 2013, 00:11:06 »
I hope you don't mind my question, but have you tried that branch already?
Phil's branch is still Lua 5.1.something. Apparently, updating to 5.2 would require a lot more changes.

I think Phil's going to merge his branch into the trunk soon, so I was kind of waiting for that to happen to apply my time lapse patches. Fixing the bug has moved down the priority list a little since I discovered the work around.

I appreciate the suggestion.
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 #154 on: 18 / March / 2013, 00:50:45 »
http://www.lua.org/bugs.html#5.2.0-4
I don't think that bug applies to the 5.1.x code (hence the "existed since 5.2.0" comment), but I could be wrong.
Don't forget what the H stands for.

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #155 on: 18 / March / 2013, 01:51:11 »
I don't think that bug applies to the 5.1.x code (hence the "existed since 5.2.0" comment), but I could be wrong.
Thanks, I didn't notice that. I think you're right.

There's a bug in 5.1.3 that could be the culprit:
http://www.lua.org/bugs.html#5.1.3-2

Since Phil updated from 5.1.3 to 5.1.5, this bug should be fixed in his branch, so it's worth testing. How soon do you think it will be until Phil merges the 5.1.5 branch into the trunk?

4. Updated Lua to version 5.1.5 (Feb 2012 release) from 5.1.3 (Jan 2008 release).
I also looked at 5.2; but the changes are much more substantial so will take a lot more effort to update.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Shot Histogram Request
« Reply #156 on: 18 / March / 2013, 03:06:42 »
How soon do you think it will be until Phil merges the 5.1.5 branch into the trunk?

Not for a while I'm afraid. Work getting in the way at the moment.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline lapser

  • *****
  • 1093
Re: Shot Histogram Request
« Reply #157 on: 18 / March / 2013, 11:15:17 »
Not for a while I'm afraid. Work getting in the way at the moment.
OK, I'll test that branch as soon as I finish what I'm working on (setting the metering area using draw_rect)

Speaking of that, I'm planning to save the shot meter area data in:

A/CHDK/DATA/Shot_Meters.dat

Is that the right place?

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos


*

Offline srsa_4c

  • ******
  • 4451
Re: Shot Histogram Request
« Reply #158 on: 18 / March / 2013, 20:52:50 »
I'm planning to save the shot meter area data in:

A/CHDK/DATA/Shot_Meters.dat

Is that the right place?
I think you can create a new directory in A/CHDK. Don't forget that your cameras can't handle long filenames, and that there's a limit (32 characters?) on path + filename length.

*

Offline lapser

  • *****
  • 1093
Lua function for drawing shot meter areas
« Reply #159 on: 18 / March / 2013, 21:35:13 »
I think you can create a new directory in A/CHDK. Don't forget that your cameras can't handle long filenames, and that there's a limit (32 characters?) on path + filename length.
Thanks. I just finished the lua function that will set the shot meter areas. You can look through the script to see what the keys do, but this is basically how it works.

up,down,left,right:  move or grow the metering rectangle
set: toggles between move and grow
zoom: change step size to 1 or 10
display: moves to next meter (4 max)
half_shoot: starts over
menu: exits and prints metering areas (percent)

Code: (lua) [Select]
--[[
@title Draw Test
--]]

function get_meters()
  local move=262 --green
  local grow=259 --red
  local nmeters
  local imeter -- current
  local meters=nil
  local i
  local mode
  local step
  repeat
    if(meters==nil)then
      meters={30,30,70,70, 30,30,70,70, 30,30,70,70, 30,30,70,70}
      nmeters=1
      imeter=1
      mode=move
      step=10
    end
    local xd=0
    local yd=0
    local step_string=string.format("%2d",step)
    draw_clear()
    repeat
      draw_string(0,0,step_string,mode,257)
      i=1
      local cmeter
      for cmeter=1,nmeters do
        local ax1=(meters[i]*359+50)/100
        local ay1=(meters[i+1]*239+50)/100
        local ax2=(meters[i+2]*359+50)/100
        local ay2=(meters[i+3]*239+50)/100
        local color=271 -- yellow
        local bcolor=256 -- clear
        if(imeter==cmeter)then
          color=mode
          bcolor=257 -- black
        end
        draw_rect(ax1-1,ay1-1,ax2+1,ay2+1,257,3)
        draw_rect(ax1,ay1,ax2,ay2,color)
        draw_string((ax1-5+(ax2-ax1)/2),(ay1-6+(ay2-ay1)/2),cmeter,color,bcolor)
        i=i+4
      end
      wait_click(200)
    until not is_key("no_key")
    if(is_key("menu"))then break end
    if(is_key("set"))then
      if(mode==move)then mode=grow else mode=move end
    elseif(is_key("left"))then
      xd=-step
    elseif(is_key("right"))then
      xd=step
    elseif(is_key("up"))then
      yd=-step
    elseif(is_key("down"))then
      yd=step
    elseif(is_key("zoom_in"))then
      step=10
    elseif (is_key("zoom_out"))then
      step=1
    elseif (is_key("shoot_half"))then
      meters=nil -- start over
    elseif (is_key("display"))then
      imeter=imeter+1
      if(nmeters<4)then nmeters=nmeters+1 end
      if(imeter>4)then imeter=1 end
      step=10
      mode=move
    end
    if((xd~=0)or(yd~=0))then
      i=(imeter-1)*4+1
      local x1=meters[i]
      local y1=meters[i+1]
      local x2=meters[i+2]
      local y2=meters[i+3]

      x2=x2+xd
      y2=y2+yd
      if(mode==move)then
        x1=x1+xd
        if(x2>100)then
          x1=x1+100-x2
          x2=100
        elseif(x1<0)then
          x2=x2-x1
          x1=0
        end

        y1=y1+yd
        if(y2>100)then
          y1=y1+100-y2
          y2=100
        elseif(y1<0)then
          y2=y2-y1
          y1=0
        end
      else -- mode==grow
        if(x2>100)then x2=100 end
        if(y2>100)then y2=100 end
      end
      if(x2<=x1)then x2=x1+1 end
      if(y2<=y1)then y2=y1+1 end
      meters[i]=x1
      meters[i+1]=y1
      meters[i+2]=x2
      meters[i+3]=y2
    end
  until false
  for imeter=1,nmeters do
    i=(imeter-1)*4+1
    print(meters[i],meters[i+1],meters[i+2],meters[i+3])
  end
end

get_meters()

EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

 

Related Topics