A couple of Multicam doubts and general help - page 3 - General Help and Assistance on using CHDK stable releases - CHDK Forum

A couple of Multicam doubts and general help

  • 159 Replies
  • 77260 Views
*

Offline reyalp

  • ******
  • 14125
Re: A couple of Multicam doubts and general help
« Reply #20 on: 10 / November / 2019, 14:34:39 »
Advertisements
Code: [Select]
mc:cmdwait('call set_aflock=0 sleep(500)')
 mc:cmdwait('call press "shoot_half" sleep(200)')
Not sure how to do the rest...
Note set_aflock is function, so the correct Lua syntax is set_aflock(0)
The code Caefix posted appears to be ubasic, which has different syntax. I'm not clear what the code posted is supposed to do, pressing shoot_half and then waiting for get_shooting to be false will either have no effect (if the condition is reached before it becomes true) or result in an infinite loop.

Quote
Reyalp, regarding the crash after downloading/deleting images in rec mode. This is the error I got. I'm about to try a new version of the script with cmdwait('play') before downloading.
Code: [Select]
ERROR: call failed:MENU3.lua:25: attempt to call method 'disconnect' (a nil value)
Looks like you are using a version of multicam from before when I added disconnect, builds in the download section are a bit old. If you want to use the latest Lua files, you can go to https://app.assembla.com/spaces/chdkptp/subversion/source/HEAD/trunk/lua and click the download button next to "checkout" and use the contents of that zip to replace everything in chdkptp lua folder.

Or you could just remove the mc:disconnect line, you might get some error messages about the connections but they should be harmless if you are quitting anyway. Some other features and fixes in the current multicam might be useful though.

I'll try to get an actual current build up fairly soon.
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #21 on: 10 / November / 2019, 15:02:41 »

Code: [Select]
mc:cmdwait('call set_aflock=0 sleep(500)')
 mc:cmdwait('call press "shoot_half" sleep(200)')
With those two lines I got the AF to jiggle a bit and enter Half press mode. It's not what I really wanted, but at least if I send this afterwards:
Code: [Select]
  status,r=mc:cmdwait('call return get_focus_ok()') if status then for id,v in ipairs(r) do if v.failed then printf('%d: failed\n',id) else printf('%d %s\n',id,tostring(v.status.status[1])) end end endI get focus confirmation, which is not bad. As I said not what I really wanted, but it somehow did the job :)
Ok, I'll update multicam right away.
And if you say there's a new build coming... I'm not expecting you to do it at all, but just wanted to remind you this ;)
Quote
5- Ideally in the future (completely optional), once the cameras are on their final placement, I think it'd be great to have each camera's focus point saved in an external file, and recall it at the start of every session. But this is just dreamland material for me right now. Better focus on the other stuff
This would definitely be a good feature, I may be able to add support for it in multicam at some point.
I'll keep testing, thanks a million.

*

Offline reyalp

  • ******
  • 14125
Re: A couple of Multicam doubts and general help
« Reply #22 on: 10 / November / 2019, 17:59:31 »
With those two lines I got the AF to jiggle a bit and enter Half press mode. It's not what I really wanted, but at least if I send this afterwards:
Again, I don't think the code Caefix posted does anything you want, and again get_focus_ok() normally means the camera found something to focus on in AF mode.

It is only valid while half press is held and get_shooting has become true. The value isn't meaningful in MF mode, and almost certainly not in AF lock either.

What process do you want to use to set focus for your rig? I see few general options
1) Use Canon AF for each shot
2) Use Canon AF, but lock in the distance at the start of the session
3) Visually evaluate the focus distance for each cam using test shots or live view, and use CHDK overrides to maintain that focus distance

It sounds like your plan is to #2. I'm not sure this is a great improvement over #1, since cameras that focus badly will be out of focus for the whole session, but if AF works well it will be more consistent form shot to shot. You could potentially use focus targets of some kind (e.g. cards with black and white patterns you put at the same distance as the real subject) to make this work better if the cameras don't focus well on your subject.

#1 would be accomplished just by using mc:shoot without any focus related settings.

For #3, you'd probably want to start with AF, get the focus distance, shoot and evaluate the results, and adjust it for any cameras without acceptable focus. If your subjects are always at similar distance and not super close to the cameras, you might be able to use the same values between sessions.
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #23 on: 10 / November / 2019, 18:42:51 »
Number 3 would be the ideal option, no doubt. But given my lack of skill, I think that for the first stages I could dodge the bullet by using mc:shoot with option 1 or 2. I'd try to create the best conditions for cameras to set focus properly, but in the future I'd need a more reliable method, hence my idea of saving focus distances for each camera to a file, and loading them before each session/scenario.
There are just two possible scenarios, full body or face scan, if the distances are mantained regardless of the focal length/zoom, I could use the same table of distances for both, or have two different sets. But focus wise, it's not going to be a very variable thing, since cameras and subject will be locked in place. Exposure will be constant too. I may need to change zoom values (and an appropiate exposure compensation if needed) depending on the scenario, but that would be it.
Regarding the rest of the workflow, everything is working fine for now (with just 4 cameras). I'll see which new problems arise when more cameras are added. I suspect they'll be more hardware based... Having them properly positioned, reliably shutting them down and turning back on, some of them are still battery based so they'll have to be unmounted from the rig every once in a while to recharge, issues with static, USB hub and communication problems, etc... But software/scripting wise, it's all looking good for now. :)
BTW, once I get the whole system running I'll be posting the final scripts here for anyone to use. Even if they're probably dumb-simple... But maybe helpful to someone. :)
« Last Edit: 10 / November / 2019, 18:45:25 by ikercito »

*

Offline reyalp

  • ******
  • 14125
Re: A couple of Multicam doubts and general help
« Reply #24 on: 10 / November / 2019, 19:14:40 »
For option 2, I'd recommend one of the options I posted in https://chdk.setepontos.com/index.php?topic=13917.msg141675#msg141675

If your rig has all the cameras roughly the same distance from the subject (i.e the cameras are an a ring several meters in diameter), it may also be sufficient to just use the same same focus distance for every cam. These cameras tend to have a deep DOF, especially at wide angle. In that case, you can just use the sd option in mc:shoot(), like

Code: [Select]
mc:shoot({sd=2000})
The distance is in millimeters, so the above would be a for a subject 2 meters from the cameras.

Note this requires the updated Lua files mentioned earlier.

I'm still thinking about how to implement option #3.

edit:
I don't have one of these big multicam rigs, or a workflow for this kind of 360 capture, so it's helpful to have input from people who do.
« Last Edit: 10 / November / 2019, 19:37:43 by reyalp »
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #25 on: 10 / November / 2019, 20:36:42 »
I don't have one of these big multicam rigs, or a workflow for this kind of 360 capture, so it's helpful to have input from people who do.
I don't have it... yet, but I'm thinking ahead. Hopefully during this week I'll finally move in and start building it. I can foresee that the biggest problems will be practical/hardware related: power and camera management (reliable supply, turning on/off, issues related to USB connections, etc...),  FOV (might need to reposition cameras depending on the scenario, but mostly face scans for now), focus and image quality (top of the list priority).
I think I could be able to set a couple of diferent groups of cameras, depending on their focus distance, and set it accordingly with mc:shoot({sd=2000})
How difficult would be to add a prompt to input certain values/parameters in some of the options? Here's the code i'm using right now (needs refining, but works for now)

Code: [Select]
mc=require('multicam')
repeat
 print('1) START&SYNC, 2) FOCUS, 3) FOCUS CHECK, 4) SHOOT (w/params), 5) SHOOT, 6) DOWNLOAD 7) SHUTDOWN REBOOT')
 local option = cli.readline('mc>')
 if option == '1' then
  mc:connect({list='cams.txt'})
  mc:start()
  mc:cmd('id')
  mc:cmdwait('rec')
  mc:init_sync()
 elseif option == '2' then
  mc:cmdwait('call set_aflock(0) sleep(500)') --- This option is temporary, needs refining and/or adding suggested focus distance from file
  mc:cmdwait('call press "shoot_half" sleep(200)')
  mc:cmdwait('call set_aflock(1) sleep(500)')
 elseif option == '3' then
  status,r=mc:cmdwait('call return get_focus_ok()') if status then for id,v in ipairs(r) do if v.failed then printf('%d: failed\n',id) else printf('%d %s\n',id,tostring(v.status.status[1])) end end end
 elseif option == '4' then ---A prompt here would be ideal, setting exposure for all cams with a given EV value (for simplicity) or specific values?
  mc:shoot({tv=exp.shutter_to_tv96(1/50), sv=exp.iso_to_sv96(50),av=exp.f_to_av96(4)})
 elseif option == '5' then 
  mc:shoot() -- Simple, but does it mantain focus distance from option 2?
 elseif option == '6' then
  mc:cmdwait('play')
  mc:download_images({dst='c:/download/TEST01/CAM${id}/_IMG_${shotseq}${ext}',delete=true}) -- A prompt to set different folder name each time would be ideal
 elseif option == '7' then
  mc:cmdwait('play')
  mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
 elseif option == '8' then
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) reboot()')
  mc:disconnect()
 end
until option=='8'


EDIT: Yes, cameras will be roughly at the same distance in 360 degrees, not always at wide angle (may need to zoom in to 50mm or more for face scans) but focus distance will be permanent once they're placed in the rig.
« Last Edit: 10 / November / 2019, 20:39:54 by ikercito »

*

Offline reyalp

  • ******
  • 14125
Re: A couple of Multicam doubts and general help
« Reply #26 on: 11 / November / 2019, 16:51:17 »
How difficult would be to add a prompt to input certain values/parameters in some of the options? Here's the code i'm using right now (needs refining, but works for now)
You can use cli.readline at other points, so you could do something like
Code: [Select]
local shutter=cli.readline('shutter speed>')
mc:shoot({tv=exp.shutter_to_tv96(tonumber(shutter))})
A couple notes:
readline returns a string. The "tonumber" above turns it into a number, but it won't handle fractions so you'd have to use 0.02 instead instead of 1/50. To handle fractions, you'd need code like in cli.lua  cli:get_shoot_common_opts

In your code, only option 8 will quit, but probably you want 7 to quit as well. You can put break in any of the if  / elseif block to exit the loop immedately, like
Code: [Select]
elseif option == '7' then
  mc:cmdwait('play')
  mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
  break
 elseif option == '8' then
...
until option=='8'
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #27 on: 12 / November / 2019, 08:36:10 »
Ok, first the easy one... Works great
Code: [Select]
elseif option == '4' then        ---------SHOOT w/FOCUS DIST
  local dist=cli.readline('Focus Dist>')
  mc:shoot({sd=dist})

Now, the not so easy one. How should I insert the readline value into the path? This just creates a folder named 'folder' in the download path (i was somehow expecting this to happen :( )
 
Code: [Select]
elseif option == '6' then        ---------DOWNLOAD
  local folder=cli.readline('Folder>')
  mc:cmdwait('play')
  mc:download_images({dst='c:/download/folder/CAM${id}/_IMG_${shotseq}${ext}',delete=true})

Sorry to ask such basic questions, I'm slowly learning but there's still a lot to improve.
And to complicate things further... This is just optional and probably rarely used option. But if I were to insert multiple values in the shoot function, it should be something like this, right?
Code: [Select]
elseif option == '4' then        ---------SHOOT w/values
  local dist=cli.readline('Focus Dist>') fnum=cli.readline('F number>') shutter=cli.readline('Shutter speed>') ISO=cli.readline('ISO>')
  mc:shoot({sd=dist, tv=exp.shutter_to_tv96(tonumber(shutter)), sv=exp.iso_to_sv96(ISO),av=exp.f_to_av96(fnum)})

There might be some adjustments needed in order to convert the inserted values to a proper format (I still don't understand APEX96 numbers, is there any table or list?). But the structure is somehow OK, right?
I think I can adapt to the required format and avoid having to dig deeper into cli:get_shoot_common_opts stuff... For now, the whole menu system is working way better than I initially expected. :)

« Last Edit: 12 / November / 2019, 13:21:12 by ikercito »

*

Offline reyalp

  • ******
  • 14125
Re: A couple of Multicam doubts and general help
« Reply #28 on: 12 / November / 2019, 13:58:47 »
Now, the not so easy one. How should I insert the readline value into the path? This just creates a folder named 'folder? in the download path (i was somehow expecting this to happen :( )
Code: [Select]
elseif option == '6' then        ---------DOWNLOAD
  local folder=cli.readline('Folder>')
  mc:cmdwait('play')
  mc:download_images({dst='c:/download/folder/CAM${id}/_IMG_${shotseq}${ext}',delete=true})
Sorry to ask such basic questions, I'm slowly learning but there's still a lot to improve.
No problem, you're learning programming in a roundabout way ;). The stuff in '' or "" in Lua is a string. The value from readline is also a string. In Lua, the concatenate operator .. is used to join strings together, like:
Code: [Select]
  mc:download_images({dst='c:/download/'..folder..'/CAM${id}/_IMG_${shotseq}${ext}',delete=true})

Quote
And to complicate things further... This is just optional and probably rarely used option. But if I were to insert multiple values in the shoot function, it should be something like this, right?
Code: [Select]
elseif option == '4' then        ---------SHOOT w/values
  local dist=cli.readline('Focus Dist>') fnum=cli.readline('F number>') shutter=cli.readline('Shutter speed>') ISO=cli.readline('ISO>')
  mc:shoot({sd=dist, tv=exp.shutter_to_tv96(tonumber(shutter)), sv=exp.iso_to_sv96(ISO),av=exp.f_to_av96(fnum)})
There might be some adjustments needed in order to convert the inserted values to a proper format (I still don't understand APEX96 numbers, is there any table or list?). But the structure is somehow OK, right?
That approach should be OK. You probably want to use tonumber on the ISO and fnum values as well. I would use one
local whatever = readline whatever
line for each value. local means that name is only known inside the surrounding block (if / elseif in this case), so if you used say shutter somewhere else, it wouldn't interfere.

Also, if you are using the recent multicam lua files, you can use svm= instead of sv= for ISO. This will use the normal "market" as displayed in the camera UI.

From a user interface perspective, this could be a bit annoying since there's no way to not shoot if you make a mistake in one of the values. Two possible ways to handle this:
1) Have a separate menu item to enter the values. At the top of the file, set your default values, like
Code: [Select]
shutter=1/50
ISO=50
fnum=4
dist=nil
Then have a menu item like
Code: [Select]
elseif option == '9' then
 dist=tonumber(cli.readline('Focus Dist>'))
 if dist == 0 then
   dist = nil
 end
 fnum=tonumber(cli.readline('F number>'))
 shutter=tonumber(cli.readline('Shutter speed>'))
 ISO=tonumber(cli.readline('ISO>'))
...
And have your shoot command, just refer to those names like your example.
The if dist == 0 is there to allow you to get back to autofocus (sd=nil, meaning not set). The advantage of this is if you want multiple shots with the changed values, they stay until you quit or change them.

2) Have a final prompt to confirm after reading the values, like
Code: [Select]
if cli.readline('shoot (y/n)>') == 'y' then
  mc:shoot({sd=dist, tv=exp.shutter_to_tv96(tonumber(shutter)), sv=exp.iso_to_sv96(ISO),av=exp.f_to_av96(fnum)})
end

To understand the APEX96 numbers, I'd recommend this description of APEX http://dougkerr.net/Pumpkin/articles/APEX.pdf
APEX96 is just the same values multiplied by 96.
Or, if the theory and math isn't your thing, chdkptp can print out conversion tables, like
Code: [Select]
!exp.print_tv_table()
!exp.print_av_table()
!exp.print_sv_table()
The shutter one also gives you decimal values of the normal fractions like 1/50 etc.

Finally, I noticed your default is ISO 50. CHDK ISO overrides do not generally allow you to go significantly lower than what's available in the Canon UI, so that's probably not useful.

edit:
typos  :-[
« Last Edit: 13 / November / 2019, 22:26:00 by reyalp »
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #29 on: 13 / November / 2019, 18:11:20 »
you're learning programming in a roundabout way ;) .
Indeed, and what a ride...!  :D
I got in the new studio today, been really busy and couldn't test anything new yet. Tomorrow starts the big build and scaling the tests to the whole array of cameras. Will start small and add new cameras slowly.
I see your point in having a prompted confirmation for shooting, I didn't really think about it before, so thanks for suggesting it! I'll keep you posted on the development  :)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal