How do get_dofinfo() and get_bv96() work? - General Help and Assistance on using CHDK stable releases - CHDK Forum

How do get_dofinfo() and get_bv96() work?

  • 4 Replies
  • 780 Views
How do get_dofinfo() and get_bv96() work?
« on: 20 / January / 2021, 21:58:04 »
Advertisements
I have lots of things working nicely with CHDKPTP, but I'm confused how these work.

I'm using an A640.

No matter what I've tried, I always get hyp_valid=false.

Here's an interactive session with CHDKPTP (camera is in record mode, on P setting):

Code: [Select]
con 23> shoot
con 24> luar return get_dofinfo()
25:return:table:{hyp_valid=false,eff_focal_length=45860,coc=6,aperture=12030,near=1277,min_stack_dist=29,dof=-1,focal_length=9565,hyp_dist=1277,far=-1,focus=65535,focus_valid=false}
con 25> luar return press("shoot_half")
con 26> luar return get_dofinfo()
27:return:table:{hyp_valid=false,eff_focal_length=45860,coc=6,aperture=12030,near=1277,min_stack_dist=29,dof=-1,focal_length=9565,hyp_dist=1277,far=-1,focus=65535,focus_valid=false}

I take a picture (shoot), check get_dofinfo() and get hyp_valid=false.

Then I try half-pressing, and while half-pressed try again. Still hyp_valid=false.

How do I get the camera to report hyp_valid=true?

I'm having similar problems with get_bv96().

The camera is in REC mode, I call get_bv96(), it returns 78.

Then I put my hand in front of the camera (so the lens gets no light), call get_bv96(), it again returns 78.

Then I tried it with half-press, and again, get 78 regardless of how much light is going in the camera.

I must be misunderstanding how things are supposed to work.

Advice?

----

Added - things that I thought were working OK, maybe aren't:

Code: [Select]
connected: Canon PowerShot A640, max packet size 512
con> luar return set_mf(1)
69:return:1
con 69> luar return set_focus(0)
70:return:true
con 70> luar return get_dofinfo()
71:return:table:{hyp_valid=false,eff_focal_length=35000,coc=6,aperture=11314,near=792,min_stack_dist=23,dof=-1,focal_length=7300,hyp_dist=792,far=-1,focus=65535,focus_valid=false}
con 71> shoot
con 72> luar return get_dofinfo()
73:return:table:{hyp_valid=false,eff_focal_length=35000,coc=6,aperture=11314,near=792,min_stack_dist=23,dof=-1,focal_length=7300,hyp_dist=792,far=-1,focus=65535,focus_valid=false}
con 73> luar return set_focus(65535)
74:return:true
con 74> luar return get_dofinfo()
75:return:table:{hyp_valid=false,eff_focal_length=35000,coc=6,aperture=11314,near=792,min_stack_dist=23,dof=-1,focal_length=7300,hyp_dist=792,far=-1,focus=65535,focus_valid=false}
con 75> shoot
con 76> luar return get_dofinfo()
77:return:table:{hyp_valid=false,eff_focal_length=35000,coc=6,aperture=11314,near=792,min_stack_dist=23,dof=-1,focal_length=7300,hyp_dist=792,far=-1,focus=65535,focus_valid=false}
con 77>

So it seems setting focus to 0 and to 65535 doesn't affect get_dofinfo() at all.

What's more, the two images (one at focus 0 and the other at 65535) appear to be focused identically.

What am I doing wrong here?


« Last Edit: 20 / January / 2021, 22:21:53 by Dave92F1 »

*

Offline reyalp

  • ******
  • 13450
Re: How do get_dofinfo() and get_bv96() work?
« Reply #1 on: 21 / January / 2021, 13:57:54 »
Code: [Select]
con 23> shoot
con 24> luar return get_dofinfo()
25:return:table:{hyp_valid=false,eff_focal_length=45860,coc=6,aperture=12030,near=1277,min_stack_dist=29,dof=-1,focal_length=9565,hyp_dist=1277,far=-1,focus=65535,focus_valid=false}
con 25> luar return press("shoot_half")
con 26> luar return get_dofinfo()
27:return:table:{hyp_valid=false,eff_focal_length=45860,coc=6,aperture=12030,near=1277,min_stack_dist=29,dof=-1,focal_length=9565,hyp_dist=1277,far=-1,focus=65535,focus_valid=false}
Each luar command is a separate script. Keys pressed inside a script are released when the script ends. Also, when you half press, you need to wait for the camera to actually update the values. So to run get_dofinfo() in half press, you'd want to use something like
Code: [Select]
=press'shoot_half' repeat sleep(10) until get_shooting() return get_dofinfo()
If you want to get Bv at the same time, you can return it in the same call
Code: [Select]
... return get_dofinfo(),get_bv96()

Quote
Then I tried it with half-press, and again, get 78 regardless of how much light is going in the camera.
It should update when you half press and wait for get_shooting(). If it doesn't, that would probably be a bug.


Quote
What's more, the two images (one at focus 0 and the other at 65535) appear to be focused identically.

What am I doing wrong here?
When the camera is in MF or AF lock, the focus should update immediately when you call set_focus(). So if you do
Code: [Select]
=set_mf(1)
=set_focus(100)
=set_focus(65535)
You should see the focus change dramatically. If it doesn't, set_mf() could be broken in this port. In that case, you can try set_aflock instead of set_mf. If set_mf is broken, I'd restart the camera before testing set_aflock.

The camera might not actually be able to focus at zero, but AFAIK most if not all cameras will focus at the nearest valid distance.

If the camera isn't in AF lock or MF, then set_focus only takes effect in half press, after the normal firmware AF has completed. To use that, you'd need to set it in the same script as the shot. If you're using the shoot CLI command, you can use the -sd and -sdmode options (use help shoot for details). If you're doing it in script, you'd use something like
Code: [Select]
=set_focus(1000) shoot()
Don't forget what the H stands for.

Re: How do get_dofinfo() and get_bv96() work?
« Reply #2 on: 21 / January / 2021, 16:10:59 »
Very, very helpful, and explains a lot. I will fiddle.

Re: How do get_dofinfo() and get_bv96() work?
« Reply #3 on: 22 / January / 2021, 21:32:23 »
Each luar command is a separate script.

That was a key insight - thanks again.

I'm able to set the shutter speed and aperture via CHDKPTP now, but I still am having trouble setting ISO.

I've tried set_sv96(), set_market_ISO(), and set_real_ISO(); none seem to affect the resulting photos.

And in each case the EXIF of the resulting .JPG shows:

exif["MakerNote ISO"]: (None) Proprietary=Auto @ None

(I'm using the Python package "exifread" to read the EXIF tags; this seems to be the only tag in the file related to ISO.)

The one thing that DOES affect ISO is set_iso_mode(), but that only allows selection of 80, 100, 200, 400, or 800. Whatever ISO is selected does affect the photo, but doesn't show up in the EXIF.

What's the recommended procedure for setting ISO gain?

I'm running an A640 in M (Manual) mode.

Also - is there a way to do a half-press and then "remoteshoot" from CHKPTP? Per your last post, the "remoteshoot" needs to be in the same luar line as the half-shoot. But I'm having trouble doing that. shoot() works OK in a script, but "remoteshoot" doesn't:

Code: [Select]
con 466> =set_focus(1000) shoot()
con 467> =set_focus(1000) remoteshoot
ERROR: :101: '=' expected near '<eof>'
user code: 1

con 468> =set_focus(1000) remoteshoot()
ERROR: :101: attempt to call global 'remoteshoot' (a nil value)
user code: 1
« Last Edit: 22 / January / 2021, 21:34:14 by Dave92F1 »


*

Offline reyalp

  • ******
  • 13450
Re: How do get_dofinfo() and get_bv96() work?
« Reply #4 on: 23 / January / 2021, 00:04:34 »
I've tried set_sv96(), set_market_ISO(), and set_real_ISO(); none seem to affect the resulting photos.
"set_market_ISO" and "set_real_ISO" do not exist. You should see an error if you attempt to use them.

The available functions are set_iso_mode, set_iso_real and set_sv96. They should all work unless the port is broken. As you've noticed, set_iso_mode works with the same values that appear in the UI (edit: except numbers below 50 are treated as IDs in CHDK ISO list, so 0 is auto, 1 is base ISO etc).

set_iso_real and set_sv96 do the same thing under the hood (that is, set_iso_real eventually calls set_sv96), the main difference is set_iso_real takes ISO units while set_sv96 takes APEX96 units. Like other overrides, they must be used in the same script that does the shot, and they are applied on the first half press after the call, or immediately, if the camera is already in halfpress.

Note that most cameras do not allow overriding ISO much outside the standard Canon range. You should be able to use overrides to set values in smaller steps (like setting ISO 123) or in some cases where the camera would normally limit the ISO range or force auto-ISO, but you shouldn't expect it to work beyond the minimum or maximum values available in the Canon UI.

Quote
exif["MakerNote ISO"]: (None) Proprietary=Auto @ None

(I'm using the Python package "exifread" to read the EXIF tags; this seems to be the only tag in the file related to ISO.)
See https://exiftool.org/forum/index.php?topic=2099.msg9213#msg9213
and https://www.exiv2.org/tags-canon.html

However, the tag value is not necessarily a reliable indicator of what the camera actually did when you use CHDK overrides. You should evaluate the actual resulting image to determine if the override is working. The isoinc.lua script included in CHDK/SCRIPTS/TEST can be used to test ISO overrides. It takes a series of shots and measures the raw levels.

CHDK ISO override works by putting the camera in auto-ISO mode and then setting the auto value, so you should expect to see that in the tags.

Quote
Also - is there a way to do a half-press and then "remoteshoot" from CHKPTP? Per your last post, the "remoteshoot" needs to be in the same luar line as the half-shoot. But I'm having trouble doing that. shoot() works OK in a script, but "remoteshoot" doesn't:

Code: [Select]
con 466> =set_focus(1000) shoot()
con 467> =set_focus(1000) remoteshoot
ERROR: :101: '=' expected near '<eof>'
user code: 1
remoteshoot is a chdkptp CLI command, not a CHDK Lua function. It runs its own set of complicated scripts on the camera (see lua/rlibs.lua in the chdkptp install). If you want to set exposure parameters, you should use the command line options like -sv=... to set ISO and -sd=... to set focus distance. See "help rs" for details.

If you need to do something not available through the standard command line options, you can use the -script to run your own script, but in that case your script must set everything.
« Last Edit: 29 / January / 2021, 12:59:21 by reyalp »
Don't forget what the H stands for.

 

Related Topics