Comparison: CHDKPTP vs Canon's RemoteCapture - page 6 - RAW Shooting and Processing - CHDK Forum supplierdeeply

Comparison: CHDKPTP vs Canon's RemoteCapture

  • 129 Replies
  • 34746 Views
*

Offline reyalp

  • ******
  • 13942
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #50 on: 26 / August / 2012, 14:39:49 »
Advertisements
This is interesting.  Thus in summary this forces chdkptp to give me access to functions I wrote in myfile.lua, correct?
Yes, require is roughly analogous to #include in C. See http://www.lua.org/manual/5.1/manual.html#5.3

In chdkptp revision 286, I added a module with conversions from traditional shutter, ISO and aperture values to/from APEX and APEX 96. You can use this with
exp=require('exposure')
and then you can set the shutter and iso using
Code: [Select]
!con:exec('set_tv96_direct('..exp.shutter_to_tv96(1/100)..')')
!con:exec('set_sv96('..exp.iso_to_sv96(80)..')')
Obviously, you could also use those in in your my_set_tv functions.

I also added the log2 function to util.lua

If you want to use these, you will need to get the most recent util.lua and exposure.lua. I will probably put up a new snapshot build today.
Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #51 on: 26 / August / 2012, 15:18:57 »
Very kind of you to do this, as I have been dreading what to do with ISO on my own // please advise me when you have the new build up.   For folks needing Av, perhaps it might be a good time too, if applicable.

With the code you offered earlier I put into a myfile.lua, I cleared out all the error messages during chdkptp load, so that looks OK, and, an execute also runs my functions, it seems.

But I have a little snag ....

The camera is set to MANUAL and Tv to Canon 15sec on PUP.  So if I say !shoot(), it works, ie it takes a 15-second exposure. 

Next if I put this code in myfile.lua ............

Code: [Select]
function test_shoot()
     con:exec('shoot()')
end

log2=function(n)
   return math.log(n)/0.69314718055995
end

function shootat_Tv(n)
   local tv96=string.format('%d',96*-log2(n))
   printf("set tv96 %s\n",tv96)
   con:exec('set_tv96_direct('..tv96..')')
   con:exec('shoot()')
end

... and say !test_shoot(), that works too, running the 15s Canon exposure as expected.

However,  if I say !shootat_Tv(1) in an attempt to override the Canon 15s with a CHDK 1s and shoot, the camera LCD blinks with your message window, but nothing more happens. 

Console is:
   > !shootat_TV(1)
set tv96 0

Also if I remove the con:exec('shoot()') statement, behavior is the same.  There are no other messages on the console.


>> I found an S90, with luck it should be here by next weekend.  In the meantime I will be learning lua.

*

Offline reyalp

  • ******
  • 13942
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #52 on: 26 / August / 2012, 15:58:02 »
However,  if I say !shootat_Tv(1) in an attempt to override the Canon 15s with a CHDK 1s and shoot, the camera LCD blinks with your message window, but nothing more happens. 
This is probably because you are using the two exec commands without waiting. Exec by default works like the 'lua' command, i.e. returns control as soon as the command is sent, rather than when it completes. This probably means your second exec is hitting a "script already running" error, which you don't see because you aren't doing any error checking.

If you replace exec with execwait, it should only return after the command finished.

Note that you could also combine the two commands, e.g.
Code: [Select]
con:exec('set_tv96_direct('..tv96..');shoot()')

As an aside, if you are using manual mode, you might want to use set_user_tv96 etc instead of set_tv96_direct. The *user commands set the same values that can be entered manually in the firmware. _direct should work, but _user may make it more likely exif etc are correct.

Another aside, for real code you probably want some error checking. Most chdkptp lua functions return
status, [error message | result ]
in other words, if status if false, the second return value is the error message, otherwise it's whatever value would be returned by the function.

If you just want to print the status, you can use cli:print_status, like this
Code: [Select]
cli:print_status(con:exec('set_tv96_direct('..tv96..');shoot()'))
If you want to do something with the results then you'd use something like
Code: [Select]
local status, msg=con:exec('set_tv96_direct('..tv96..');shoot()')
if not status then
 printf("error %s",msg)
else
...
If you use execwait, it defaults to acting like remote procedure call to the camera, returning status followed by any values returned by the camera code. So for example you can do
status,bv96=con:execwait('return get_bv96()')
to get the "brightness value" from the camera to chdkptp lua code.

You can customize the behavior of exec/execwait extensively by passing a table of options after the code. These are documented in chdku.lua. execwait is actually just a wrapper that sets the wait option to exec
Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #53 on: 26 / August / 2012, 16:12:09 »
Yup, I replaced the line  ...
    con:exec('set_tv96_direct('..tv96..')')
with
   con:execwait('set_tv96_direct('..tv96..')')

... and said !shootat_Tv(1)  That took the shot this time // but // the exposure was Canon's 15 sec, not CHDK 1s.  So there is an improvement but we're not there yet.

Thanks for the detailed informative reply.  I will read it closely and try the ideas you propose.


*

Offline reyalp

  • ******
  • 13942
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #54 on: 26 / August / 2012, 16:15:38 »
... and said !shootat_Tv(1)  That took the shot this time // but // the exposure was Canon's 15 sec, not CHDK 1s.  So there is an improvement but we're not there yet.
Try using set_user_tv96
Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #55 on: 26 / August / 2012, 16:25:48 »
Very very nice // that worked.  In fact, the Canon display changed to 1 s after the shot.  And as you mentioned .. exif data ...  that too, is necessary.

Next, ISO, then we can officially start RemoteCapture<->CHDKPTP comparison testing // cool.  I'm out for a dinner bite but will be back on this afterwards.

Talk to you later.

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #56 on: 26 / August / 2012, 19:49:27 »
Minor gremlin we ought to look at ...

!shootat_Tv(1) results in a 1s shot with PUP preset of 15s // OK.  OSD shows 1" afterwards.  Looks normal.

!shootat_Tv(2 | 4 | 8 etc) results in the present OSD Tv instead of the CHDK Tv.   Hmmm.
 
!shootat_Tv(values less than 1s) seems to shoot the camera faster than 1s (I cannot be certain of speed accuracy), but the OSD does not change, remaining at the same value it was prior to shot.

Console
   for 2s result= -95
   for 4s result= -191
   for 1/2s result= 95
   for 1/8s result= 287

Ideas?

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #57 on: 26 / August / 2012, 20:12:18 »
Update ... the way it looks after several more attempts at isolating the problem is !shootat_Tv(1) is the only value that overrides the current OSD Tv, and shoots at 1s.  If I try any other value, it shoots at the Tv currently displayed on the OSD.


*

Offline reyalp

  • ******
  • 13942
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #58 on: 26 / August / 2012, 20:18:06 »
Minor gremlin we ought to look at ...
"We" ? You are responsible for debugging your own code, thanks ;)
Quote
Console
   for 2s result= -95
   for 4s result= -191
   for 1/2s result= 95
   for 1/8s result= 287
Without testing, I suspect the Canon OSD isn't updating when the values don't exactly match a value known to the Canon UI. E.g. 2s should be -96. The difference between -95 and -96 is very small (2 vs 1.985...), but the Canon firmware doesn't have a display for that value.

If you use the code I added in revision 286, the results will be slightly more accurate. They still may not exactly match the firmware values.

edit:
It's also possible set_user_tv96 only accepts values known to the camera. That should be something you can check by experiment.

edit:
OK, I verified in the source that _user only accepts values in the shutter speed table.

edit:
if you set the propcase directly, that should work for non standard values, e.g.
Code: [Select]
con:execwait("props=require('propcase');set_prop(props.USER_TV,<your tv96 value>)")
« Last Edit: 26 / August / 2012, 20:30:42 by reyalp »
Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: Comparison: CHDKPTP vs Canon's RemoteCapture
« Reply #59 on: 26 / August / 2012, 20:30:08 »
I did not know I was doing this in isolation ... after all, it would have been impossible for me alone to debug the original A/R caveat // just being friendly :)

Quote "I suspect the Canon OSD isn't updating when the values don't exactly match a value known to the Canon UI. E.g. 2s should be -96"

For now, my "update" is more accurate and stands.  I will hardcode -92 and let you know what happens.

Is r286 available?

 

Related Topics