CHDK Forum

Using CHDK => General Help and Assistance on using CHDK stable releases => Topic started by: ikercito on 24 / October / 2019, 12:52:06

Title: A couple of Multicam doubts and general help
Post by: ikercito on 24 / October / 2019, 12:52:06

Hi guys,


I'm finally ready to undertake my new iteration of a multicam 3D scanner project. Got the space, got the hardware and I'm ready to start building it (for the third time). However (as it was pointed before in my other threads) I have no coding skills at all. I'm trying really hard, but I'm desperate for some help.


In my previous attempts, with as many as 15 cameras, a "hardware" based approach was used thanks to the help from waterwingz and his usbptp.lua script. Cameras were manually turned on, autoloaded the script, and were shot powering up and down the usb hubs that connected them, once finished shots were dowloaded manually to PC. Pros: simple Cons: unreliable, time consuming, a PITA...


So, after a long research I'm finally coming to terms with the use of CHDKPTP and multicam.lua in order to make it more reliable. I've managed to wire 3 cameras (SX150IS) for testing (the rig will have 30, mostly SX150IS and a few smaller P&S Powershot A2300, A2400, A2600...) and initial tests have been succesful.


I have these simple commands under control
There is an examples in the top of the multicam.lua source file
Code: [Select]
experimental code for shooting with multiple cameras
not optimized for best sync, lots of loose ends
usage:
!mc=require('multicam')
!mc:connect()
!mc:start()
!return mc:cmdwait('rec')
!return mc:cmdwait('preshoot')
!return mc:cmdwait('shoot')
!return mc:cmdwait('play')
!mc:cmd('exit')


Even managed to shoot using mc:init_sync() and mc:testshots, like this:
!mc:testshots{tv=96,sv=411,nshots=2}
would take 2 shots with a 1/2 second exposure at about ISO 100.


And downloaded using this, even though I don't undertand a thing from that line... I just managed to modify the path to my hard drive
If you want to the CLI mdownload command instead of figuring out the API parameters, you could do it like this
Code: [Select]
!for i,lcon in ipairs(mc.cams) do con=lcon cli:print_status(cli:execute('mdl A/DCIM /some/path -fmatch=%.JPG$')) end
Some day I'd like to integrate shoot and download into multicam, but I haven't got to it yet.


So, all in all, I've learned a lot so far. I'm starting to understand CLI, CHDKPTP, camera based scripts and the likes. Been around the forum digging for info, but it's tricky (i have more than 30 tabs open right now with different bits and pieces of info that I cannot still understand), some of it is outdated (i know i should better be using mc:download_images() instead, but despite having the syntax https://chdk.setepontos.com/index.php?topic=11667.msg114920#msg114920 (https://chdk.setepontos.com/index.php?topic=11667.msg114920#msg114920) i am unable to figure out how to write a single line)


So here are a few areas where i'd like to ask for help:


- The use of mc:download_images() to retrieve the images and have them separated to different folders with the camera name (or serial), to keep them organized
- Naming the cameras, in order to make it easier to debug possible errors or send individual commands. And somehow, make these names persistent from session to session. Optional (making groups of cameras)
- Setting a few basic parameters on cameras (or groups of cameras), like exposure or focus. I've used testshots for this, but couldn't figure out how APEX96 units work.
- And last creating a set of BAT executables to perform the basic functions, instead of writing code line by line (I'm a newbie and make lots of mistakes). I think cmdwait will need to be used extensively isn't it? But what would be the general shape of such BAT file?


If anyone could provide a bit of guidance I'll be more than grateful. I'm doing the effort to learn, but my coding skills are simply awful... I think I've set some manageable goals for now, haven't I?


Thanks guys!
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 25 / October / 2019, 01:28:17
- The use of mc:download_images() to retrieve the images and have them separated to different folders with the camera name (or serial), to keep them organized
options for download_images are a lua array, like
Code: [Select]
!mc:download_images({dst='${id}/${subdir}/${name}',pretend=true})
The pretend=true above makes it print out what it would do, instead of doing it.
The dst tells it how to name the files. The example above is the default you would get if you didn't pass any options.
${id} is the number of the camera. Each one will be unique in a multicam session. See below about naming.
${subdir} is the canon image directory, like 111___10 or whatever your canon settings give.
${name} is the canon image name, like IMG_0123.JPG
you can use
Code: [Select]
help imdl
in the chdkptp prompt to see substitution strings like this. You can also include normal text in dst, like dst='c:/myfiles/camera-${id}/${name}'

Quote
- Naming the cameras, in order to make it easier to debug possible errors or send individual commands. And somehow, make these names persistent from session to session. Optional (making groups of cameras)
multicam doesn't let you name cameras, but they have a number, which can be saved across sessions if the cameras report a serial number (very old cameras don't).

The multicam list / sel functions let you select groups of cameras, see here https://chdk.setepontos.com/index.php?topic=12748.msg126644#msg126644

You can see see all connected cameras mc:list_all(), or the current selected ones with mc:list_sel(). You can toggle display of camera ids on the cameras using mc:cmd('id')

Quote
- Setting a few basic parameters on cameras (or groups of cameras), like exposure or focus. I've used testshots for this, but couldn't figure out how APEX96 units work.
First, I'd suggest using mc:shoot() rather than mc:testshots(). It provides more controls and doesn't spam the screen with test output.

You can use the use the chdkptp exp module to convert from standard units to APEX96. For example, for 1/100th shutter speed, you could use
Code: [Select]
mc:shoot({tv=exp.shutter_to_tv96(1/100)})
For ISO, use iso_to_sv96, and for aperture use f_to_av96

If you want to set something that is not an option for mc:shoot(), you can use
Code: [Select]
!mc:cmdwait('call <some CHDK lua code>')
with the script functions listed at https://chdk.fandom.com/wiki/CHDK_Scripting_Cross_Reference_Page
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 25 / October / 2019, 13:29:08
Thanks a lot for your prompt help Reyalp!


A couple of things:
-I was aware I should be using mc:download_images(), but couldn't figure out how to set the destination folder (despite having the syntax code in front of me, that's how bad I am with code). Now it's much clearer, tried it and it's working.


- mc:cmd('id') turned out to be really handy, I saw a similar thing by waterwingz (number and status in the display) and wanted to ask for a similar thing. This does it, but... First time I used it, the list numbered 3 cameras as 1, 2 &3, but in the display the cameras were offset by one number (2,3,&4). I unplugged my mouse (only usb thing I had connected to the laptop aside from cameras) tried again and numbers showed up correctly. Now tried again, with mouse plugged and it's working fine too...?? Are these numbers persistent? I suppose not, any way to make them persistent from session to session?


-I'd like to dig deeper into the variables for mc:shoot, where can I check them? I've tried !mc:cmdwait('call <get_focus_ok>') but nothing happened, why do mc:shoot variables syntax differ from the cross reference page you linked? I think I'm not using this correctly :(


-And finally, once i get the code properly set up, I'd like to create BAT executables with groups of orders sent to camera (one to initialize, one to set focus and lock it, one to set exposure, one to shoot in sync, and last one to download and delete images) instead of sending lines of code one by one. It's something I saw here (https://chdk.setepontos.com/index.php?topic=11478.msg120521#msg120521 (https://chdk.setepontos.com/index.php?topic=11478.msg120521#msg120521)). I've already set one with following code and it works:

chdkptp  -e"exec mc=require('multicam') mc:connect() mc:start() return mc:cmdwait('rec')

Things are starting to take shape, once I polish a few rough edges. Thanks for all your help!
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 25 / October / 2019, 14:25:14
- mc:cmd('id') turned out to be really handy, I saw a similar thing by waterwingz (number and status in the display) and wanted to ask for a similar thing. This does it, but... First time I used it, the list numbered 3 cameras as 1, 2 &3, but in the display the cameras were offset by one number (2,3,&4). I unplugged my mouse (only usb thing I had connected to the laptop aside from cameras) tried again and numbers showed up correctly. Now tried again, with mouse plugged and it's working fine too...?? Are these numbers persistent? I suppose not, any way to make them persistent from session to session?
You can make them persistent using the camera list function I mentioned in the previous post.

Specifically, after you have all the cameras connected, you can do something like
Code: [Select]
!mc:save_list('cams.txt')
If you want to make a list of only some of the cameras, you can use mc:sel() to select them first.
Code: [Select]
-- select all available cameras
mc:sel('all')
-- select camera ID 1
mc:sel(1)
-- select cameras 1,3 ,5
mc:sel({1,3,5})
-- select cameras 3 through 9
mc:sel({min=3,max=9})
mc functions like mc:shoot and mc:cmdwait operate on all the selected cameras.

Once you have a list saved, you can connect to those cameras with the same IDs later, using the list option, like:
Code: [Select]
mc:connect({list='cams.txt'})

Quote
-I'd like to dig deeper into the variables for mc:shoot, where can I check them?
The major multicam functions are usually documented in multicam.lua. Find "function mc:shoot" and then look at the part above between --[[ and  --]]

Quote
I've tried !mc:cmdwait('call <get_focus_ok>') but nothing happened, why do mc:shoot variables syntax differ from the cross reference page you linked? I think I'm not using this correctly :(
Because they're different things ;)
mc:shoot() takes options, that are defined within mc:shoot. It interprets those options and builds a sequence of multicam commands to send with mc:cmd

mc:cmd / mc:cmdwait take "commands" which are defined within the camera side part of the multicam script, found at the bottom of the multicam.lua file, in chdku.rlibs:register

call in mc:cmdwait('call ...') is a command as described above, where the part following call is treated as camera side Lua, which is described on the wiki page.

Your example is almost right, but if you want to get a value back, you need to use return, and you need to display the result, like
Code: [Select]
!mc:print_cmd_status(mc:cmdwait('call return get_focus_ok()'))
That outputs a verbose structure like
Code: [Select]
1: {
 done=true,
 failed=false,
 status={
  status={
   [1]=false,
  },
  cmd="call",
 },
}
2: {
...
The outer 1 means the stuff in the following { } is for camera ID 1
The innermost status is what the lua code returned, in this case, it returned one value which was false (focus not OK)

If you want less verbose output, you can process the returned values with your own code instead of mc:print_cmd_status, like
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 end
(note above is all one line)

Quote
And finally, once i get the code properly set up, I'd like to create BAT executables with groups of orders sent to camera (one to initialize, one to set focus and lock it, one to set exposure, one to shoot in sync, and last one to download and delete images) instead of sending lines of code one by one.
I'd suggest using Lua files you can run from the chdkptp prompt rather than bat files for most of this, because if you quit chdkptp in between you'd need to re-connect and re-initialize between each one.

You can do this by creating a text file myinit.lua with with
Code: [Select]
mc=require'multicam'
mc:connect()
mc:start()
mc:rec()
And then in the chdkptp prompt, use
Code: [Select]
!dofile('myinit.lua')
Note that inside the myinit.lua file, the mc: commands do NOT have an ! in front of them.  The ! in chdkptp is what tell chdkptp that the thing following it should be treated as chdkptp Lua code.

If you just give a file name like above, the file is expected to be in the same directory you started chdkptp from. You can use a full path like dofile('c:/whatever/files/myfile.lua'). Use forward slashes / to avoid confusion with \ being treated as an escape character.

You could create more files for shooting, download etc.

You can start the whole thing with myinit from a batch file like
Code: [Select]
chdkptp  -e"exec dofile('myinit.lua')"
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 25 / October / 2019, 14:43:59
Wow!! Thanks a lot! Monday I'm moving into the new studio, where the project will be built. I'll be doing some further testing with all the info provided during the week and report back. Can't believe so much progress in such a short time! Thanks a million :D
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 26 / October / 2019, 13:24:08
Ok, been doing a bit of testing. Seems like it's starting to work. A couple of doubts...

Can I specify multiple shooting variables? F=4, shutter 1/100, iso 80 all at the same time? I've tried different combinations, this is one of them, there must be an obvious syntax error :(

Code: [Select]
!mc:shoot({tv=exp.shutter_to_tv96(1/100).iso_to_sv96(100})
ERROR: compile failed:[string "mc:shoot({tv=exp.shutter_to_tv96(1/100).iso_t..."]:1: ')' expected near '}'

And, is there a command to reboot all the cameras? I see it useful when the whole bunch of them needs to be rebooted... Tried this, but to no avail :(

Code: [Select]
!mc:cmdwait('call <reboot>')
I'm trying different stuff, but syntax... oh, syntax's not my friend.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 26 / October / 2019, 14:25:19
Ok, been doing a bit of testing. Seems like it's starting to work. A couple of doubts...

Can I specify multiple shooting variables? F=4, shutter 1/100, iso 80 all at the same time? I've tried different combinations, this is one of them, there must be an obvious syntax error :(
Yes. Each thing you want to set is like tv=..., separated by commas. like
Code: [Select]
!mc:shoot({tv=exp.shutter_to_tv96(1/100), sv=exp.iso_to_sv96(100),av=exp.f_to_av96(4)})
One thing to note on ISO, if you use the above, the value that gets set won't be exactly what you'd get setting ISO 100 in the Canon UI. The firmware uses two kinds of ISO values, which we refer to as "market" and "real". The difference is depends on the model.

If you want to set the value by "market" ISO (as you would see in the Canon UI), you'd need a separate command, before shooting. To set one of the regular values available in the menu, you could use:
Code: [Select]
!mc:cmdwait('call set_iso_mode(100)')

Quote
And, is there a command to reboot all the cameras? I see it useful when the whole bunch of them needs to be rebooted... Tried this, but to no avail :(

Code: [Select]
!mc:cmdwait('call <reboot>')
First, the <> in my example were just to say something goes there, it should not be part of the actual code.
Secondly, reboot is a function, so you'd need to use reboot(), like
Code: [Select]
!mc:cmd('call reboot()')
Note you do not want to use cmdwait with reboot: cmdwait means chdkptp sits around asking the cameras for a response, but reboot will break the connection so you'll get a bunch of errors. In fact, you probably want a delay like
Code: [Select]
!mc:cmd('call sleep(1000) reboot()') mc:disconnect()
which tells the camera side code to wait one second, while the chdkptp side code disconnects immediately.
Reboot in CHDK is pretty hacky in other ways. I'd suggest avoiding it unless you find you actually need it. If you do, be sure to switch to playback first. Also note that image numbering may not be saved when reboot is used, so for example if you shot IMG_0010, IMG_0011, and then reboot, the next image you shoot after rebooting might be IMG_0010 again. This is generally only an issue if you are deleting the images, the counter will be set after the highest numbered image on the card. You can use dummy images to set the counter.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 31 / October / 2019, 12:42:32
Thanks for your invaluable help reyalp! Been doing some more testing (still can't move into the new studio, so the big rig will have to wait one more week), there's a couple of things I have probably missed:
1 - In order to have the same filename for each shot across all cameras, you suggested using a dummy file. I suppose this is a "read-only" jpg inside DCIM?
2 - I have to install CHDK in the remaining 27 cameras, and would like them to have the same CHDK startup configuration. Which is the file that holds this info? Can't seem to find it.
3 - As suggested I've started creating few different lua files with batches of commands. My goal is to create a single .bat executable that invokes these different lua files as in a menu using
Code: [Select]
chdkptp  -e"exec dofile('start.lua')"
And the matching LUA:

Code: [Select]
mc=require'multicam'
mc:connect({list='cams.txt'})
mc:start()
mc:cmd('id')
mc:cmdwait('rec')
Something like: Press 1 to start, 2 to intialize sync, 3 to set focus, 4 to set exposure, 5 to shoot, 6 to download images and 7 to shutdown and exit. Is this the correct/advisable way to do it? (I'm having a friend write that .bat, that's why i'd like to know in advance)
4 - I'm not understanding well the procedure for the cameras to focus, and then lock focus. I've tried
Code: [Select]
!mc:cmd('call get_focus_ok()')--- or less verbose
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 end
---and
Code: [Select]
!mc:cmd('call get_focus_state()')
First two are always false, third one does nothing. I see get_focus() needs and input value to set focus on a given distance, so... Which one is the command to tell the camera just to autofocus? Suppose I'll have to use it with cmdwait and then issue a set_aflock(1). I can´t seem to get this to work. :(
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 :)
(reminder) Need to: install drivers for every camera with Zadig, number every camera and matching card, then install CHDK in everyone of them and copy config file.
Thanks again for your support! :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 01 / November / 2019, 02:13:09
1 - In order to have the same filename for each shot across all cameras, you suggested using a dummy file. I suppose this is a "read-only" jpg inside DCIM?
On startup, the camera will set the image number based on the highest numbered image that matches the camera naming convention. So if you create a file called IMG_0001.JPG in the current image directory, the first shot after reboot should be IMG_0002.JPG and so on.

You could create a file like this in current image directory using something like
Code: [Select]
mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_0001.JPG","wb") fh:close()')
(edit: the above assumes you've deleted all other images, the camera looks at the highest numbered image)

Alternatively, you don't need to keep the camera file names in sync at all, you can use the ${....} substitution strings in mc:download_images dst to name them, for example with ${shotseq} the various date/time ones.

Quote
2 - I have to install CHDK in the remaining 27 cameras, and would like them to have the same CHDK startup configuration. Which is the file that holds this info? Can't seem to find it.
You can copy all the .CFG files from the CHDK directory.
See https://chdk.setepontos.com/index.php?topic=12325.0 for an example of uploading the same file to all cameras.
Note that CHDK might overwrite your uploaded CFG files if you enter/exit alt mode or change CHDK settings after uploading, so I'd suggest shutting down or rebooting the cameras after uploading the files.

edit:
An alternate way to set CHDK settings is to use set_config_value https://chdk.fandom.com/wiki/Script_commands#set_config_value which could be done using the multicam 'call' command.

Quote
3 - As suggested I've started to create a few different lua files with batches of commands. My goal is to create a single .bat executable that invokes these different lua files as in a menu using
Code: [Select]
chdkptp  -e"exec dofile('start.lua')"
Something like: Press 1 to start, 2 to intialize sync, 3 to set focus, 4 to set exposure, 5 to shoot, 6 to download images and 7 to shutdown and exit. Is this the correct/advisable way to do it? (I'm having a friend write that .bat, that's why i'd like to know in advance)
As I mentioned in the earlier post, if you quit chdkptp between actions (as would be required if your UI is in the batch file), you will need to re-initialize and reconnect  for each of these options. So you'd be better off prompting for the option 1, 2 etc inside chdkptp. If you are using chdkptp in CLI mode, you could do something like

start.lua
Code: [Select]
repeat
 print('1) start, 2) intialize sync, 3) set focus, 4) set exposure, 5) shoot, 6) download images 7) shutdown and exit')
 local option = cli.readline('mc> ')
 if option == '1' then
  mc:connect({list='cams.txt'})
  mc:connect()
  mc:start()
  mc:cmd('id')
  mc:cmdwait('rec')
 elseif option == '2' then
  mc:init_sync()
 elseif ... other options go here ...
 elseif option == '7' then
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
 end
until option=='7'
If you use the GUI, these could be done with IUP buttons instead. However, using the GUI introduces a lot of additional complexity and room for possible issues with multicam.

Quote
4 - I'm not understanding well the procedure for the cameras to focus, and then lock focus. I've tried
First, get_focus_ok() just reports whether the camera thinks auto focus was successful, meaning it found *something* to focus on. It is only updated when the shutter is half pressed and get_shooting becomes true.

You can use the 'preshoot' command to make all the cameras go into half press and wait there.

Controlling focus is unfortunately a complicated subject in CHDK. Different cameras need different methods. I'll try to deal with that in another post.

Quote
Which one is the command to tell the camera just to autofocus? Suppose I'll have to use it with cmdwait and then issue a set_aflock(1). I can´t seem to get this to work. :(
You could do it after preshoot. Whether set_aflock works and does what you want in half shoot may depend on the camera. If it doesn't, you could try using key presses to enable AF lock instead of set_aflock(). This should work in preshoot, like
Code: [Select]
!mc:cmdwait('preshoot')
!mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
The key(s) to enable canon AF lock may vary depending on your camera. On cameras with native MF, it may just put you in MF mode, with SET required to dismiss the focus UI.

Another option would be get the focus distance in preshoot, and then enable MF and set the focus distance outside:
Code: [Select]
!mc:cmdwait('preshoot')
!mc:cmdwait('call local sd=get_focus() release"shoot_half" sleep(500) set_mf(true) set_focus(sd)')
This will only work on models that support set_mf and have working focus override in MF. The sleep may be needed to prevent crashes that happen when set_mf is called before the camera is fully done leaving half shoot.

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.

The latest version of multicam in svn allows you to set focus distance in mc:shoot(), but the same value would be applied to all cameras, which is probably not useful in many real world scenarios.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / November / 2019, 11:58:36
Hi!

Did my first test with the menu, and seems like there's something wrong. Until I find out the correct way to set focus and exposure (for now they're optional) I've made options 3,4 and 5 to Shoot. First issued a
Code: [Select]
!dofile('MENU.lua')This is MENU.lua
Code: [Select]
repeat
 print('1) start, 2) intialize sync, 3) set focus, 4) set exposure, 5) shoot, 6) download images 7) shutdown and exit')
 local option = cli.readline('mc> ')
 if option == '1' then
  mc:connect({list='cams.txt'})
  mc:connect()
  mc:start()
  mc:cmd('id')
  mc:cmdwait('rec')
 elseif option == '2' then
  mc:init_sync()
 elseif == '3' then
  mc:shoot()
 elseif == '4' then
  mc:shoot()
 elseif == '5' then
  mc:shoot()
 elseif == '6' then
  mc:download_images({dst='c:/download/TEST01/Camera${id}/${name}',delete=true})
 elseif option == '7' then
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
 end
until option=='7'
This is what I get in CLI

Code: [Select]
ERROR: call failed:MENU.lua:12: unexpected symbol near '=='
stack traceback:
   [string "dofile('MENU.lua')"]:1: in main chunk
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:733: in function <C:\CHDKPTP\lua\cli.lua:724>
   (...tail calls...)
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
   C:\CHDKPTP\lua\gui.lua:683: in function 'action'
   C:\CHDKPTP\lua\gui.lua:642: in function <C:\CHDKPTP\lua\gui.lua:640>
   (...tail calls...)
   [C]: in function 'MainLoop'
   C:\CHDKPTP\lua\gui.lua:758: in function <C:\CHDKPTP\lua\gui.lua:731>
   (...tail calls...)
   C:\CHDKPTP\lua\main.lua:286: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk
Any help? There seems to be something either missing or wrong :(
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / November / 2019, 12:56:07
Tried a few changes... But it's still not working


Code: [Select]
repeat
 print('1) start, 2) intialize sync, 3) set focus, 4) set exposure, 5) shoot, 6) download images 7) shutdown and exit')
 local option = cli.readline('mc> ')
 mc=require('multicam') -- took the liberty of adding this just in case
 if option == '1' then
  mc:connect({list='cams.txt'})
  mc:connect()
  mc:start()
  mc:cmd('id')
  mc:cmdwait('rec')
 elseif option == '2' then
  mc:init_sync()
 elseif option == '3' then  --added 'option' after elseif as it was missing
  mc:shoot()
 elseif option == '4' then  --added 'option' after elseif as it was missing
  mc:shoot()
 elseif option == '5' then  --added 'option' after elseif as it was missing
  mc:shoot()
 elseif option == '6' then
  mc:download_images({dst='c:/download/TEST01/Camera${id}/${name}',delete=true})
 elseif option == '7' then
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
 end
until option=='7'



Code: [Select]
ERROR: call failed:attempt to yield from outside a coroutine
stack traceback:
   C:\CHDKPTP\lua\gui.lua:675: in function 'readline'
   MENU.lua:3: in main chunk
   [C]: in function 'dofile'
   [string "dofile('MENU.lua')"]:1: in main chunk
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:733: in function <C:\CHDKPTP\lua\cli.lua:724>
   (...tail calls...)
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
   C:\CHDKPTP\lua\gui.lua:683: in function 'action'
   C:\CHDKPTP\lua\gui.lua:642: in function <C:\CHDKPTP\lua\gui.lua:640>
   (...tail calls...)
   [C]: in function 'MainLoop'
   C:\CHDKPTP\lua\gui.lua:758: in function <C:\CHDKPTP\lua\gui.lua:731>
   (...tail calls...)
   C:\CHDKPTP\lua\main.lua:286: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk
Any ideas? Thanks! :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 06 / November / 2019, 12:59:31
Hi!

Did my first test with the menu, and seems like there's something wrong.
Any help? There seems to be something either missing or wrong :(
The first line of the error message should identify the line where the problem is. In this case
Code: [Select]
ERROR: call failed:MENU.lua:12: unexpected symbol near '=='
Looking at line 12 of MENU.lua:
Code: [Select]
elseif == '3' then
"option" is missing in the elseif statement. It should be like the ones above, checking if option is equal to the value, like
Code: [Select]
elseif option == '3' then
The same is true in some of the following ones.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / November / 2019, 13:01:49
Yeah, got that. Check reply#10 as i added 'option' just before you pointed it out :)


BTW, I've tried with and without 'mc=require('multicam')' in line 4... Still getting error
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 06 / November / 2019, 13:08:16
Yeah, got that. Check reply#10 as i added 'option' just before you pointed it out :)
The new error looks like it's related to using "readline" in the gui.

Unless you need the gui, I'd suggest running chdkptp in CLI mode. You can do this by starting chdkptp with the -i option or if you want to run menu.lua automatically, -e"dofile('menu.lua')"

edit:
FWIW, I'd suggest putting the mc=require('multicam') outside of the repeat loop (before "repeat") although it shouldn't cause any problems where it is.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / November / 2019, 14:53:19
Done! And it's working! Thanks!! :D

I redid the shutdown process, since issuing a mc:cmdwait('play') before the shut_down gave me a couple of errors and some cameras would turn off with the lens out, and some others would retract the lens but not turn off. I removed the line and now they all shut down properly (despite some errors showing up on the CLI)
Two more things:
- Image numbering: I've inserted a read-only jpg in the DCIM folder, tried the line you suggested in different ways
Code: [Select]
mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
(before the 'repeat' loop, and into option 1) but had little success. Will keep trying to debug what's causing the problem.

- Some cameras (they're all second hand) seem to have the internal clock battery gone (or whatever keeps date and time when off). Maybe this is somehow related to the numbering issue?? Anyway, I'd like to add a line at startup to set the current date and time (or anything that matches between all cameras), but couldn't find anything except get_time command. Any ideas?

The menu has worked great for testing with these 4 cameras, I suppose when I start adding more and more cameras new problems will arise. I hope to move to the new studio next week and start the final build. I'll be conducting more tests until then. Thanks a lot reyalp I'm learning something new everyday :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 06 / November / 2019, 15:49:06
I redid the shutdown process, since issuing a mc:cmdwait('play') before the shut_down gave me a couple of errors and some cameras would turn off with the lens out, and some others would retract the lens but not turn off.
Some cameras will crash if you delete images in rec mode.
Quote
I removed the line and now they all shut down properly (despite some errors showing up on the CLI)
What kind of errors?
In general, I'd recommend trying to understand the cause of things like this, even if it seems too work.


Quote
- Image numbering: I've inserted a read-only jpg in the DCIM folder, tried the line you suggested in different ways
I didn't suggest the file should be read-only. The camera looks for files called IMG_nnnn.JPG, and sets the counter to the highest numbered image on startup.

Quote
Code: [Select]
mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
(before the 'repeat' loop, and into option 1) but had little success. Will keep trying to debug what's causing the problem.
Since the effect is based on what the camera sees at startup it should be done as the last part of your shooting session (i.e. in your shutdown option) rather than at startup, and all higher number images must have been deleted from the card.

You should also verify that your code is actually creating the file, for example by connecting to a single camera and doing imls.

All that said, I'd still recommend using download_images options to number the files instead of relying on the camera shot counters.

Quote
- Some cameras (they're all second hand) seem to have the internal clock battery gone (or whatever keeps date and time when off). Maybe this is somehow related to the numbering issue??
Unlikely. Generally, saved settings are saved in the cameras onboard flash, not volatile memory powered by the clock battery.

Many older cameras have a replaceable clock battery. If that's true of yours, I would strongly recommend just replacing the batteries. You can get them bulk on amazon at reasonable prices.

Quote
Anyway, I'd like to add a line at startup to set the current date and time (or anything that matches between all cameras), but couldn't find anything except get_time command. Any ideas?
The module in lua/extras/syntime.lua can set the camera clock from PC clock.
However, there's a some of caveats:
* You need to enable Lua native function calls in the CHDK menu under miscellaneous. You should be able to do this on one camera and copy the configs. You cannot do it with set_config_value.
* It's set up to work in the normal CLI with a single camera, not multicam.
* It registers some eventprocs which can cause crashes on some cameras if you try to shoot after using it (and could possibly have other side effects). I normally recommend rebooting after using synctime, but if the clock battery is dead, you might end up back at the clock prompt in that case (it's possible a "soft reboot" is OK, I haven't tested).

Anyway, if you want to try the synctime code, you could do something like this in your Lua file
Code: [Select]
local lt=os.date("*t")
mc:print_cmd_status(mc:cmdwait(string.format([[
call
if call_event_proc('FA.Create') == -1 then
return 'FA.Create failed'
end
if call_event_proc('InitializeAdjustmentFunction') == -1 then
return 'InitializeAdjustmentFunction failed'
end
if call_event_proc('SetYear',%d) == -1
or call_event_proc('SetMonth',%d) == -1
or call_event_proc('SetDay',%d) == -1
or call_event_proc('SetHour',%d) == -1
or call_event_proc('SetMinute',%d) == -1
or call_event_proc('SetSecond',%d) == -1 then
return 'set failed'
end
return true
]],lt.year,lt.month,lt.day,lt.hour,lt.min,lt.sec),{libs='serialize_msgs'}))

edit:
If the cameras are sitting with the clock prompt open, you'll probably want to send something like
Code: [Select]
mc:cmdwait('call click"set"')
to make it go away
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / November / 2019, 19:44:26
Ok, thanks for the info! I'll try to grab the shutdown errors tomorrow, in case there's something problematic. Luckily I didn't get any crashes when downloading/deleting images while in rec mode, but perhaps I should add mc:cmdwait('play') before downloading? I didn't mean you suggested a read-only jpg, that was something easy I thought could work (it didn't). I got wrong the use of
Code: [Select]
mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')Thought it was meant to be at startup, like resetting the image counter. Will try to implement it tomorrow prior to shutting down, and report back.

Both the image numbering and the time/date functions are just cosmetic, in order to distinguish between very similar shots, or to detect cameras that may have not fired. It's a minor thing, your solution seems too complicated for me to implement, so I guess I'll let it pass for now (but thanks anyway!). I'll spend some time learning the options in download_images during the next couple of days. BTW some cameras do sit on the clock prompt at startup, but it goes away once i initialize multicam and change to rec mode.

Up to now all the test have been small-scale, I hope everything works as well as it does now once I add more cameras and start buidling the rig. Will keep you posted, thanks again!
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 07 / November / 2019, 19:38:40
Ok, thanks for the info! I'll try to grab the shutdown errors tomorrow, in case there's something problematic. Luckily I didn't get any crashes when downloading/deleting images while in rec mode, but perhaps I should add mc:cmdwait('play') before downloading?
The crash I mentioned doesn't happen during the download/delete, it happens when you attempt to switch to play, or shut down, after having deleted images in rec mode.

Not all models suffer from this problem, but it could explain the issues you saw with having play in the shutdown sequence. If it's a problem in your setup, switching to play before deleting should be a usable workaround.

Quote
I'll spend some time learning the options in download_images during the next couple of days.
Two that might be useful
${shotseq} numbers images from each camera sequentially. So
Code: [Select]
!mc:download_images({dst='./${id}_IMG_${shotseq}${ext}'})
would give you names, identified by camera, with each cameras images being number 0001, 0002 etc, regardless of the canon image counter.
You can set the starting number by including something like shotseq_start=100 in the download_images option.

${ldate}
is the PC date/time when the download starts. This can be used to group together shots in a session, or uniquely identify them if your workflow is download after each shot. By default, it uses YYYYMMDD_HHMMSS format, like 20191107_161812, but this can changed using strftime format codes (https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html), like ${ldate,%Y} for just the year.

${mdate} is similar, using the file create time on the camera. However, this is less useful if your cameras clocks aren't set.
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 09 / November / 2019, 11:27:21
Unfortunately Sx150 doesn´t have that clock battery drawer any more.
So You probably prefer scripting without access to cam´s clock.

Doing AF like that mostly works:  ???
Code: [Select]
set_aflock 0
 sleep 200
press "shoot_half"
do
 sleep 200
until not get_shooting
set_aflock 1
release "shoot_half"
x=get_focus

the get_focus values are somehow spooky, seem to depend on everything between sensor and object´s surface.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 10 / November / 2019, 08:34:26

Thanks Caefix, seems like a good way to do it. I'm trying to implement it into the menu script, but I'm not too sure I'm doing it right. I should follow this structure, right?
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...

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]
mc>7
call sleep(2000) shut_down()
ERROR: call failed:MENU3.lua:25: attempt to call method 'disconnect' (a nil valu
e)
stack traceback:
        [C]: in function 'dofile'
        [string "dofile('MENU3.lua')"]:1: in main chunk
        [C]: in function 'xpcall'
        C:\CHDKPTP\lua\cli.lua:733: in function <C:\CHDKPTP\lua\cli.lua:724>
        (...tail calls...)
        [C]: in function 'xpcall'
        C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
        C:\CHDKPTP\lua\main.lua:210: in function 'do_execute_option'
        C:\CHDKPTP\lua\main.lua:247: in function 'do_no_gui_startup'
        C:\CHDKPTP\lua\main.lua:282: in main chunk
        [C]: in function 'require'
        [string "require('main')"]:1: in main chunk


EDIT: I redid the last part of the code, and somehow screwed it further...
Code: [Select]
elseif option == '6' then
  mc:cmdwait('play')
  mc:download_images({dst='c:/download/TEST01/${id}/_IMG_${shotseq}${ext}',delete=true})
  --mc:download_images({dst='c:/download/TEST01/Camera${id}/${name}',delete=true})
 elseif option == '7' then
  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()
 end
until option=='7'
And got this
Code: [Select]
mc>7
call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()
call sleep(2000) shut_down()
ERROR: call failed:MENU4.lua:35: attempt to call method 'disconnect' (a nil valu
e)
stack traceback:
        [C]: in function 'dofile'
        [string "dofile('MENU4.lua')"]:1: in main chunk
        [C]: in function 'xpcall'
        C:\CHDKPTP\lua\cli.lua:733: in function <C:\CHDKPTP\lua\cli.lua:724>
        (...tail calls...)
        [C]: in function 'xpcall'
        C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
        C:\CHDKPTP\lua\main.lua:210: in function 'do_execute_option'
        C:\CHDKPTP\lua\main.lua:247: in function 'do_no_gui_startup'
        C:\CHDKPTP\lua\main.lua:282: in main chunk
        [C]: in function 'require'
        [string "require('main')"]:1: in main chunk
Line 35 is mc:disconnect(), should I change it to mc:disconnect(1) ???
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 10 / November / 2019, 14:34:39
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.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito 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.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp 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.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito 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. :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp 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.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito 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.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp 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'
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito 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. :)

Title: Re: A couple of Multicam doubts and general help
Post by: reyalp 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  :-[
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito 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  :)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 19 / November / 2019, 05:27:26
Hi, I'm back! During the last week I've been mainly working in the hardware side of the project, which has been really time consuming. Yesterday finally got to test part of the rig with ten cameras (with only SX150is cameras), and wow! It worked way better than I expected! However I had to deal with a couple of hardware problems first, that may be troublesome in the future when more cameras are added. Software wise, just a couple of hiccups that I got to bypass temporarily.

- First of all USB hub connections are topped out with seven cameras on a single port, even if I use a network of self powered usb hubs. Win7 throws a "too many devices" error. So I had to plug a branch of cameras to a different port, and this is a limiting factor in order to plug the remaining 17 cameras I have since i have no more ports (there's four USB ports but i think they share just two internal hubs). This is probably a hardware/driver issue I'll have to deal with. (I'm suspicious that the main central hub, the one where all the other hubs are being connected is not powering up by itself and instead drawing power from laptop, will need to check)


- Turning cameras on. I already expected this, but yesterday I realized how big a PITA is to turn each camera on manually once they're set up on the rig. I've read suggestions about hacking the power buttons, etc... but couldn't find it again.


- The LED light strips I'm building are way less powerful than I expected. They're SMD 5630s which are the most powerful/readily available for general public. But the amount of light is clearly insufficient and gives a ton of noise in my images. Will have to double the amount, or look for other alternatives. Any tips are welcome.


- Ok, now regarding the software/CHDK side: Couldn't get this to work
Code: [Select]
  mc:download_images({dst='c:/download/'..folder..'/CAM${id}/_IMG_${shotseq}${ext}',delete=true})
I tried inserting the readline like 'folder', "folder", '..folder..' but to no avail. Will try to copy/paste the error later. It surely is a syntax mistake on my side...


- If the cams.txt file that stores camera numbering doesn't match up the connected cameras, the program will quit. I disabled this line temporarily (and used just mc:connect) in order to test the rest of stuff. Will have to recreate it with the new batch of cameras
Code: [Select]
  mc:connect({list='cams.txt'})

- I haven't yet implemented the tonumber suggested previously nor the prompt with default values/confirmation. It's in the to do list. I tried setting the values manually with option 4, but I probably introduced them wrong (had little time to test yesterday) and i think they were ignored. Shutter 0.02, ISO 80, f 4. I'm trying to use the lowest ISO available (which should be ISO 80 "market") and since cameras don't have a real aperture diaphragm I'll have to use the widest aperture available so ND filters don't come in and spoil image quality (f3.4 in SX150is, and f2.8 in most of the others, since they're not the same, is there a possibility to set "widest aperture" in all of them?)


Well, despite all these problems, the project is starting to take shape and I'm very happy with how the code worked up to now. I'm very surprised! Will keep working on it and report anything that comes up. Thanks!!
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 20 / November / 2019, 13:39:14

USB hub problems are (kind of) sorted out for the moment. Had to re-route most connections, and have the main hub close to the laptop (without extension cable) to avoid problems. In the future will have to rethink this (better hubs?). New lights are coming in the next week, it was shocking to see how bad cameras performed with such poor lighting, noise was eating detail completely (even DNGs were poor) :( Camera power is still being handled by hand at the beggining of each session, I can cope with this for now but will be grateful for any tips.


On the software side, I managed to rebuild the camera list with correct numbering, implemented tonumber in the parameters prompt, and finally got the correct value format for each parameter. So it's all working great. Still haven't managed to get the 'folder' string inserted in the download path, I've tried all the combinations I could think of, but no... no way to get it working. And have left the default values idea for later, to avoid further problems, So if anyone could help me with the 'folder' string, I'll be really grateful :)
Code: [Select]
  mc:download_images({dst='c:/download/'..folder..'/CAM${id}/_IMG_${shotseq}${ext}',delete=true})
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 20 / November / 2019, 15:33:17
Camera power is still being handled by hand at the beggining of each session, I can cope with this for now but will be grateful for any tips.
The usual solution to this is to mechanically hold the power buttons down or cut them out and hardwire the connections, and then control the power supplies with externally in some way.
Two common issues:
1) You may need to to send
Code: [Select]
mc:cmdwait('post_levent_to_ui"UnpressPowerButton"')
after startup to avoid some parts of the camera firmware getting confused by the power button being held.

2) If you have the power button held, software shutdown (e.g. lua shut_down or "PressPowerButton" levent) stops the firmware OS, but doesn't actually power off the camera hardware (or it powers back on immediately because the physical button is still active). You should first send shutdown, wait a small amount of time, and then cut the external supply.

Quote
On the software side, I managed to rebuild the camera list with correct numbering, implemented tonumber in the parameters prompt, and finally got the correct value format for each parameter. So it's all working great. Still haven't managed to get the 'folder' string inserted in the download path, I've tried all the combinations I could think of, but no... no way to get it working. And have left the default values idea for later, to avoid further problems, So if anyone could help me with the 'folder' string, I'll be really grateful :)
Code: [Select]
  mc:download_images({dst='c:/download/'..folder..'/CAM${id}/_IMG_${shotseq}${ext}',delete=true})
Can you post the specific error or symptom? It would also be helpful to have the code including where "folder" is set.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 20 / November / 2019, 16:04:58
Hi, will keep in mind the tips for the power button hack. thanks!
This is the related code:
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})
And this is the error from the GUI, I'm back at home and can't test it from CLI since i dont have any cameras here. It acts normally, but there's no files to download and does nothing.
Code: [Select]
> !dofile('MENU4b.lua')
ERROR: call failed:attempt to yield from outside a coroutine
stack traceback:
   C:\CHDKPTP\lua\gui.lua:675: in function 'readline'
   MENU4b.lua:4: in main chunk
   [C]: in function 'dofile'
   [string "dofile('MENU4b.lua')"]:1: in main chunk
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:748: in function <C:\CHDKPTP\lua\cli.lua:739>
   (...tail calls...)
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
   C:\CHDKPTP\lua\gui.lua:683: in function 'action'
   C:\CHDKPTP\lua\gui.lua:642: in function <C:\CHDKPTP\lua\gui.lua:640>
   (...tail calls...)
   [C]: in function 'MainLoop'
   C:\CHDKPTP\lua\gui.lua:758: in function <C:\CHDKPTP\lua\gui.lua:731>
   (...tail calls...)
   C:\CHDKPTP\lua\main.lua:286: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk
If I substitute '..folder..' for 'folder' CLI shuts down. This is the error i get in the GUI.
Code: [Select]
> !dofile('MENU4b.lua')
ERROR: call failed:MENU4b.lua:34: '}' expected near 'folder'
stack traceback:
   [string "dofile('MENU4b.lua')"]:1: in main chunk
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:748: in function <C:\CHDKPTP\lua\cli.lua:739>
   (...tail calls...)
   [C]: in function 'xpcall'
   C:\CHDKPTP\lua\cli.lua:285: in function 'execute'
   C:\CHDKPTP\lua\gui.lua:683: in function 'action'
   C:\CHDKPTP\lua\gui.lua:642: in function <C:\CHDKPTP\lua\gui.lua:640>
   (...tail calls...)
   [C]: in function 'MainLoop'
   C:\CHDKPTP\lua\gui.lua:758: in function <C:\CHDKPTP\lua\gui.lua:731>
   (...tail calls...)
   C:\CHDKPTP\lua\main.lua:286: in main chunk
   [C]: in function 'require'
   [string "require('main')"]:1: in main chunk
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 20 / November / 2019, 16:41:47
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})
And this is the error from the GUI, I'm back at home and can't test it from CLI since i dont have any cameras here. It acts normally, but there's no files to download and does nothing.
The gui error is the same one you encountered before, which is a general problem with using readline from the GUI. It's not related to the folder variable or download command. You can start the cli with chdkptp -i whether or not you have cameras. Of course, you won't be able try the actual download.

If what you are saying is that with the cameras, there are no errors and no files downloaded, I'd suggest adding verbose=true or pretend=true to the download command, so you can see what it's trying to do.
Quote
Code: [Select]
> !dofile('MENU4b.lua')
ERROR: call failed:attempt to yield from outside a coroutine
stack traceback:
   C:\CHDKPTP\lua\gui.lua:675: in function 'readline'
...
If I substitute '..folder..' for 'folder' CLI shuts down. This is the error i get in the GUI.
The syntax in the first example, with '..folder..' is correct. Without the .. is incorrect, resulting in the second error quoted.

In general, to debug stuff like this, you want to see what the program is actually doing at each step, and isolate the problem the most specific part of the code you can.

You and use print to display values. So for example you could use
Code: [Select]
local folder=cli.readline('Folder>')
 print('folder is',folder)
To make sure the value was being read like you expected.
You could also build the dst string outside of the download_images command, and print that, like
Code: [Select]
local mydst='c:/download/'..folder..'/CAM${id}/_IMG_${shotseq}${ext}'
 print('dst is',mydst)
And as suggest above, you can use "pretend" to see what the download would do, like
Code: [Select]
mc:download_images({dst=mydst,delete=true,pretend=true})
If you aren't sure of syntax, you can try things in the chdkptp console with the ! command.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 20 / November / 2019, 17:51:54
Will test it tomorrow as soon as possible. It's a minor problem, but it's been giving me a headache so long. I'm starting to suspect I had something else wrong in the code when I inserted the ..folder.. part, and blamed on it. Anyway, will test asap.
Regarding the power button hack, do you think I could glue it down? Thanks again for all your help. :D
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 20 / November / 2019, 19:14:36
Regarding the power button hack, do you think I could glue it down? Thanks again for all your help. :D
I haven't done it as a permanent mod. I'd personally go for something less permanent and more adjustable. One approach I recall being suggested is rubber bands holding a washer sized to match the button. A zip tie in a similar setup might work too. Another option is to make some kind of bracket with a set screw.

Some related threads
https://chdk.setepontos.com/index.php?topic=13289.0
https://chdk.setepontos.com/index.php?topic=12971.20
https://chdk.setepontos.com/index.php?topic=11434.0

Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 21 / November / 2019, 08:51:41

Ok, so... Voila! The '..folder..' thing now works! I probably confused some other error, or there was something else preventing it from working :(
Just taped a nut onto the power button, added "unpresspowerbutton" command at startup and all seems to be working prefectly!
A new improvement, added zoom control:
Code: [Select]
elseif option == '2' then        ---------SET ZOOM
  local zoom=cli.readline('Zoom>')
  mc:cmdwait('call set_zoom('..zoom..')')
Since I have a few non SX150is cameras (A2600, to A2300) I expected this option to be troublesome given the different range in zoom. But despite the zoom ratios being different, it's working nicely with both types (from 0 to 128 they zoom in and out nicely). And I'm proud I did this one on my own :D
I'm working in getting a reliable focus method right now. Will report back. Thanks again!
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 26 / November / 2019, 18:39:55
Hi again, I finally have 20 cameras up and running. There's been all sort of problems along the way, and still have a few to resolve. But, they're "sort of" working. Regarding USB connections, I've had to swap my laptop for a more powerful desktop, to overcome numerous connection issues. On that matter (I believe it is USB related, correct me if I'm wrong) today i've gotten this error a couple of times during different stages of the process (when syncing, zooming,... it's happened in three different cameras)
Code: [Select]
ERROR: call failed:I/O error
attempted to close non-present device bus-0:\\.\libusb0-0002-0x04a9-0x3271
I've been reading about this type of error, some suggest it can be due to power failures/instability. Indeed it has happened on one of the A2400 that I've connected to a power source (instead of it's battery) while the other three (on the same source) have remained stable. But next up I've had the same type of error on two A2400s using their own original battery. So I'm quite puzzled, but I'm thinking it might be USB related? Bad cables maybe? (just ordered a couple of new ones)


The big problem here is that if this error happens, it throws down the whole process and has to be restarted, sometimes even cameras need a fresh start. I suppose this is part of the inner working and there's nothing to do about it? Well, just wanted to check. Thanks again :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 26 / November / 2019, 20:55:54
On that matter (I believe it is USB related, correct me if I'm wrong) today i've gotten this error a couple of times during different stages of the process (when syncing, zooming,... it's happened in three different cameras)
Code: [Select]
ERROR: call failed:I/O error
attempted to close non-present device bus-0:\\.\libusb0-0002-0x04a9-0x3271
By itself, that error just tells you that the connection went away. It could be that the camera crashed or hung or other USB errors. Power or grounding issues are certainly a possible cause in a multicam rig, but there are plenty of "normal" bugs that can crash cams too.

If the camera crashes (shuts down, without retracting the lens, if it was out), you can try getting a romlog: https://chdk.fandom.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

Quote
The big problem here is that if this error happens, it throws down the whole process and has to be restarted, sometimes even cameras need a fresh start. I suppose this is part of the inner working and there's nothing to do about it? Well, just wanted to check. Thanks again :)
If the camera hangs or crashes, it at least needs to be restarted. There is a function mc:check_connections described on https://chdk.setepontos.com/index.php?topic=13212.msg135500#msg135500 which might be helpful.

Quote
If you notice cameras are crashed, run mc:check_connections(). You can pass it options for connect, e.g. a camera list like {list='mylist.txt'}

It checks for disconnected cameras in the current selection. If none are found, it returns without making any changes.
Otherwise, it exits the camera side script on the remaining cameras. If mc.cam_powercycle_cmd is defined, it runs it with the IDs of the disconnected cameras and waits 5 seconds. If not, it lists the cameras to be restarted and waits for keyboard input.
After the cameras are restarted, it runs mc:connect with the options passed in, followed by mc:start()

That thread also has some discussion of presumed power related crashes with a2500
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / November / 2019, 04:58:59

Ok, I've come across some of Andrew Stephens' posts during my time here. His skills are way beyond mine! But I see that quite a bit of the problem solving related to multiple cameras, comes from your conversations with him. The forum is certainly an incredible resource of info. What I find funny is that, every new hurdle, every new problem I find along the way, has already been resolved here in the forum. Prior to finding it, it's all mumbo-jumbo i cannot even undertsand, but once I find it, it all makes more sense. I'm learning so much in the process... :)
Regarding the actual problem, I'll first go the easy way and swap cables for new ones. If problem persists will try to catch the romlog in case it helps. I don't yet see how mc:check_connections is supposed to work, since my menu system just shuts down when the error happens. I suppose I'd need to implement it on a separate file and run it once the error happens, it should powercycle/restart the crashed cameras, wait 5 secs, and bring the whole system back up again? Or at least it kills the script on the connected cameras in order to have a fresh start in all of them...?
And one quick thing... Can't seem to find any options for white balance nor in mc:shoot nor in the Scripting Cross reference... Am I blind? Set_wb anywhere?!?!
Thanks!
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 27 / November / 2019, 10:33:44
Regarding the actual problem, I'll first go the easy way and swap cables for new ones.
Power or grounding issues are certainly a possible cause in a multicam rig, but there are plenty of "normal" bugs that can crash cams too.
I quickly scanned all your previous posts (https://chdk.setepontos.com/index.php?action=profile;area=showposts;u=26658) as I recall various conversations going back 5+ years.

It looks like your latest project is using a lot more cameras than previously? Typically problems with grounding and power distribution start happening more often as people try to build bigger rigs.  Can you provide a detailed description of how you are providing power to all those cameras and the USB connection scheme? While I can see some of that info in various recent posts, getting it all in one place might help us to diagnose your problems and make suggestions to get them fixed.
 
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / November / 2019, 12:54:01

Hi waterwingz! Glad to have you around. Years ago you were really helpful in one of the early developments of the rig. As you can see now I'm operating the whole thing with multicam, at the time I used your usbptp.lua script and just switched the power strip controlling the usb hubs to trigger the cameras, and downloaded manually. Now it is a bit more complicated, but it's starting to work. I made two little schemes with the setup.


The biggest problems up to now have been:
- Had to switch from laptop to a desktop PC to prevent USB problems (too many connections or unrecognized devices). Up to now, seems like a did the right thing.
- Bad LED lights. I bought new powerful High CRI LED strips to replace these cheap ones. Noise (due to low power) and color reproduction are horrible with these.
- Power failures/unstable power with the A series cameras. I initially had 4 (the ii ones) of them into a 4.5V 2A power source. Today I split those 4 into 2 groups. Tested two connected to the a 1A source and seem to be working fine. Couldn't test both groups since one of the DIY battery dummies broke. I'll replace it tomorrow and try again. Batteries are actually 3.6V, but cameras seem to be acting normally and handling well the extra voltage. There's four more cameras still operating with batteries (and still quite a few more 12-15 to add to the rig)


Up to now, the most reliable cameras are the SX150is with their chinese couplers and power source, no problems whatsoever. The cameras on the right side (ii) with DIY battery dummies have been the problematic ones. I've had a couple of mishaps with the (*) ones on the extreme left too, I suppose it might be due to daisy chaining the USB hubs? Although they've only been problematic once the (ii) ones gave errors. I'm having two 5V 10A power sources with voltage adjustment delivered tomorrow in order to have a sturdier power source with the A2300-A2600s, will have to create better dummies with ground..?


Looking at the scheme, can you spot any future problems I might have to consider? Thanks a lot for your time. Will keep testing tomorrow.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 27 / November / 2019, 13:27:08
Regarding the actual problem, I'll first go the easy way and swap cables for new ones. If problem persists will try to catch the romlog in case it helps. I don't yet see how mc:check_connections is supposed to work, since my menu system just shuts down when the error happens. I suppose I'd need to implement it on a separate file and run it once the error happens, it should powercycle/restart the crashed cameras, wait 5 secs, and bring the whole system back up again? Or at least it kills the script on the connected cameras in order to have a fresh start in all of them...?
Ah right I didn't think of that. Mumbo jumbo ahead:
When you run a command from the cli with !, like !mc:shoot() it's "protected" from errors. That is, if there's an error during the shoot call, the shoot command ends wherever the error occurred, and you end up back at the command prompt. When you run your menu script, the entire script is protected, but individual mc: calls are not, so if there's an error, the script ends, and you would need to restart it.

So if you wanted to handle errors in your script more cleanly, some options would be
1) Arrange for the menu file to call stuff protected,
2) Make it so that re-running the script allows you to pick up where you left off
3) Add your menu options as chdkptp cli commands
All of these require a bit of programming. Not having your current script, I'm can only give general advice.

For #1, you could change something like
Code: [Select]
elseif option == '5' then
  mc:shoot()
 elseif option == '6' then
To
Code: [Select]
elseif option == '5' then
  cli:print_status(pcall(function()
   mc:shoot()
  end))
 elseif option == '6' then
pcall calls a function in protected mode http://www.lua.org/manual/5.2/manual.html#6.1
the function() ... end is an anonymous function that lets you just past the code that you already had into the pcall
cli:print_status() expects status, error return values like pcall produces, and prints the error if there was one (actually, it prints the second value regardless, but from pcall it should only be an error)

For #2, if your script doesn't keep much state, you might just be able to add a menu option to do check_connections instead of the initial setup. So your procedure would be  on error, run menu .lua and then choose recovery instead of start & sync.

Complications: Focus and zoom settings would be lost on the crashed camera unless you added code to save them. You'd also need to include init_sync in the recovery command, since the reconnected cam wouldn't be synced.

#3 requires more code, but I can provide examples if you want.

Quote
And one quick thing... Can't seem to find any options for white balance nor in mc:shoot nor in the Scripting Cross reference... Am I blind? Set_wb anywhere?!?!
You can't set custom white balance values. You can set white balance mode with something like
Code: [Select]
mc:cmdwait('call set_prop(props.WB_MODE,1)')
1 above would be daylight. For older cameras like yours, the numbers will probably be
0 = Auto, 1 = Daylight, 2 = Cloudy, 3 = Tungsten, 4 = Fluorescent, 5 = Fluorescent H, 7 = Custom
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / November / 2019, 14:04:13
Hi reyalp! Thanks for the explanation! Not so mumbo-jumbo... I managed to understand it! :) #1 seems somehow doable. But on one hand, I'm 100% sure I'm going to make many mistakes, and on the other, first I need to solve the hardware issues and tidy up the menu system and options before committing to something more advanced. I keep in mind your suggestion from #28, I will eventually go for it too.


But for example white balance seems easy to implement (and will do tomorrow). Have you looked at the diagram/scheme I made for waterwingz? Any suggestions? Thx.
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 27 / November / 2019, 14:54:30
Looking at the scheme, can you spot any future problems I might have to consider? Thanks a lot for your time. Will keep testing tomorrow.
Comments and questions below - thanks for those diagrams.  That's a good start.

Quote
I bought new powerful High CRI LED strips to replace these cheap ones. Noise (due to low power) and color reproduction are horrible with these.
Have you noticed if your connection issues seem to occur more frequently if the LED strips are on or off?

Quote
Power failures/unstable power with the A series cameras. I initially had 4 (the ii ones) of them into a 4.5V 2A power source. Today I split those 4 into 2 groups. Tested two connected to the a 1A source and seem to be working fine.
I'd say a nominal 1A power source might be okay for 1 camera, which can briefly pull 1.5 amps during certain operations. I would not recommend two or three hooked up to that same power supply.

Quote
Up to now, the most reliable cameras are the SX150is with their chinese couplers and power source, no problems whatsoever.
That's one bit of good news then ...

Quote
I'm having two 5V 10A power sources with voltage adjustment delivered tomorrow in order to have a sturdier power source with the A2300-A2600s, will have to create better dummies with ground..?
Good!  See my previous comment. Budget 2 amps per camera (or 5 -6 cameras maximum per power supply).

Regarding USB connections, I've had to swap my laptop for a more powerful desktop, to overcome numerous connection issues.
By "more powerful" I assume you mean software power not electrical power?

Quote
But next up I've had the same type of error on two A2400s using their own original battery.
This is the most worrying part electrically. I've assume the USB shield and/or 0V pin is the common ground for all the camera. If the A2400's on battery power are not behaving then we might have to think about that.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / November / 2019, 15:38:37
Hey, thanks waterwingz!! I don't recall any difference with strips being on or off, but will test further tomorrow. I changed to desktop cause the laptop would start giving connection issues with just 7 devices connected. Brought one of my desktop rendering nodes to the studio and since then I've had no issues. I suppose it's related to internal hubs and power distribution (or something else, they're generally finicky, it's not the first time I encounter USB issues on laptops).


2A per camera is quite a bit! I based my numbers in the designation of the NB-11L batteries that says 680mAh.. In any case I'll follow your advice and give them some excess amperage. Regarding the battery powered cameras, let's wait til I have the new power sources installed to draw conclusions... Only time they caused errors was after the powered ones failed.


And yeah... mighty old sx150, I'm trying to source more of them but they are scarce. Not the best image quality with the zoom wide open, but very similar to A2300-A2600s that are really abundant (and cheap). Do you guys happen to know any affordable Canons (under 100€, I'm finding them in pawnshops) that might give a little better quality? I was never a Canon user, so don't know their hierarchy/designation regarding better quality (I only knew the G series). In any case, from experience, in very bright scenes the quality improves quite a lot, so once the new lights are in place I'm sure it'll improve.


Will keep testing tomorrow and report back. Thanks!!


**BTW, I'll probably will be redoing most of my electrical wiring, I should make sure all my cameras are grounded right?


***I just saw a pretty good offer on a Canon DSLR, and went to check Magic Lantern. I was shocked to see that CHDK is miles further developed and much more reliable! Then I quickly forgot about DSLRs :D
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 28 / November / 2019, 13:47:25
Ok, first a reminder... 1) I have no coding skills 2) I am not an electrician


So... I have fried two cameras. Yup... gone, forever. :(

Today I received the power sources I mentioned: 5V 10A 50W, brand new.. I connected the mains cabling and measured with the voltmeter. At first it was giving around 5.3V so I turned it down to the minimum, and it was around 4.6V. I checked the cameras and at the bottom it says 4.3V so thought the cameras could well withstand a little bit more tension and proceeded to plug one of them. Just as i turned on the power strip I thought I heard a very tiny pop and went to check the camera, it wouldn't turn on... Mmmm, maybe the dummy (the old one, without ground) had slipped inside? Or maybe (remember I don't have much of a clue about electricity, voltage, tension, amps...) maybe i should plug two of them so the excess voltage is split? Plugged both, turned on and... a very tiny pop again, and cameras off. Oh my... :(

So I unhooked them from the rig, removed the tape that held a nut on the power button, inserted a battery, and... Wont turn on. Fried. Bye bye...

Seems like that 0.3V excess was too much to withstand. Now the rig has two less cameras, and two power sources I don't know what to do with. The wonderful world of tinkering with stuff you don't know. (no facepalm icon here? it would be very appropiate for this moment)  :'(
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 28 / November / 2019, 13:54:01
Today I received the power sources I mentioned: 5V 10A 50W, brand new..
Can you post a link to the units you purchased?

Quote
Seems like that 0.3V excess was too much to withstand.
So here's the big question.  Are you absolutely certain you got the polarity correct? An extra 0.3V over the nominal battery voltage of 4.3V is quite unlikely to damage anything.  Reversing the polarity can be fatal though.

Edit :
Quote
maybe i should plug two of them so the excess voltage is split?
It does not work that way.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 28 / November / 2019, 14:06:16
It does not work that way.
Yeah, I see that now... That gives you a clue about my electrician skills.


This is the model
https://www.amazon.es/XKTTSUEERCRR-Alimentaci%C3%B3n-Transformador-cConvertidor-Vigilancia/dp/B07DQKM9P7 (https://www.amazon.es/XKTTSUEERCRR-Alimentaci%C3%B3n-Transformador-cConvertidor-Vigilancia/dp/B07DQKM9P7)


A friend of mine just texted me the same about polarity. I'm pretty sure that's the reason... But given the fact that I don't even know which one is which in the voltmeter... At least I'm happy I (still) didn't get any electric shocks with all these cables lying around  ;)


Noob mistake, will never happen again. Will check polarity 20 times before plugging something, I promise.
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 28 / November / 2019, 14:19:43


Noob mistake, will never happen again. Will check polarity 20 times before plugging something, I promise.
It's not just a noob mistake. Don't ask how I know.

With no disrespect intended, can I ask if you are sure what polarity is and how you make sure it's connected correctly?



Sent from my LM-Q710(FGN) using Tapatalk

Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 28 / November / 2019, 14:21:45
Less cams- new arrangement.
I use my cams 'offline' only... 8)
I would suggest, You place the cams 'upright', ( "I" not "--".)
So You reduce background and can take the lights on seperate tripods nearer to the center.
(&& I like my Ixus 300 & the S Serie with 1:2.0)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 28 / November / 2019, 14:40:36
No disrespect waterwingz! Polarity is the (+) and (-) in any electrical circuit... The current "comes" from the positive and "leaves" from the negative? And the ground is for safekeeping, right? My cheap voltmeter doesn't indicate which cable is which (and they're interchangeable, really cheap stuff) I first checked voltage with a battery, but I believe I mistook the cables when connecting the cameras to the power source. Rookie mistake. Anyway, i can buy new ones, they're dirt cheap here :D

Thanks Caefix for the tips! Cameras are in vertical position, good tip though. I'll check the prices of the models you mentioned. Thx!
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 28 / November / 2019, 14:45:47
My cheap voltmeter doesn't indicate which cable is which (and they're interchangeable, really cheap stuff)
I have several really cheap voltmeters that I've acquired over the years.  Analog moving coil models and fully digtal model. It is possible to check polarity with even the very worst of them.

What model do you have ? Post a picture here and I may be able to help.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 29 / November / 2019, 08:39:25
I'm off from the city during the weekend, but don't worry once I'm back I'll take care not to screw more cameras again. But thanks for your help! ;)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 30 / November / 2019, 02:22:24
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.
In the latest multicam version (r900) I added code to set different shooting options per camera. This doesn't do exactly what you described, but it provides building blocks to do it. The way it works is you can specify any of the shooting options like sv, tv, sd per camera, using an option named camopts, which is a table of id = {options} for each camera. So
Code: [Select]
mc:shoot{camopts={[1]={sd=100},[2]={sd=1000}}}
would set the focus distance of camera 1 to 100mm and camera to 1000. If there were cameras other than 1 or 2, they would just use autofocus or whatever was previously set. The top level values are merged, so if you use
Code: [Select]
mc:shoot{sd=500,camopts={[1]={sd=100},[2]={sd=1000}}}
Any other cameras would use 500. You can also specify different values for different cameras, like
Code: [Select]
mc:shoot{sd=500,svm=768,camopts={[1]={sd=100,tv=96},[2]={sd=1000,av=512}}}
so the default focus distance would be 500, all cameras would use svm 768, and cameras 1 and 2 would have shutter and aperture set, respectively.

Now, typing this all out every time would be annoying, but you can put the table in variable instead: Like
Code: [Select]
my_focus_table={
[1]={sd=100},
[2]={sd=500},
...
[20]={sd=123},
}
(... means you fill in the rest of the values)
and then use it like
Code: [Select]
mc:shoot{tv=123,camopts=my_focus_table}
If you wanted to just change settings for one camera, you could use
Code: [Select]
my_focus_table[3]={sd=456}
If you want to save it to a file, you could use
Code: [Select]
fsutil.writefile_e(util.serialize(my_focus_table,{compact_arrays=false}),'my_focus_table.txt')
and to load it
Code: [Select]
my_focus_table=util.unserialize(fsutil.readfile_e('my_focus_table.txt'))
The format is simple, so you could edit the .txt file in a text editor to adjust the distances if you wanted.

If you wanted to start from the cameras current focus distance from auto focus, you could use something like
Code: [Select]
my_focus_table={}
mc:cmwait('preshoot')
local status,result=mc:cmdwait("call return get_focus()")
for id, res in pairs(result) do
 my_focus_table[id]={sd=res.status.status[1]}
end
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 30 / November / 2019, 08:23:18
Wow Reyalp, that's huge!! Thank you so much!! I'm going to need some extra time to play with so many options  :D
AF right now is pretty solid, it nails it down almost everytime. Assuming it's ok, I'd print every focus distance with get_focus and store it, so I can reuse it with camopts. That way I'll be sure to have perfect focus every time. Thanks!!
Code: [Select]
my_focus_table={}
mc:cmwait('preshoot')
local status,result=mc:cmdwait("call return get_focus()")
for id, res in pairs(result) do
 my_focus_table[id]={sd=res.status.status[1]}
end
That's perfect!!!
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 02 / December / 2019, 04:31:04
Here goes a pic of the voltmeter, I have polarity sorted out now. All working fine (except that I have two cameras less)
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 02 / December / 2019, 06:55:38


Here goes a pic of the voltmeter, I have polarity sorted out now.
Nice - the labels on your meter probes are a good idea.

All of my life, red has been positive and black has been negative when doing DC electronics projects. It's kind of an unofficial international standard. Green is always "earth ground" and white undefined but often a positive voltage different than red.

It never occurred to me someone new would not instinctively know that so I was confused about why you were having meter difficulties.

(Of course this knowledge almost resulted in a nasty shock when I first encountered North American mains wiring where to black wire is usually "live" or "hot" )
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 02 / December / 2019, 13:23:34

Yeah, it's always been like that for me too! ("Rojo, positivo. Negro, negativo" Here in Spain) But take a look at the meter, cables are interchangeable, and I still can't find any clear indication of + or - to be sure I had them the right way. Anyway, today I checked all the dummies and cabling, and found out where the problem lies... It's terrible and really embarrasing. It's been fixed, it's been a funny facepalm moment. And during the weekend I managed to scour two G10s at a very good price, it's a step up in quality so I'm (somehow) happy I was forced to look for new cameras.


BTW, while checking the dummies I've come to the conclusion I need a different method to make them. If I'm to insert a ground cable, I have not enough precision with my current "grab a piece of plastic and glue a couple of cables at the right distance" method... I've been thinking of using some sort of readymade connector, like a JST or Molex connector with around 3mm spacing between pins (I measured all the batteries, they're all roughly the same) and sand it down to fit inside. I could scavenge an old battery, but it's a bit of a waste and still requires some "precision" soldering (that I'm not skilled enough to do). Do you have any other ideas? Thx!
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 02 / December / 2019, 18:47:43
But take a look at the meter, cables are interchangeable, and I still can't find any clear indication of + or - to be sure I had them the right way.
The earth symbol and the letters COM (for common) attached to the lower terminal should have been a clue as well.
(https://i.imgur.com/Z1bvPtz.jpg)

 :-X


Quote
BTW, while checking the dummies I've come to the conclusion I need a different method to make them. .... Do you have any other ideas?
how about this link : 3D Printed Camera Battery Emulator (https://hackaday.com/2015/01/21/3d-printed-camera-battery-emulator/)  ??
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 02 / December / 2019, 19:06:29
how about this link : 3D Printed Camera Battery Emulator (https://hackaday.com/2015/01/21/3d-printed-camera-battery-emulator/)  ??
Funny, I found that 3d model some time ago. Having it 3D printed is even more expensive than a 3rd brand working battery!  :lol
Anyway, I'll go shopping connectors tomorrow. Hope I'm lucky, seems like the best idea.
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 02:50:30
I can not find the post / picture but someone years ago made fake NL-4B batteries from wood. I've also seen AA batteries made of wood for Canon A series cameras.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 03:12:34
This has been working great for now. There's a big blob of glue instead of tape. But fitting a third (ground) cable in between those two will probably short circuit the whole thing. JST XH connectors have a distance between pins similar to the batteries poles. Will give them a try (if I can find any).
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 03:47:33


But fitting a third (ground) cable in between those two will probably short circuit the whole thing.
I must have missed something here. Why are you trying to fit a third wire in there?  Are you going to try camera triggering via the battery third terminal method?
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 04:57:01
Maybe I am the one that missed it, but when I had connection problems you suggested I should keep an eye on grounding problems... That's why I'm adding a third wire for ground. Is it not the right thing to do?
Title: Re: A couple of Multicam doubts and general help
Post by: c_joerg on 03 / December / 2019, 05:03:32
All of my life, red has been positive and black has been negative when doing DC electronics projects. It's kind of an unofficial international standard.
Well, take a look at the wiring at original mercedes charger. I hope that's just an exception...  :D
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 10:11:06
All of my life, red has been positive and black has been negative when doing DC electronics projects. It's kind of an unofficial international standard.
Well, take a look at the wiring at original mercedes charger. I hope that's just an exception...  :D
Regardless of the wire colours that thing uses, having them swap like that when passing through a connector is just frightening.  Especially when you see the damage that a incorrectly connected automotive batttery can do.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 12:08:42
Hey waterwingz, not sure if you read #65. But you left me in doubt, not sure if I should proceed with the new grounded cabling/dummies... Actually, the center pin on the batteries says T, for temperature? Maybe it's not ground? Is it pointless to use it??  :blink:
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 03 / December / 2019, 12:36:44
Hey waterwingz, not sure if you read #65. But you left me in doubt, not sure if I should proceed with the new grounded cabling/dummies... Actually, the center pin on the batteries says T, for temperature? Maybe it's not ground? Is it pointless to use it??  :blink:
Yes, the 3rd battery pin is for the battery thermristor. You should not ground it! (edit: low resistance will make the camera think the battery is on fire ;))
If you want the camera to think there is a battery, you can connect it to - with a ~10k resistor, but normal AC adapters just leave it open circuit.  In CHDK, you can also use it as a remote trigger https://chdk.setepontos.com/index.php?topic=13451.msg137584#msg137584
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 12:42:57
Ok, I won't be touching that then! I wonder what waterwingz meant with "problems with grounding" on #41, and on the last bit of #45... :blink:


BTW I'm not planning to change the shooting procedure, it's perfect as it is now. The whole 3rd cable idea comes from #41, was he referring to another type of grounding problems?
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 13:15:07
Ok, I won't be touching that then! I wonder what waterwingz meant with "problems with grounding" on #41, and on the last bit of #45...
Grounding problems can occur with multi-camera rigs primarily because of all the different AC to DC power supplies being used for the USB hubs and "battery eliminators"

In theory, each of those power supply provides a 100% floating DC output.   The issue comes when those different outputs are only randomly connected together through a maze of small ground paths through he USB trigger cables and "dummy battery" connectors.  This can creates voltage offsets and current spikes that cause weird random problem - possibly including camera crashes.  And with some power supplies, the isolation is not perfect to the mains (or AC) side of the power supply, allowing potential shock hazards (one CHDK multicam user reported just that several years ago).

So, the best way to handle this is to use a heavy gauge wire (say 14 ga.) to interconnect the DC grounds of each of the power supplies for the cameras and the USB hubs. People tend not to do this as it's extra work and the little "wall wart" power packs for the USB hubs and the battery eliminator power supplies tend not to provide a convenient connection point.  But even if you can't connect all of the power supply grounds, interconnecting the 0V wires coming from each dummy battery power pack is a pretty good compromise as that's where the most substantial current flows will be.  You don't need a wire to the dummy battery itself as it's better to just connect things at the power supply end.  To finish this off, you can connect (bond) that common ground conductor to building ground ("earth") for a bit of added protection.

Does that help?


 
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 13:34:17

It does! Thank you so much for clarifying! Tomorrow I'll check what can be done about it.


interconnecting the 0V wires coming from each dummy battery power pack
All the power strips are grounded to building ground. The power supplies for dummies are grounded individually too. The SX150 battery adapters do not seem to have any grounding (will check tomorrow, I'm out of the studio now) Should I interconnect the ground between them? Never thought that would be safe... But again I have no f*** clue of what I'm talking about. Thanks so much for your patience :)
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 03 / December / 2019, 13:48:15
Generally, how to optimize a smooth start of the rig?  :-*
I would power up each 'tripod' one by one with some secs delay to avoid heavy power peeks.
Then boot computer...
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 13:51:48
All the power strips are grounded to building ground.
That's good  (and almost certainly required by your local electrical code).

However, remember that each of your power supplies can be thought of as having two sides.  One side is connected to the AC mains power..  The other side connects DC low voltage power to your cameras.  Inside the power supply, the electronics magic converts the high voltage AC mains power into safe low voltage DC power. There is no actual electrical connection between the two sides though - they are "isolated" (or supposed to be).

So connecting things to building ground on the AC side does nothing to create a common ground on the DC side.

Quote
The power supplies for dummies are grounded individually too.
I assume you mean on the AC side? See my previous comment if so.

Quote
The SX150 battery adapters do not seem to have any grounding (will check tomorrow, I'm out of the studio now)
AC side again?  This is not uncommon and allowed by electrical code if the internal design meets a "double insulated" standard.

Quote
Should I interconnect the ground between them?
Don't touch anything on the main/AC/high voltage side.  Please.

On the DC side, where the + and - cables we discussed earlier come out, you should interconnect a single thick conductor (at least 18ga and 14ga even better) between each of the black ( - ) negative wires as close to each power supply as possible.  Tie the end of that wire to building earth (ground) for extra protection.

Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / December / 2019, 14:08:43
Will check it out tomorrow, but here's a drawing to check if I understood correctly. (Note: red cables are untouched)
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 14:17:36
Generally, how to optimize a smooth start of the rig?  :-*
I would power up each 'tripod' one by one with some secs delay to avoid heavy power peeks.  Then boot computer...
While I'm not sure that's completely necessary,  there is certainly nothing wrong with doing it that way.
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 03 / December / 2019, 15:09:07
Will check it out tomorrow, but here's a drawing to check if I understood correctly. (Note: red cables are untouched)
Good - you've got the concept now.  I expanded it a bit for you - note that AC mains wires are a different color too. Safety first!
(https://i.imgur.com/5C4gX9g.png)
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 04 / December / 2019, 07:53:51
Today I received the power sources I mentioned: 5V 10A 50W, brand new.. I connected the mains cabling and measured with the voltmeter. At first it was giving around 5.3V so I turned it down to the minimum, and it was around 4.6V. I checked the cameras and at the bottom it says 4.3V so thought the cameras could well withstand a little bit more tension and proceeded to plug one of them
Incidentally, there is an old trick you could use here to lower the voltage output a little bit more.  Install a 5A silicon diode in series with the +5V output of each of these power supplies. Or a seperate 2A diode to each camera. At the current level you will be using it shoild give you a constant 0.5 to 0.6V voltage drop - enough to get to the specified operating voltage of the camera.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / December / 2019, 10:28:42
Something like this... Or a 2A on each of the cameras, instead.


In any case, I may temporarily leave this out.  There's 0,5V excess, as long as the power source can keep up with it, the cameras should be fine right?

Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 04 / December / 2019, 11:01:59
Something like this... Or a 2A on each of the cameras, instead.
That's correct.  Note that diodes are polarity sensitive - although nothing breaks if you put them in backwards here - it just won't work.  For most diodes, there is a  band printed around one end of the diode that shows the end to connect to the cameras. 

If you try to measure voltage without the cameras connected you will not see any voltage drop - current needs to flow for that to happen. So turn the voltage adjust on the power supply to the lowest output voltage, install the diode(s), connect the cameras, power everything up, and check the voltage after the diode.

Also, you need plain old Si (silicon) diodes - not schottky diodes. See what you can find from your electronics supplier and post a part number for me to check?

Quote
In any case, I may temporarily leave this out.  There's 0,5V excess, as long as the power source can keep up with it, the cameras should be fine right?
It will probably work fine - there is usually a "safety margin" built into most electronic designs.   

That being said, those little cameras were not designed to run continuously - most people turn them on, take a couple of photos, and turn them off.  You, on the other hand, could be running them continuously for hours so there is going to be a lot more heat build-up than they were designed for.  Made even worse by running them with too high a voltage on the input terminals (= more heat).   

It's your decision of course.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / December / 2019, 11:13:20

See what you can find from your electronics supplier and post a part number for me to check?
I will, I recently found a great electronics store nearby. I'm pretty sure I'll be visiting them frequently from now on.
Quote
those little cameras were not designed to run continuously - most people turn them on, take a couple of photos, and turn them off. 
I'm aware of this, always been careful not to have them on for too long. Once the rig is 100% up and running I'll implement the necessary precautions to have it working safely for longer periods. For now, there's a lot of testing to be done, I'll be careful. :)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 24 / December / 2019, 08:25:58
Hi guys, no major updates in the project. Lately I've been working in the hardware side, adding more cameras, improving cabling, lighting, etc... I recently bought a 3D printer, I'm quite new to this, but it's turned out to be extremely useful to create proper dummies and supports for the cameras and different parts to aid other needs. I'll be uploading the content I've created to thingiverse so people can make use of it. Since the project started to build up (now I'm in 34 cameras in 360 degrees) progress has slowed down considerably, the amount of work has ramped up and slowly left the CHDK/software part in a secondary place. I'll no doubt be returning to my menu system once the hardware side has been dealt with. Anyway, I wanted to thank all of you again for your support and wish you a very happy Xmas. :)
Title: Re: A couple of Multicam doubts and general help
Post by: waterwingz on 24 / December / 2019, 10:21:02


I'll be uploading the content I've created to thingiverse so people can make use of it.
Please post a link here when you get it done?  I'll add it the wiki too when you do.

Hope the holiday season goes well for you !

Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 29 / January / 2020, 03:56:20
Hi guys,


Currently uploading the dummy 3D models for NB11L, NB6L, NB7L and NB4L batteries to Thingieverse. Have to wait 24h to make them public. But they'll soon be available for anyone to use. They're simple and quite rough, but they worked perfectly for me.


As an update, just finished a ton load of work and I'm back at the project. Finally got the hardware side (cabling, usb, lights, power...) roughly sorted to start testing the whole array. Found a couple of hiccups and will try to debug them today. Will keep you posted. Thx!
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 30 / January / 2020, 05:42:44

Here are the battery dummy 3d models.


NB11L - https://www.thingiverse.com/thing:4132890
NB4L - https://www.thingiverse.com/thing:4132905
NB6L - https://www.thingiverse.com/thing:4132900
NB7L - https://www.thingiverse.com/thing:4132908

This is the initial version, might improve NB11L with a little prong, so the battery latch holds onto it and remains better in place.

I'm considering hacking the on/off switches of all A2xxx and Ixus 1xx as seen here:
https://chdk.setepontos.com/index.php?topic=12749.0 (https://chdk.setepontos.com/index.php?topic=12749.0)
But couldn't find much more info on it. Now that everything is up in the rig, it's quite a pain to turn them on manually. Also considering designing/3D printing individual clamps to have the button pressed, though... not sure which method will be less time consuming.

Also, some cameras are going a bit rogue (I'm suspecting 2 of them, probably due to some excess voltage) If one of them fails it brings the whole system down. Need to go back to reply #43 and review the protected/unprotected functions, and usage of mc:check:connections. Anyway, thanks for your help, I'm back at it and will keep you posted. Hope the battery dummies are helpful.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / February / 2020, 12:24:21
Hi guys, I just caught one of the cameras throwing the following error. It somehow manages to bring the whole system down... Seems like there's something wrong with multicam, this one doesn't understand the iD command??


Edit: I just had the offending camera connected, trying to debug the problem. Maybe the init_sync error is related to that??
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 04 / February / 2020, 13:41:20
Hi guys, I just caught one of the cameras throwing the following error. It somehow manages to bring the whole system down... Seems like there's something wrong with multicam, this one doesn't understand the iD command??
The "failed status from unknown cmd..." message means that some other command received a status message generated by the id command. This could happen if you used mc:cmd('id') rather than mc:cmdwait('id')

The issue is almost certainly in your code, so it will be difficult to provide much more advice without seeing it.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / February / 2020, 14:07:29
And once again.... You're absolutely right!  ;)

This is the latest code I've been using. Many things have been left out for the moment, until the system proves to be reliable (right now it is NOT). I used to ID cameras according to a txt created previously, but since I'm constantly finding errors and unplugging cameras, that's been left out too.


I just corrected the cmdwait('id') line locally. This is the original version:

Code: [Select]
mc=require('multicam')
mc:cmdwait('post_levent_to_ui"UnpressPowerButton"')


repeat
 print('1) START 2) ZOOM 3) SHOOT w/FOCUS 4) SHOOT (w/params) 5) AUTO 6) DOWNLOAD 7) SHUTDOWN 8) REBOOT')
 local option = cli.readline('mc>')
 
 if option == '1' then            --------START&SYNC
  mc:connect()
  mc:start()
  mc:cmd('id')
  mc:cmdwait('rec')
  mc:init_sync()
 
 elseif option == '2' then        ---------SET ZOOM
  local zoom=cli.readline('Zoom>')
  mc:cmdwait('call set_zoom('..zoom..')')
 
 elseif option == '3' then        ---------SHOOT w/focus     
  local dist=cli.readline('Focus Dist>')
  mc:shoot({sd=dist}) 


 elseif option == '4' then        ---------SHOOT w/values
 --- local dist=cli.readline('Focus Dist>')
  local fnum=cli.readline('F number>')
  local shutter=cli.readline('Shutter speed>')
  local ISO=cli.readline('ISO>')
  mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  mc:shoot({tv=exp.shutter_to_tv96(tonumber(shutter)), svm=exp.iso_to_sv96(tonumber(ISO)),av=exp.f_to_av96(tonumber(fnum))})
 
 elseif option == '5' then        ---------SHOOT
   mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  mc:shoot()
 
 elseif option == '6' then        ---------DOWNLOAD
  local folder=cli.readline('Folder>')
  mc:cmdwait('play')
 --- mc:download_images({dst='c:/download/'..folder..'/CAM${id}/CAM${id}_${shotseq}${ext}',delete=true,verbose=true})
  mc:download_images({dst='c:/download/'..folder..'/CAM${id}_${shotseq}${ext}',delete=true,verbose=true})


 elseif option == '7' then        ---------SHUTDOWN
  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        ---------REBOOT
  mc:cmdwait('play')
  mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
  mc:cmd('call sleep(2000) reboot()')
  mc:disconnect()
  break
 end
until option=='8'
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 05 / February / 2020, 07:30:23
Hi. This is the problem i'm facing right now. Been thinking about it and can't find the way to debug it. Let's see if you can shed some light on this... I've disabled   mc:connect({list='cams.txt'}) because i'm constanly unplugging cameras from the array trying to find which one is crashing/failing. And using that line caused errors if one or more listed cameras were not connected. Now cameras don't have a fixed ID number i can refer to, every time i start the system they get a random ID for every camera. So, i start the system, cameras usually connect and initialize sync fine, I can even shoot quite reliably. But every time I try to download files, there's one camera which shuts down/fails, i get the attached message (capture4.jpg) and after a few seconds the command window shuts down. I sometimes get an error poiting to the offending camera (capture1.jpg).


Additionally, is there a way to have init_sync produce less verbose? It creates hundreds of lines, too many to scroll up and pinpoint which camera might be the offending one...

So, basically Im playing cat and mouse with the system now... Do you guys have any idea how could I solve this? Thanks :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 05 / February / 2020, 17:15:34
But every time I try to download files, there's one camera which shuts down/fails, i get the attached message (capture4.jpg) and after a few seconds the command window shuts down. I sometimes get an error poiting to the offending camera (capture1.jpg).
The chdkptp error really doesn't tell you anything. It just means USB communication failed. The most common case is probably the camera crashing, but problems in the USB system are also possible, especially in a multicam rig.

So you need to identify the failed camera, and determine what state it's in: crashed / shut down, frozen, or running normally. After the issue happens, you should be be able to physically identify a crashed camera since it will be shut down and the others will not.

You should also try to determine whether only certain cameras have the problem or if it happens randomly to different cameras, or only to certain models if you are using a mix of different models.

If a camera crashes, you should get a ROMLOG (see https://chdk.fandom.com/wiki/Debugging#Camera_crash_logs_.28romlog.29) and post it here.

If the problem affects only certain cameras, this could be due to different settings on those cameras, or problems with things like the power supply or USB hardware.

Quote
I've disabled   mc:connect({list='cams.txt'}) because i'm constanly unplugging cameras from the array trying to find which one is crashing/failing. And using that line caused errors if one or more listed cameras were not connected.
I believe there will just be a warning, and the missing camera won't be added to the list. If this isn't correct, what kind of error do you see?

Quote
Additionally, is there a way to have init_sync produce less verbose? It creates hundreds of lines, too many to scroll up and pinpoint which camera might be the offending one...
There isn't currently a way to disable those messages, but if a errors happen in download, I'm not sure why you are trying to spot the problem camera in init_sync.

You could use mc:check_connections immediately after download to identify the crashed cams.

Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / February / 2020, 06:10:59
After lots of testing, the crashing camera was identified. I produced a romlog (see attached) and it says Harware Defect so I'll probably have to discard it. It's odd because out from the rig, individually it seems to work fine. I wonder what the romlog says... (maybe power related?) In any case, I'm starting to realize that having different models mixed up is not the best way to go. I'm going to try to strip down the system to only A2xxx, SX150 and G10, which are the cameras that have proved to work reliably.
Every camera has it's own quirks, and one example are two old SD1300 I had lying around and included in the rig. They work, but for some reason (or quirk) their exposures are way off from the rest, and produce an error when shuting down the system (couldn't catch it, it happens a split second before the system shuts down). These are minor things, but if I'm looking for some degree of reliability, I'm going to have to discard them. There's a few other little things I may try to resolve in the future, but for now, I'm happy with the progress.
Hope the romlog is useful, thanks!


EDIT: About the error with mc:connect({list='cams.txt'}) I've attached a screengrab just before it closes. If I use mc:connect() , everything works fine. Can´t attach "cams.txt", here's the content:

Code: [Select]
{
 ["FF81F24C80E64C60B180914B936E8335"]={
  ["id"]=12
 },
 ["836BB0F4C82942328CE460978F650B7A"]={
  ["id"]=22
 },
 ["59F76D99E74D4E56A432C01AA1F25F70"]={
  ["id"]=08
 },
 ["8D6851BE4706416B83CB24D5C51E008C"]={
  ["id"]=04 },
 ["CFFBD611EBFA4B3AB7E7E96DDAACD3D7"]={
  ["id"]=05
 },
 ["535772AB22C94DC390105204ABE1CEB5"]={
  ["id"]=16 },
 ["7C5E599D846B453B9C3D2DC6FE50CA60"]={
  ["id"]=07
 },
 ["510EC32D808848FDAFB75076CD3321A7"]={
  ["id"]=17
 },
 ["4A7D94B66EA6466E8457913F3278263C"]={
  ["id"]=1
8 },
 ["5F000B5E65AA4054AA7379D9D15AEE9F"]={
  ["id"]=02 },
 ["CF100970CC43440C8B7A72FBBC70FE72"]={
  ["id"]=06
 },
 ["913E2905D0C345908575A42E463FF077"]={
  ["id"]=15
 },
 ["70C41C4110834DEAA1A54BCFE0F6BE70"]={
  ["id"]=13 },
 ["AA0D228C8F5D418B967549835F00EAB5"]={
  ["id"]=24
 },
 ["B4E1ACD96C454ECB84AC0685EF70D81A"]={
  ["id"]=01 },
 ["9D224B712F7D4F12B42EAEFA9FBE8388"]={
  ["id"]=21
 },
 ["5B844D15130B42328BD2DF240F41561A"]={
  ["id"]=20 },
 ["3B8F8341FB524051BC1666ABBA19B580"]={
  ["id"]=14
 },
 ["2C5B486D306C4596B4BAF7D7B6BD35B9"]={
  ["id"]=03
 },
 ["A0B8A1BD345B455A95B9C1F8AABCEFED"]={
  ["id"]=10
 },
 ["C483BAA2681E47A78D5A0B5FFFE5A8B2"]={
  ["id"]=11 }
}
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / February / 2020, 07:09:02
The shutdown error I mentioned before points to cameras 9, 14, 21 and 22. I traced them and they're exactly the "different ones" SD1300 and IXUS 145 and 160.. So once again, even if they work, i'll replace those with A2xxx.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 06 / February / 2020, 13:00:33
After lots of testing, the crashing camera was identified. I produced a romlog (see attached) and it says Harware Defect so I'll probably have to discard it.
Hardware defect doesn't always mean there's a hardware failure. Sometimes CHDK problems make the camera think there's been a hardware error.

However, yours is E18 (lens error) which is a common, real hardware failure.

Quote
It's odd because out from the rig, individually it seems to work fine. I wonder what the romlog says... (maybe power related?)
The romlog doesn't obviously tell, but if it only happens in the rig, power problems do seem like a reasonable guess. Or perhaps something about how it's mechanically mounted.

What model and firmware version is the failing camera?
Quote
EDIT: About the error with mc:connect({list='cams.txt'}) I've attached a screengrab just before it closes. If I use mc:connect() , everything works fine. Can´t attach "cams.txt", here's the content:
It looks like there might be a syntax error in your list, unless it was a mistake pasting in the forum:
Code: [Select]
["4A7D94B66EA6466E8457913F3278263C"]={
  ["id"]=1
8 },
If that's supposed to be 18, it shouldn't have a newline.

I should make the load_list report errors in cases like this. edit: updated to show an error in r926
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 07 / February / 2020, 13:35:27

What model and firmware version is the failing camera?
Its an IXUS 145 firmware version 100c. I've been testing further and it's a power problem, it all works perfectly until I try to download the images and the cameras go into PLAY mode, lens retracts and that's when I get the error. I've tested it with it's own battery and works fine. So it has to be power related.
Regarding cams.txt, you were right. That line break didn't show on windows notepad , but notepad++ did. Solved.
The system is starting to work :D
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 11 / February / 2020, 18:10:10
Hi again, testing goes on. I replaced a couple of faulting cameras. I have a couple of questions...
1) Not directly CHDK related, but is there some way to rename USB hubs in Device Manager so they don't show up the same "Generic USB Hub" name? It'd be handy to rename them with different labels in case one of the cameras goes rogue and shows "USB device not recognized", it would be handy for debugging.
2) I've replaced the faulty IXUS 160 and 145 with A2400s, and suddenly when using option 2 for zooming (see #88 for full code) everything fails... It used to work perfectly yesterday, before I replaced those. Nothing in the code has changed. And now I get "failed timeout" errors in 15 cameras that used to work perfectly before. Any ideas about what might be happening?

Code: [Select]
elseif option == '2' then        ---------SET ZOOM
  local zoom=cli.readline('Zoom>')
  mc:cmdwait('call set_zoom('..zoom..')')
3) I've finally implemented mc:check_connections in the menu as option "0". Is this the correct way to go? I've attached the error message I got after checking connections. It's been a last minute quick test and I didn't look if they reconnected.

Code: [Select]
mc=require('multicam')
mc:cmdwait('post_levent_to_ui"UnpressPowerButton"')
mc:connect({list='cams.txt'})
mc:start()
mc:cmdwait('id')
   
repeat
 print('0)CHECK 1)SYNC 2)ZOOM 3)SHOOT AF 4)MANUAL 5)AUTO')
 print('6)DOWNLOAD 7)SHUTDOWN 8)REBOOT')


 local option = cli.readline('mc>')
 
  if option == '0' then            --------CHECK
   mc:check_connections(cam_powercycle_cmd)
   mc:connect({list='cams.txt'})
   mc:start()
   mc:cmdwait('id')
   
 elseif option == '1' then            --------START&SYNC
  mc:cmdwait('rec')
  mc:init_sync()
4) Would something like this work if I needed to send manual commands to the cameras inside the? Or I should be looking for an exit/break to go back to the command line and then relaunch the script? I'm out of my water with this... :(

Code: [Select]
elseif option == '9' then        ---------COMMAND
  local command=cli.readline('>>>')
  mc:cmdwait('call ('..command..')')


In any case, question number TWO is the most important one. The rest are completely optional. Thanks!
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 11 / February / 2020, 21:18:44
Hi again, testing goes on. I replaced a couple of faulting cameras. I have a couple of questions...
1) Not directly CHDK related, but is there some way to rename USB hubs in Device Manager so they don't show up the same "Generic USB Hub" name? It'd be handy to rename them with different labels in case one of the cameras goes rogue and shows "USB device not recognized", it would be handy for debugging.
I don't think so. You may find USBView helpful https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/usbview

Quote
2) I've replaced the faulty IXUS 160 and 145 with A2400s, and suddenly when using option 2 for zooming (see #88 for full code) everything fails... It used to work perfectly yesterday, before I replaced those. Nothing in the code has changed. And now I get "failed timeout" errors in 15 cameras that used to work perfectly before. Any ideas about what might be happening?
Not idea. Timeout without any other errors would normally suggest a software problem. USB connection problems, cameras completely freezing etc should generally cause a connection related error.

Some things to check:
* The default timeout for cmdwait is 10 seconds. I don't think zoom should take this long, if you want to try a longer timeout you could do something like  mc:cmdwait('call set_zoom('..zoom..')',{timeout=20000}) for 20 seconds.
* After the timeout, are you still able to communicate with the cameras? For example, if you send an mc:cmdwait('id') does it work and toggle the IDs on all cameras?
* Try disconnecting the recently added cameras  and see if it still works. If it does, you can try adding one at a time.
* Do any of the cameras move their lenses when you send the zoom command? Or does it timeout without doing anything?
* Electrical issues when trying to move all the zooms at once wouldn't be a surprise, but I'd expect different errors. USB problems might conceivably slow things down enough to trigger a timeout without actually failing, I guess.
Quote
3) I've finally implemented mc:check_connections in the menu as option "0". Is this the correct way to go? I've attached the error message I got after checking connections. It's been a last minute quick test and I didn't look if they reconnected.
The cam_powercycle_cmd is incorrect. mc:check_connections should be passed options you want to use for mc:connect, probably {list='cams.txt'}
In your case, check_connections reports that cameras 18 and 25 need to be restarted. You need to do this manually before continuing.
The errors after reconnect refer to camera 16 (and one that's cut off) but if you didn't pass the list in options, the numbers might be changed.

cam_powercycle_cmd is made for cases where the computer running chdkptp also has hardware control of the camera power supplies. The assumption is you have some external program which manipulates a GPIO or something like that.  It's a field in mc, not an argument to check_connections, so you'd set it once with something like:
Code: [Select]
mc.cam_powercycle_cmd = "/path/to/some_command"
The command would need to be custom code that accepts a camera ID number and controls the hardware.

Quote
4) Would something like this work if I needed to send manual commands to the cameras inside the? Or I should be looking for an exit/break to go back to the command line and then relaunch the script? I'm out of my water with this... :(

Code: [Select]
elseif option == '9' then        ---------COMMAND
  local command=cli.readline('>>>')
  mc:cmdwait('call ('..command..')')
That seems like it should work. Like always, mc:cmdwait will send the code to all selected cameras, so if you want to do different things on some cameras you'd have to use mc:sel first. If you want to execute local code, like you normally do with !, you'd need a different approach. You could either quit your script, or use something like your example above but instead of mc:cmdwait use
Code: [Select]
cli:print_status(cli:execute('exec '..command))
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 12 / February / 2020, 07:36:34
Ok, I'll be testing those options later. I assumed powercycle was an option inside check_connections, my bad. So to clarify the workflow, once some cameras fail (after zooming for example) I'd need to mc:sel({1,3,5}) those problem cameras (1,3,5) and then mc:cmdwait('play') and mc:cmd('call sleep(2000) reboot()') (assuming they're still connected and have not crashed), and once they reboot (it'd be nice to have a beep to know they're back up) I send mc:check_connections. Or I got everything wrong? I could try to do all this from the 9 option I showed before...?
I'm not sure I got the grasp of how check_connections works. If I should reboot cameras manually (meaning physically turning them on and off by hand), I'm afraid that´ll be impossible, because the way the rig is built. I can only turn on/off the whole group of cameras at once.
Regarding that, I made some 3D printed clamps for various cameras models to have the ON button continually pressed. If waterwingz is interested (didn't get any feedback from the battery dummy 3d prints :( ) I could upload them to thingieverse too. Check the attached image.
EDIT:
Code: [Select]
cli:print_status(cli:execute('exec '..command))
That should be '..command)) or '..command..'))  ??
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 12 / February / 2020, 13:20:53
So to clarify the workflow, once some cameras fail (after zooming for example) I'd need to mc:sel({1,3,5}) those problem cameras (1,3,5) and then mc:cmdwait('play') and mc:cmd('call sleep(2000) reboot()') (assuming they're still connected and have not crashed), and once they reboot (it'd be nice to have a beep to know they're back up) I send mc:check_connections. Or I got everything wrong? I could try to do all this from the 9 option I showed before...?
I'm not sure I got the grasp of how check_connections works. If I should reboot cameras manually (meaning physically turning them on and off by hand), I'm afraid that´ll be impossible, because the way the rig is built. I can only turn on/off the whole group of cameras at once.
In the vast majority of cases, I'd expect you need to physically restart the cameras if it's failed in check_connections(). If you can execute a script to reboot, you probably don't need to reboot.
So in your case, you can use it to check if any are failed, but you'd have to reboot the whole group or rig.

Quote
Regarding that, I made some 3D printed clamps for various cameras models to have the ON button continually pressed. If waterwingz is interested (didn't get any feedback from the battery dummy 3d prints :( ) I could upload them to thingieverse too. Check the attached image.
If it's not much trouble, I don't see any reason not to post it. I expect others could find it useful in the future.
Quote
EDIT:
Code: [Select]
cli:print_status(cli:execute('exec '..command))
That should be '..command)) or '..command..'))  ??
The former. ".." concatenates a string. cli:execute expects a string like you'd type in the normal chdkptp command prompt. You want to joint "exec " with whatever you typed. So you could type mc:cmdwait('whatever') and get
Code: [Select]
exec mc:cmdwait('whatever')
(exec is the same as !)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 14 / February / 2020, 07:18:12
I've been quite busy the last couple of days and couldn't spend enough time working in the project. The cause for zooming problems is still unknown (though I suspect it's power related)
There's another issue that's been bugging me. I usually set the exposure values manually to have consistency between pics. I expect some discrepancies between different camera models, but there's one that is responding way off from the rest, it's an A3400. While the exposure on the rest is quite similar, this one is way darker. And even if the EXIF data says it's shot at f4 1/15 and ISO 100, given the amount of noise, I suspect it's shot at much higher ISO. Seems like it's not responding to the code... Is there any other way to set the parameters and see if it responds better?
This is the code regarding that area:

Code: [Select]
elseif option == '4' then        ---------SHOOT w/values
  local dist=cli.readline('Focus Dist>')
  local fnum=cli.readline('F number>')
  local shutter=cli.readline('Shutter speed>')
  local ISO=cli.readline('ISO>')
  mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  mc:shoot({tv=exp.shutter_to_tv96(tonumber(shutter)), svm=exp.iso_to_sv96(tonumber(ISO)),av=exp.f_to_av96(tonumber(fnum)),sd=dist,nd=2})
I'm attaching a screenshot of the folder. It's camera 12, and it's not just -2 darker, it's much noisier too. Maybe it's (another) faulty camera? :(
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 14 / February / 2020, 16:31:46
I expect some discrepancies between different camera models, but there's one that is responding way off from the rest, it's an A3400. While the exposure on the rest is quite similar, this one is way darker. And even if the EXIF data says it's shot at f4 1/15 and ISO 100, given the amount of noise, I suspect it's shot at much higher ISO.
From the specs, it seems like A3400 and A2400 should should be very similar. The zoom, aperture and ISO ranges are the same. In fact, it looks like the only difference is touch screen https://www.dpreview.com/products/compare/side-by-side?products=canon_a2400is&products=canon_a3400is&sortDir=ascending

Neither of these cameras have an adjustable aperture, so the av value should be ignored.

I'm not sure about the noise, underexposed images will look noisy even at low ISO. It would be helpful if you can upload full images somewhere, with one example from the problem camera and one from a normal one, taken in the same multicam shot.

Quote
Seems like it's not responding to the code... Is there any other way to set the parameters and see if it responds better?
Overrides pretty much use the same underlying mechanism. However, testing that camera alone with normal chdkptp commands might help understand what's happening.
You can shoot once without overrides, check what the exposure is, and then shoot with one override at a time to see if they have the expected effect.

Another thing I would check is whether Canon settings are equivalent on the cameras. Are the in the same Canon shooting mode, is the ISO setting the same?
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 17 / February / 2020, 08:57:39
Yeah, all A2xxx and A3xxx are quite the same camera, excepting the touchscreen (which I dont care about), so images should be about the same. Here are a few shots
https://photos.app.goo.gl/GDJ8YisJvqE1KTQp9 (https://photos.app.goo.gl/GDJ8YisJvqE1KTQp9)
Warmer one was shot on friday, with manual input of exposure values (using the menu, values I dont remember). These pics were not shot on the rig, so they don't have the best lighting conditions, it was intentional. Other two were shot today with values inserted (exact figures I inserted are 4 for aperture, 0.05 for shutter, 100 for ISO) and then in Auto. Both Auto pics are correct, but the others...?? Am I doing something wrong in the menu? Am I using the right format for values?? I'm puzzled. Check the code a couple of posts before.
Regarding the zooming issues I reported last week, it was definitely a power issue that's been corrected. Unfortunately I had a terrible mishap and two cameras got fried :( (even with the power sources turned off).
And finally, this was mentioned before in post #28 (sorry I'm going back to the basics). How should I insert this prompt option into the Shoot menu? I see and "end" there, not sure how to deal with it...
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
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 17 / February / 2020, 16:32:05
Warmer one was shot on friday, with manual input of exposure values (using the menu, values I dont remember). These pics were not shot on the rig, so they don't have the best lighting conditions, it was intentional. Other two were shot today with values inserted (exact figures I inserted are 4 for aperture, 0.05 for shutter, 100 for ISO) and then in Auto. Both Auto pics are correct, but the others...?? Am I doing something wrong in the menu? Am I using the right format for values?? I'm puzzled. Check the code a couple of posts before.
I don't think you are doing something wrong, I'd guess it's either a problem with this specific camera, or a bug in the CHDK (or maybe a bug in multicam).
Am I correct that you only have one a3400?  If you have more than one and they all have the same problem that would point to a port bug, but with only one, I'd suspect the camera.

Looking at the images, the auto images are roughly equal, but the exposure recorded is very different:
a2500 is 1/50, ISO 400
a3400 is 1/20, ISO 800
This is more than 2 stops different, and the A3400 is darker. These cameras don't have an adjustable aperture, so that must be the same if focal length is the same.

Ones explanation would be if the ND filter on the A3400 is physically stuck in, or CHDK is somehow putting it in unexpectedly.

Can you try shooting ND not specified, in and out, with no other exposure values set? Like
Code: [Select]
mc:shoot()
mc:shoot({nd=1})
mc:shoot({nd=2})
Main interest is a3400, but including one a2500 to compare would be worthwhile.

Quote
And finally, this was mentioned before in post #28 (sorry I'm going back to the basics). How should I insert this prompt option into the Shoot menu? I see and "end" there, not sure how to deal with it...
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
I'm not sure I understand, the "end" goes with the preceding "if", so you should be able to just put the whole if / end block in your code where the shoot command was.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 17 / February / 2020, 16:51:11
My guess is the ND filter is stuck or misbehaving, but will test tomorrow (see that the shoot menu command includes a nd=2 by default). There "was" another A3400, but got fried.. So can't compare. :( I've decided to stick to the A2xxx series, but i'll do my best to have this one working properly.
Ok, I now understand how to integrate the prompt. It goes nested inside the shooting option, will add it tomorrow.
This whole build is like a game of whack-a-mole, once you fix something, something else breaks... A neverending story   :'(
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 18 / February / 2020, 12:12:18
Hi Reyalp, I updated the album with the ND pictures. I'm not sure how the command works regarding the ND, but in the A3400 I see no change, and surprisingly, there's a variance in the A2500... Well, take a look. Thx
https://photos.app.goo.gl/GDJ8YisJvqE1KTQp9
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 18 / February / 2020, 15:36:13
Hi Reyalp, I updated the album with the ND pictures. I'm not sure how the command works regarding the ND, but in the A3400 I see no change, and surprisingly, there's a variance in the A2500... Well, take a look. Thx
https://photos.app.goo.gl/GDJ8YisJvqE1KTQp9
Thanks, I think that confirms that your A3400 has a mechanical problem: The ND filter is stuck in the "in" position. The best bet is probably to replace it, but you since you mentioned you had another 3400 that died, you could try to swap some components, or you could add special code to always offset exposure for this camera by the ND value, or try percussive maintenance (https://en.wiktionary.org/wiki/percussive_maintenance).

The A2500 is as expected: Underexposed by 2+ stops when the ND is in, and normal when it's out or auto.

In auto mode, your A3400 still exposes correctly (as long as the scene isn't bright enough that it would normally try to use the ND), because it doesn't know the ND is in, it just measures the scene and sets the exposure.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 18 / February / 2020, 16:05:07
Percussive maintenance seems like the way to go. I recovered an SX150 that showed "Lens Error" that way yesterday. I might not be good with electronics, but I'm damn fine slamming cameras :D
I was puzzled with the results since I expected the A2500 to compensate for the ND filter, but yeah.. What you said makes more sense.
Quick question: Don't worry about the code for now, it's just an ou of the box idea. Would it be possible to shoot a quick burst of 3 or 4 images (I know how to do this), and save them as JPGs, but keep the DNG only for the last one? JPG to allow for a quicker burst/write rate and after the last one there'd be time for the DNG to write. This would be an "emergency" shot, that would allow me to combine multiple JPGs to reduce noise with median filter (just a crazy idea, but is it doable?) I would still need to check if the burst rate across different cameras would be quick enough (only the first shot would need to be synced). Thx :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 18 / February / 2020, 17:01:07
Percussive maintenance seems like the way to go. I recovered an SX150 that showed "Lens Error" that way yesterday. I might not be good with electronics, but I'm damn fine slamming cameras :D
One thing you can check is if the camera makes any sound when it tries to put in the ND filter.

If the camera is in half press, the ND filter functions will try to change the ND position immediately, so you can do something like
Code: [Select]
mc:cmdwait('preshoot')
mc:cmdwait('call set_nd_filter(1)')
mc:cmdwait('call set_nd_filter(2)')
If you hear some clicking, then you at least know the actuator can be commanded. If it makes no sound, an electrical problem might be more likely, although it might just be really well stuck.

You could also have the camera repeatedly try to move the actuator while you do percussive maintenance, like
Code: [Select]
!mc:cmdwait('call for i=1,10 do set_nd_filter(1) sleep(100) set_nd_filter(2) end')
Again, this should be done in half press.

Quote
I was puzzled with the results since I expected the A2500 to compensate for the ND filter, but yeah.. What you said makes more sense.
Yep, as a general rule, the Canon autoexposure does not know about CHDK overrides.

Quote
Quick question: Don't worry about the code for now, it's just an ou of the box idea. Would it be possible to shoot a quick burst of 3 or 4 images (I know how to do this), and save them as JPGs, but keep the DNG only for the last one? JPG to allow for a quicker burst/write rate and after the last one there'd be time for the DNG to write. This would be an "emergency" shot, that would allow me to combine multiple JPGs to reduce noise with median filter (just a crazy idea, but is it doable?) I would still need to check if the burst rate across different cameras would be quick enough (only the first shot would need to be synced). Thx :)
It should be possible, but would need code changes in mc:shoot or the camera side code if you don't want to do the DNG as a separate shot.

The simplest would be probably be to shoot one burst and leave the cameras in half press, so you can then just enable raw and do another shoot command. Doing another shot from half press is pretty quick, but you'd still have multicam command delay. I think the only change needed to support this would be allow setting release_half in mc:shoot options.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 19 / February / 2020, 16:44:02
Camera does click with the given commands, but unfortunately and despite some heavy percussion... No change. Will think about whether to compensate the exposure or ditch this one and try to get an A2400. Regarding the 3 JPG+1DNG thing.. I've tested the burst speed in the A2500 and it averages at 1fps, which is not ideal, but who knows it might do the trick? I've tested the technique with a stationary object (a mannequin) and the noise reduction is quite good (combining 3 shots). Anyway, it's just a crazy idea. I have a million more things to deal with a the moment :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 23 / February / 2020, 02:18:13
Regarding the 3 JPG+1DNG thing.. I've tested the burst speed in the A2500 and it averages at 1fps, which is not ideal, but who knows it might do the trick? I've tested the technique with a stationary object (a mannequin) and the noise reduction is quite good (combining 3 shots). Anyway, it's just a crazy idea. I have a million more things to deal with a the moment :)
You won't get much better than 1 fps on cheap Canon P&S, but as you say, if your subject is still enough, the noise reduction is good.

I made some changes to multicam.lua based on earlier discussion in this thread:
init_sync now doesn't print the individual for each sync send by default, just a two line summary per camera. The old style output can be enabled by setting mc.init_sync_verbose=true

In mc:shoot, you can now include an option release_half=false. This will leave halfpress held, so you can changes settings more quickly between shots, or to shoot several shots with same settings. To release halfpress, you can use something mc:cmdwait('call release"shoot_half"'), or just leave out the release_half=false in your final shoot command.

You can get the latest lua file from svn http://subversion.assembla.com/svn/chdkptp/trunk/lua/multicam.lua
As of this posting, it will work with the chdkptp 921 build, but might not work with earlier ones.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 23 / February / 2020, 17:06:26
That's great Reyalp, thanks!! I will be testing it tomorrow :)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / February / 2020, 10:30:19
Should I do this,
If you wanted to start from the cameras current focus distance from auto focus, you could use something like
Code: [Select]
my_focus_table={}
mc:cmwait('preshoot')
local status,result=mc:cmdwait("call return get_focus()")
for id, res in pairs(result) do
 my_focus_table[id]={sd=res.status.status[1]}
end
And then,

Code: [Select]
fsutil.writefile_e(util.serialize(my_focus_table,{compact_arrays=false}),'my_focus_table.txt')
To create a file with the focus distances where the current AF is? Correct?
Regarding the focusing/exposure table, is this the correct format?

Code: [Select]
my_focus_table={
[1]={sd=2100,tv96=0.06,svm=100,av=4,nd=2},
[2]={sd=1980,tv96=0.04,svm=100,av=4,nd=2},
...
A few more things...
- Reboot option makes one of the cameras lens crackle and then crashes while retracting the lens (just one of the A2500, the rest are fine) whereas if I Shutdown, it works fine. Odd...
- Zooming is still very unstable. Most cameras do zoom in/out nicely, but there's four cameras (in the same power source) that always crash. Interestingly, I get a timeout error on about fifteen of them, but excepting these four i can reconnect to the rest. Looks like the error in those four has a cascade effect in the rest?? I'll try to see what happens if a couple of them are battery powered
- I suppose that check_connections and the current workflow doesn't allow for any remote reboot command, right? It's quite incovenient to reboot them manually, given the fact that I installed clamps in the on/off buttons so they power up automatically. (I should install individual switches on all the power lines?)  :(
- Oddly enough, the one single IXUS 165 I (still) have... Always crashes starting the download stage if there's been a shoot before. If I just connect and download, everything works fine.
- A minor thing. Looks like the G10s have a different zooming ratio than the SX150 and A2xxx. If I enter 40 as zoom value, they go way beyond what the others do. Would it be possible to add zoom values to the camopts table? Just a quick idea...
- And finally, while doing the 3D reconstruction JPGs (oddly enough) are giving me better results than DNGs. I didn't expect this, unfortunately the colour balance (even if set to WB_MODE,1) is all over the place. Any ideas on how to get a consistent white balance across the JPGs in the whole rig? I've tried correcting it in Photoshop and Lightroom, but it's very cumbersome and inconsistent :(


I'm still working out many bits and pieces. The goods news is, I've managed to hook 6 Nikon DSLRs to the rig, and shoot them remotely in quite good sync with the CHDKs. Quality improvement is massive! :D
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / February / 2020, 14:13:47
Ok, so I managed to get the focus table to work. But I'm quite puzzled with the results, numbers are all over the place... I've downloaded the pics and they all seem to be in good focus, but look at the results....

Code: [Select]
{
 [1]={
  sd=666
 },
 [2]={
  sd=479
 },
 [3]={
  sd=-1
 },
 [4]={
  sd=731
 },
 [5]={
  sd=505
 },
 [6]={
  sd=1536
 },
 [7]={
  sd=1558
 },
 [8]={
  sd=1244
 },
 [9]={
  sd=1635
 },
 [11]={
  sd=482
 },
 [13]={
  sd=-1
 },
 [14]={
  sd=526
 },
 [15]={
  sd=798
 },
 [16]={
  sd=-1
 },
 [17]={
  sd=2576
 },
 [18]={
  sd=1153
 },
 [19]={
  sd=581
 },
 [20]={
  sd=2201
 },
 [21]={
  sd=842
 },
 [22]={
  sd=559
 },
 [23]={
  sd=-1
 },
 [24]={
  sd=479
 },
 [25]={
  sd=-1
 }
}
Number 3, is a G10, I can see it nailed the focus and can see every detail, but it says (-1) which I guess means it didn't lock focus. How much should I trust these numbers? Are they in different scales/proportions? They differ from around 500 to 2500 and all cameras are placed around 200cm from the subject with the central focus point aimed at it.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 27 / February / 2020, 15:02:12
Number 3, is a G10, I can see it nailed the focus and can see every detail, but it says (-1) which I guess means it didn't lock focus. How much should I trust these numbers? Are they in different scales/proportions? They differ from around 500 to 2500 and all cameras are placed around 200cm from the subject with the central focus point aimed at it.
-1 means "infinity". Aside from that, the values are always in mm, so your cameras are nominally focusing between 0.5 and 2.5 meters, or infinity. These values are not particularly precise. At wide angle, the depth of field is large, and it's normal for "infinity" to start fairly close.

If it looks OK, you could just not worry about it. Or you could just set them all to 2 meters.

If you want to compare focus in an objective way, one simple method is to compare jpeg file sizes with exposure parameters and lighting held constant. Files with more detail will be larger. If the subject you want to focus on doesn't fill the frame, you should crop to the subject area and save that before comparing, otherwise the background being in focus could throw things off. You can batch crop the center of the frame with programs like imagemagick or gmic.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 27 / February / 2020, 17:04:38
Code: [Select]
my_focus_table={
[1]={sd=2100,tv96=0.06,svm=100,av=4,nd=2},
[2]={sd=1980,tv96=0.04,svm=100,av=4,nd=2},
...
FWIW, you should only need to set the values that are different from what is set in the command. Setting them all like you have here is fine too.
Also, as I've mentioned before, many of your cameras do not have an adjustable aperture, so the AV value will be ignored.

Quote
- Reboot option makes one of the cameras lens crackle and then crashes while retracting the lens (just one of the A2500, the rest are fine) whereas if I Shutdown, it works fine. Odd...
I'd suggest switching to playback and letting the lens retract (or using an eventproc to retract it https://chdk.setepontos.com/index.php?topic=6857.msg73227#msg73227) before using reboot.

However, the fact that only one of the a2500 is affected suggests there's a hardware or power supply factor involved too. You could try getting a romlog from that camera.

Quote
- Zooming is still very unstable. Most cameras do zoom in/out nicely, but there's four cameras (in the same power source) that always crash. Interestingly, I get a timeout error on about fifteen of them, but excepting these four i can reconnect to the rest. Looks like the error in those four has a cascade effect in the rest?? I'll try to see what happens if a couple of them are battery powered
This seems very likely to be a power issue.

Quote
- I suppose that check_connections and the current workflow doesn't allow for any remote reboot command, right? It's quite incovenient to reboot them manually, given the fact that I installed clamps in the on/off buttons so they power up automatically. (I should install individual switches on all the power lines?)  :(
As I said before, if the camera is crashed, then there is not going to be any software way to reboot it. To have software controls, you would need to implement the hardware and software to actually control the power supplies (using GPIO and relays for example)

Quote
- Oddly enough, the one single IXUS 165 I (still) have... Always crashes starting the download stage if there's been a shoot before. If I just connect and download, everything works fine.
A romlog and the specific code or sequence of actions involved might be helpful. Also, do you mean ixus 160? There isn't (AFAIK) an ixus165 (https://global.canon/en/c-museum/product/dcc832.html) port.
Quote
- A minor thing. Looks like the G10s have a different zooming ratio than the SX150 and A2xxx. If I enter 40 as zoom value, they go way beyond what the others do. Would it be possible to add zoom values to the camopts table? Just a quick idea...
The zoom value is in "steps" so it will vary a lot between cameras. It would make sense to allow in camopts, I'll look into adding that. An option to set zoom by 35mm equivalent focal length would also be a good idea.

Quote
- And finally, while doing the 3D reconstruction JPGs (oddly enough) are giving me better results than DNGs. I didn't expect this, unfortunately the colour balance (even if set to WB_MODE,1) is all over the place. Any ideas on how to get a consistent white balance across the JPGs in the whole rig? I've tried correcting it in Photoshop and Lightroom, but it's very cumbersome and inconsistent :(
This doesn't surprise me, Canon jpeg processing is very good, and you usually have to work to get better results from raw.
If shots are taken in similar lighting with the same WB setting, you could potentially come up with processing profiles you can re-use between sessions. Raw Therapee lets you do command line processing with saved profiles (https://rawpedia.rawtherapee.com/Command-Line_Options),  I expect similar things are possible with other programs.

Aside from color balance, you may also need to correct lens distortion in CHDK raw. This could vary a lot between camera models.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 28 / February / 2020, 05:25:23
I'd suggest switching to playback and letting the lens retract (or using an eventproc to retract it https://chdk.setepontos.com/index.php?topic=6857.msg73227#msg73227 (https://chdk.setepontos.com/index.php?topic=6857.msg73227#msg73227)) before using reboot.

However, the fact that only one of the a2500 is affected suggests there's a hardware or power supply factor involved too. You could try getting a romlog from that camera.
The reboot and shutdown options are basically the same, cameras go into play mode and then the reboot/shutdown command is sent. I'm puzzled because shutdown works perfectly 100% of the times, but reboot doesn't. I doubt it's power related, since shutdown is OK and this camera is in a safe power source (not the one in conflict with the zoom option). Here's the code.... In any case it's a minor thing, I only mentioned because I find it odd.
Code: [Select]
elseif option == '7' then        ---------SHUTDOWN
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) shut_down()')
  mc:disconnect()
  break
 
 elseif option == '8' then        ---------REBOOT
  mc:cmdwait('play')
  mc:cmd('call sleep(2000) reboot()')
  mc:disconnect()
  break
 end
Quote
This seems very likely to be a power issue.
I couldn't test it yesterday, I will today... That group of cameras (in the same power source) is my main headache, I will test with batteries and split into two power sources if needed. If nothing works, I'll have to install mini switches for each camera and make use of check_connections (which BTW is such a great addition, congrats!)
Quote
A romlog and the specific code or sequence of actions involved might be helpful. Also, do you mean ixus 160? There isn't (AFAIK) an ixus165 port.
Yeah IXUS 160, sorry. The code is basically the same as in #88, the sequence is just Init&Sync, Shoot a couple of pics and then Download... Crashes. If I reboot the whole system and Init&sync and go directly to download, it works fine...
Quote
The zoom value is in "steps" so it will vary a lot between cameras. It would make sense to allow in camopts, I'll look into adding that. An option to set zoom by 35mm equivalent focal length would also be a good idea.
That would be awesome! The camopts table is something else I'll be testing today. AV values will be eliminated and I'll compensate exposure with shutter speed. Just wanted to check if the format is the right one. I'll build the whole table like that, so changes in the future are easier to insert instead of setting individual exceptions (makes more sense in MY head)
Quote
This doesn't surprise me, Canon jpeg processing is very good, and you usually have to work to get better results from raw.
If shots are taken in similar lighting with the same WB setting, you could potentially come up with processing profiles you can re-use between sessions. Raw Therapee lets you do command line processing with saved profiles (https://rawpedia.rawtherapee.com/Command-Line_Options (https://rawpedia.rawtherapee.com/Command-Line_Options)),  I expect similar things are possible with other programs.


Aside from color balance, you may also need to correct lens distortion in CHDK raw. This could vary a lot between camera models.
Canon processing is a bit too harsh with noise reduction and sharpening, but does a great job with distortion correction (which I think is what benefits the 3D reconstruction) That's the reason I was hoping for an in-camera solution. The shooting conditions are always going to be the same, so I'll need to test the best values for each camera (but I believe that's external and not possible to implement in camopts, right?) Edit:I was referring to White Balance here
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 29 / February / 2020, 21:43:48
In revision 930, I added support for setting zoom in mc:shoot. This can be set in camopts like the other values. There is also a zoomwait option which adds a delay after setting the zoom. This may be needed to avoid crashes, especially if you are also setting focus.

Example
Code: [Select]
!mc:shoot({zoom=10,sd=2000,zoomwait=200,camopts={{zoom=50},{zoom=100}}})
This sets the default zoom position to 10, subject distance to 2 meters, wait to 200ms. Camera 1 has zoom set to 50, camera 2 is set to 100.

The zoom number is in the camera zoom steps, which varies widely between models. Some older cameras only have 5 steps, while newer ones can have hundreds. If you want the same effective focal length, you'll need to figure out which zoom step corresponds to the desired focal length on each model.

I looked at setting zoom by EFL, but it would require support in CHDK code.

The reboot and shutdown options are basically the same, cameras go into play mode and then the reboot/shutdown command is sent. I'm puzzled because shutdown works perfectly 100% of the times, but reboot doesn't.
They do different things in CHDK code. A "soft" shutdown in CHDK should take care of retracting the lens just like if you had pressed the power button. A reboot is much less clean.

Quote
I doubt it's power related, since shutdown is OK and this camera is in a safe power source (not the one in conflict with the zoom option).
If you have many cameras of the same model (and firmware, since only 100A exists for A2500), and only one is affected, it suggests a hardware difference somewhere. Whether it's in the camera itself or external hardware is hard to guess.

The different groups of cameras could be affected by different electrical problems. For example, some might be caused by EMI, while others were supply voltage.
Quote
AV values will be eliminated and I'll compensate exposure with shutter speed.
Note G10 and SX150 do have adjustable apertures, so you may need to control those.

Quote
Canon processing is a bit too harsh with noise reduction and sharpening, but does a great job with distortion correction (which I think is what benefits the 3D reconstruction)
FWIW, you can control the sharpening of Canon jpeg a bit using the "my colors" custom setting, which can be controlled using propcases from script.

Quote
That's the reason I was hoping for an in-camera solution. The shooting conditions are always going to be the same, so I'll need to test the best values for each camera (but I believe that's external and not possible to implement in camopts, right?) Edit:I was referring to White Balance here
I think I didn't read your previous post carefully enough, I thought your WB problem was in raw processing. For jpeg, you can only set WB mode from script, and in modes other than custom, the cameras will still adjust the WB for each shot. To use custom WB, you'd need to set it individually on each camera.
There has been some work on finding ways around this:
https://chdk.setepontos.com/index.php?topic=12208.0
It's possible this could be finished into a usable feature.

If you are using raw, you almost certainly need to come up with settings for each camera model externally. White balance can be set completely after the fact, so you wouldn't need to change the camera setting (as long as you can tell your raw software not to use camera WB). Using CHDK raw, you'd almost certainly need to do distortion correction. Some lens profiles and information in this thread https://chdk.setepontos.com/index.php?topic=9268.0
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / March / 2020, 07:53:08

Damm... I'm having a very frustrating morning. I've been finding random connection issues, so I've been toggling ids and checking camera displays all morning. Would it be possible to turn the front LED on when cameras are connected? It'd make things so much easier. I tried it in the past as a command in the header (using set_led) but it never worked. :( I suppose it should be something like...??
Code: [Select]
mc:connect
if connect=true then set_led 9 1
But you know my syntax is not enough to get it working :(
Additionally, my two cents regarding mc:connect({list='cams.txt'}) It's great in order to have a tidy list of cameras. But in the process, since I'm quite often adding/changing/having problems with some of the cameras, newly added cameras are ignored at connect. I think it would be ideal if it would (as and option maybe?) connect to all available cameras, and id known ones according to the table, and new ones randomly... Does this makes sense?
Also, I haven't had time to test the camopts table. I still have zooming issues to resolve. But I will as soon as I can. And I just shot a batch of pcitures with a color calibration table in order to have proper color correction applied to the images. There's still a lot to do...  :'(
EDIT: Something odd is going on with focusing distances. Setting it to 2000, brings it way beyond where it should be. Way past 4 meters, subject is at 2 meters and out of focus. For more precision I gave it a try with cameras zoomed in (shorter DOF) Values do not correspond with real life measurements. I'm puzzled. Here's a gallery with my beautiful test subject and attached is myfocustable.txt too.
https://drive.google.com/open?id=1Np90dhbUvtOv60SBCl80T-Xs8yghUhvK (https://drive.google.com/file/d/1NrENuqdF50ss_T2rRnwRl6o4X8WQhflk/view?usp=sharing)
Edit: Not sure if the link is working, here goes another one....
https://drive.google.com/drive/folders/1Np90dhbUvtOv60SBCl80T-Xs8yghUhvK?usp=sharing
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 03 / March / 2020, 12:52:38
Also, some more stuff... A few cameras are permanently throwing errors when zooming. Got a romlog and they all share the same error: ASSERT!! FocusLensController Is this too bad? Anything to fix it? See attached file A2500. I also attached a romlog for an A2400 which afterwards seems to be working fine, says Hardware Defect, but don't know related to what.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 03 / March / 2020, 21:56:42
Also, some more stuff... A few cameras are permanently throwing errors when zooming. Got a romlog and they all share the same error: ASSERT!! FocusLensController Is this too bad?
What is the specific sequence of events that's triggering the error? Are you using the new zoom option on mc:shoot, or setting zoom as a standalone call to set_zoom()?
Are all of the cameras that are affected A2500? If so, are *all* of your A2500 affected, or just some?
What version of CHDK are you using? To check, you can use
Code: [Select]
!mc:cmdwait('call bi=get_buildinfo() return bi.build_number,bi.build_revision')
The assert by itself may be be one we've seen before related to focus.

Quote
I also attached a romlog for an A2400 which afterwards seems to be working fine, says Hardware Defect, but don't know related to what.
romlog is recorded when there is a problem, and stays there until the next one is recorded. So, if it's working fine, don't worry about it. The romlog is from a lens error, which could happen if the lens was jammed.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 03 / March / 2020, 22:20:26
But you know my syntax is not enough to get it working :(
The syntax to turn an LED on and off from multicam would be like
Code: [Select]
!mc:cmdwait('call set_led(1,1)')
 !mc:cmdwait('call set_led(1,0)')
The first number specifies the LED, and the second specifies on or off. However, which number corresponds to which physical LED varies by camera model. For cameras with only 2 LEDs, usually 0 will be the power / status LED and 1 will be the AF. For others, you need to test.

Quote
Additionally, my two cents regarding mc:connect({list='cams.txt'}) It's great in order to have a tidy list of cameras. But in the process, since I'm quite often adding/changing/having problems with some of the cameras, newly added cameras are ignored at connect. I think it would be ideal if it would (as and option maybe?) connect to all available cameras, and id known ones according to the table, and new ones randomly... Does this makes sense?
Being able to add cameras while keeping the IDs of known ones does make sense.

Quote
EDIT: Something odd is going on with focusing distances. Setting it to 2000, brings it way beyond where it should be. Way past 4 meters, subject is at 2 meters and out of focus. For more precision I gave it a try with cameras zoomed in (shorter DOF) Values do not correspond with real life measurements. I'm puzzled. Here's a gallery with my beautiful test subject and attached is myfocustable.txt too.
I'm not sure what to make of this. As I said before, the number aren't super accurate, but I'd expect them to be a bit closer than your description suggests.

One thing to check is whether focus override is actually working. For example, if you take a series of shots with sd=10, sd=100, sd=1000, sd=10000
You can do this without involving myfocustable.txt

I'm not sure what the images in your gallery are supposed to show. I didn't look closely at all of them, but the ones I did don't seem to be terribly out of focus.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / March / 2020, 05:51:35

The syntax to turn an LED on and off from multicam would be like
Code: [Select]
!mc:cmdwait('call set_led(1,1)')
 !mc:cmdwait('call set_led(1,0)')
I wanted to make it conditional,depending if they connected fine or not (is this a silly option?), thus the if connect=true then !mc:cmdwait('call set_led(1,1)') I think I can manage that by myself, will try later.
Quote
Being able to add cameras while keeping the IDs of known ones does make sense.
That would be sweet
Quote
I'm not sure what to make of this. As I said before, the number aren't super accurate, but I'd expect them to be a bit closer than your description suggests.
One thing to check is whether focus override is actually working. For example, if you take a series of shots with sd=10, sd=100, sd=1000, sd=10000
You can do this without involving myfocustable.txt
I'm not sure what the images in your gallery are supposed to show. I didn't look closely at all of them, but the ones I did don't seem to be terribly out of focus.
The gallery pics are the result of preshoot and writefocustable commands. They are in good focus, distances are shown in the table. What I wanted to show, is the disparity between numbers, given the known distance of the subject (about 2 meters to all of the cameras). There's cameras focused at 90cms and others at 3,5m... Focus override does work, I did tests and figures around 1000 and 1200 worked best generally, but some cameras were out of focus. To me it seems like setting a numeric distance to all of them is unreliable in order to get the best focus. I guess different models interpret these distances differently? I think I'm getting better focus with a simple preshoot and not setting it manually...




What is the specific sequence of events that's triggering the error? Are you using the new zoom option on mc:shoot, or setting zoom as a standalone call to set_zoom()?
Are all of the cameras that are affected A2500? If so, are *all* of your A2500 affected, or just some?
What version of CHDK are you using?
The assert by itself may be be one we've seen before related to focus.
I'll check the version later, but it should be quite recent. The sequence is the one stated in #88. Connect, start, ID, init_sync and then call set_zoom (with the value stated in cli.readline). No camopts table yet, nor mc:shoot zoom... I did it the old fashioned way. Maybe they enter preshoot after init_sync and that causes problems? Regarding the romlog and the A2500s. It happens to 3 of them. Right now I'm not sure if I have more (there's a mix of 2400, 2500 and 2600) will check later, but it could be a model specific problem. In any case, is the assert too bad? are those cameras recoverable?

I'll keep you updated. Thanks
EDIT: It's version 1.4.1 5414. Correction it's two A2500 and one A2600, all have the same Romlog showing the assert mentioned before. And they keep crashing when zooming. The bunch of A2400 and A2300 (and the rest of the cameras) are working fine.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 04 / March / 2020, 13:09:39
I wanted to make it conditional,depending if they connected fine or not (is this a silly option?), thus the if connect=true then !mc:cmdwait('call set_led(1,1)') I think I can manage that by myself, will try later.
Maybe I'm missing something, but the command will never reach cameras that aren't connected.

Quote
The gallery pics are the result of preshoot and writefocustable commands. They are in good focus, distances are shown in the table. What I wanted to show, is the disparity between numbers, given the known distance of the subject (about 2 meters to all of the cameras). There's cameras focused at 90cms and others at 3,5m... Focus override does work, I did tests and figures around 1000 and 1200 worked best generally, but some cameras were out of focus. To me it seems like setting a numeric distance to all of them is unreliable in order to get the best focus. I guess different models interpret these distances differently?
As I said, the values aren't very exact. I'm slightly surprised they're as far off as you've reported, but from your description it sounds like that's the explanation.

Quote
I think I'm getting better focus with a simple preshoot and not setting it manually...
If you're worried about autofocus being reliable, you could start with the camera autofocus value, like your myfocustable.txt. That would let you keep the same distance for shots in the same session, and you could adjust manually in the file if some were off. You would probably want to start from autofocus again any time the zoom level changed.


Quote
EDIT: It's version 1.4.1 5414. Correction it's two A2500 and one A2600, all have the same Romlog showing the assert mentioned before. And they keep crashing when zooming. The bunch of A2400 and A2300 (and the rest of the cameras) are working fine.
I'd suggest trying the 1.5 branch (so called "unstable"), as we fixed some issues related to zoom which cause a crash like this. Probably best to test on one camera before updating the whole rig.

Since the SD cards are already prepared, you can just download the zip from the autobuild http://mighty-hoernsche.de/trunk/ and upload the files with chdkptp. See https://chdk.setepontos.com/index.php?topic=11667.msg124777#msg124777 for an example of how to upload from multicam. Note since your rig has several different cameras, you need to be careful to only upload to cameras with the same model and canon firmware.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 04 / March / 2020, 13:32:18
Maybe I'm missing something, but the command will never reach cameras that aren't connected.
See? I'm SO clever sometimes...  ???

Quote
As I said, the values aren't very exact. I'm slightly surprised they're as far off as you've reported, but from your description it sounds like that's the explanation.

If you're worried about autofocus being reliable, you could start with the camera autofocus value, like your myfocustable.txt. That would let you keep the same distance for shots in the same session, and you could adjust manually in the file if some were off. You would probably want to start from autofocus again any time the zoom level changed.
Yeah, no doubt about it. I will basically have two zoom settings, and the general idea (once everything is working) is to create two presets, one for full body scans and one for face scans. Every detail will be set accordingly in two different tables... Someday...
Quote
I'd suggest trying the 1.5 branch (so called "unstable"), as we fixed some issues related to zoom which cause a crash like this. Probably best to test on one camera before updating the whole rig.

Since the SD cards are already prepared, you can just download the zip from the autobuild http://mighty-hoernsche.de/trunk/ (http://mighty-hoernsche.de/trunk/) and upload the files with chdkptp. See https://chdk.setepontos.com/index.php?topic=11667.msg124777#msg124777 (https://chdk.setepontos.com/index.php?topic=11667.msg124777#msg124777) for an example of how to upload from multicam. Note since your rig has several different cameras, you need to be careful to only upload to cameras with the same model and canon firmware.
I will first update the faulty cameras and see how they respond. Eventually I will update all, but for the moment... will these work together with the older versions? As a side note, today I managed to detect a USB problem that was giving me headaches for the last couple of days. Hooray for me, it's been sorted. And most importantly, the LED on thing is VERY handy! :D
Edit: Quick and silly thing (i haven't really tested without it) but in CHDK/DATA folder I usually have multicam.0 and multicam.cfg, that are never present originally in the builds. These NEED to be there, right?
EDIT 2: OMG!!! They work!!! Thanks!!!!!!!
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 04 / March / 2020, 14:58:35
I will first update the faulty cameras and see how they respond. Eventually I will update all, but for the moment... will these work together with the older versions?
Generally, having a mix 1.4 and 1.5 shouldn't be a problem. However, 1.5 also fixes some issues with USB stability where some cameras models would fail on transfers of certain sizes, so going to all 1.5 is probably a good idea.

Quote
Edit: Quick and silly thing (i haven't really tested without it) but in CHDK/DATA folder I usually have multicam.0 and multicam.cfg, that are never present originally in the builds. These NEED to be there, right?
I'm not sure what these are, chdkptp multicam shouldn't(edit) care about them. Files like that would be created if you ran a script called multicam through the CHDK menu.

CHDK settings are kept in CHDK/*.cfg. You probably want to keep those.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / March / 2020, 07:36:35
It's probably from some script I used long time ago. I recicled the cards from back then, and left it just in case. Good to know that it's not needed. Regarding the update to 1.5, I've updated 5 problem cameras and for now, individually connected to the PC they're working great. Everything is smooth like this. I'm going to put them back in the rig, and see how they perform. Thanks for the tip :)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 06 / March / 2020, 09:34:32
Something I found today. Do not rush the cameras. I've found that after shooting, if the camera is still busy writing to card and I send a zoom command, it will inevitably crash. I was worried about zooming, and I've been doing some thorough tests, since crashes were quite random. And that's what I found out. Not much, but if some cards are a tad slower than the others, give them some time to write, before sending any command. My two cents for today :)
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 14 / October / 2020, 07:30:41
Hi guys! After a few months on standby I'm retaking the project. I'd like to know if there's been any major updates to chdk and multicam since... March? (wow, it's been a long time!) I hope you're all doing great, thanks!

(last thing i did was update CHDK to 1.5 on most cameras)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 14 / October / 2020, 15:06:32
Hi guys! After a few months on standby I'm retaking the project. I'd like to know if there's been any major updates to chdk and multicam since... March? (wow, it's been a long time!) I hope you're all doing great, thanks!

(last thing i did was update CHDK to 1.5 on most cameras)
Not in multicam. The one feature I added was the ability to set the camera clocks (also requires updated CHDK)

In CHDK, there were some improvements to zoom control for digic 4 and later, making lens correction more likely and focus more likely to be kept through zoom changes without crashing. If your cameras are digic 4 or later, and you use set_zoom, this might be worth having.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 15 / October / 2020, 09:24:53
Ok, good to know!
Being able to add cameras while keeping the IDs of known ones does make sense.
This little feature would make my life way easier, now that I'll be adding a few more cameras to the rig. :)  After so long on standby, it feels like I'm starting from scratch again, but it'll only take me a couple of days to be up and running. I'll keep posting new discoveries and issues (hope not too many of the latter). Thx.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 18 / October / 2020, 01:47:33
This little feature would make my life way easier, now that I'll be adding a few more cameras to the rig. :)  After so long on standby, it feels like I'm starting from scratch again, but it'll only take me a couple of days to be up and running. I'll keep posting new discoveries and issues (hope not too many of the latter). Thx.
In the current code, you can use
mc:connect{add=true} to add unconnected cameras. This can't be combined with other options, and the IDs will start after highest existing ID.

So if you have some cameras in a list, and want to add more unlisted cameras, you can just do
Code: [Select]
mc:connect{list='mylist.txt'}
mc:connect{add=true}
If that doesn't fit what you are trying to do, describe how you'd like it to work.

Note I fixed a small bug just now (in r959) which made the IDs increase more than they needed to with add.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 19 / October / 2020, 08:18:51
Wow! That's great to know! I'll give it a go tomorrow, sounds just what I needed. Thanks!!
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 11 / January / 2022, 12:47:04
Hi guys,


Long time no see! I've recently come back to the project. I've already spent a week getting back to it, this is my last Hail Mary at it, my last effort to put it to work. I've found numerous problems on the comeback (supports that came loose, cameras that now refuse to connect, I've forgotten many things about code....). So well, there's been a lot of work involved. Out of curiosity I've just downloaded the latest multicam.lua, hoping that it'd maybe give more stability or solve some issues, but.... Nope. Cameras just don't connect now. I can get back to the old version which worked, but maybe I'm missing something out. I'm attaching part of the error messages.


And this is my code (many blood and tears have been spent on it, so bare with my noobness) :D

Code: [Select]
mc=require('multicam')
mc:cmdwait('post_levent_to_ui"UnpressPowerButton"')
mc:connect({list='cams.txt'})
mc:start()
mc:cmdwait('id')
   
repeat
 print('0)CHECK 1)SYNC 2)ZOOM 3)SHOOT AF 4)MANUAL 5)SHOOT GOOD')
 print('6)DOWNLOAD 7)SHUTDOWN 8)REBOOT 9)COMMAND')


 local option = cli.readline('mc>')
 
  if option == '0' then            --------CHECK
   mc:check_connections()
   mc:connect({list='cams.txt'})
   mc:connect{add=true}
   mc:cmdwait('call set_led(1,1)')
   mc:start()
   mc:cmdwait('id')
   mc:cmdwait('rec')


 elseif option == '1' then            --------START&SYNC
  ---mc:connect({list='cams.txt'})
  ---mc:cmdwait('call set_led(1,1)')
  ---mc:start()
  ---mc:cmdwait('id')
  ---mc:cmdwait('rec')
  mc:init_sync()
 
 elseif option == '2' then        ---------SET ZOOM
  local zoom=cli.readline('Zoom>')
  mc:cmdwait('call set_zoom('..zoom..')')
 
 elseif option == '3' then        ---------SHOOT AF     
  local fnum=cli.readline('F number>')
  local shutter=cli.readline('Shutter speed>')
  local ISO=cli.readline('ISO>')
  mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  ---mc:shoot({tv=exp.shutter_to_tv96(tonumber(shutter)), svm=exp.iso_to_sv96(tonumber(ISO)),av=exp.f_to_av96(tonumber(fnum)),nd=2})
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),nd=2})
  end
 
 elseif option == '4' then        ---------SHOOT MANUAL
  local dist=cli.readline('Focus Dist>')
  local fnum=cli.readline('F number>')
  local shutter=cli.readline('Shutter speed>')
  local ISO=cli.readline('ISO>')
  mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  mc:shoot({tv=exp.shutter_to_tv96(tonumber(shutter)), svm=exp.iso_to_sv96(tonumber(ISO)),av=exp.f_to_av96(tonumber(fnum)),sd=dist,nd=2})
 
 elseif option == '5' then        ---------SHOOT OPTIM
  mc:cmdwait('call set_prop(props.WB_MODE,1)')
  mc:cmdwait('preshoot')
  mc:cmdwait('call click"left" sleep(100) release"shoot_half"')
  mc:shoot({tv=exp.shutter_to_tv96(tonumber(0.05)), svm=exp.iso_to_sv96(tonumber(100)),av=exp.f_to_av96(tonumber(4)),nd=2})
 
 elseif option == '6' then        ---------DOWNLOAD
  local folder=cli.readline('Folder>')
  mc:cmdwait('play')
 --- mc:download_images({dst='c:/download/'..folder..'/CAM${id}/CAM${id}_${shotseq}${ext}',delete=true,verbose=true})
  mc:download_images({dst='c:/download/${ldate,%d%m%y} '..folder..'/${shotseq}_CAM${id}${ext}',delete=true,verbose=true})


 elseif option == '7' then        ---------SHUTDOWN
  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        ---------REBOOT
  mc:cmdwait('play')
  ---mc:cmdwait('call local fh=io.open(get_image_dir().."/IMG_1000.JPG","wb") fh:close()')
  mc:cmd('call sleep(2000) reboot()')
  mc:disconnect()
  break
 
 elseif option == '9' then        ---------COMMAND
  local command=cli.readline('>>>')
  cli:print_status(cli:execute('exec '..command))
  break
 
 end
until option=='9'
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 11 / January / 2022, 13:14:59
I can get back to the old version which worked, but maybe I'm missing something out. I'm attaching part of the error messages.
From the error message, it looks like the version of multicam.lua you are using is different from the chdkptp version. The reference to drive_mode_info was added in r944. The chdkptp binary release including this change is r964, available from https://app.assembla.com/spaces/chdkptp/documents
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 11 / January / 2022, 15:52:02
Thanks so much Reyalp. Yeah, in fact that was the problem, i just updated it. After such a long time without working in the project, is there anything else i should be updating? I see CHDK 1.6 available for most of the cameras (some benefited much from the experimental features)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 11 / January / 2022, 16:15:49
Thanks so much Reyalp. Yeah, in fact that was the problem, i just updated it. After such a long time without working in the project, is there anything else i should be updating? I see CHDK 1.6 available for most of the cameras (some benefited much from the experimental features)
There's not a whole lot of difference between 1.5 and 1.6 for most cameras at this point. The only major feature added is support for floating point math in Lua scripts https://chdk.setepontos.com/index.php?topic=14305.msg145763#msg145763, which probably doesn't matter for you. Bug fixes should mostly be backported to 1.5.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 12 / January / 2022, 12:13:52
Thanks, I just updated a couple to try and seem to be working fine. Is there any option to delete images just as they are downloaded from each camera? Right now they are deleted AFTER the download of all of them is completed.... So if any camera fails in the download process, test images that I've shot, pile up in the cards making the download longer and longer each time. It'd be very neat to delete the files, just after they're downloaded from each camera. Here's my current code:
Code: [Select]
elseif option == '6' then        ---------DOWNLOAD
  local folder=cli.readline('Folder>')
  mc:cmdwait('play')
 --- mc:download_images({dst='c:/download/'..folder..'/CAM${id}/CAM${id}_${shotseq}${ext}',delete=true,verbose=true})  mc:download_images({dst='c:/download/${ldate,%d%m%y} '..folder..'/CAM${id}_${shotseq}${ext}',delete=true,verbose=true})
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 12 / January / 2022, 12:50:44
You could DELETE! :-X with a modification of c("down",>4<) in an adaption of ...
Code: [Select]
luar function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end c("menu") c("down",4) c() c("up") c() c("right") c() sleep(40000)

:o DON´T INVOKE THIS SPELL IF YOU DON´T WANT NO IMAGE!  :o

https://chdk.setepontos.com/index.php?topic=14302.msg147262#msg147262
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 12 / January / 2022, 13:43:26
You could DELETE! :-X with a modification of c("down",>4<) in an adaption of ...
Code: [Select]
luar function c(k,x) for x=1,x or 1 do click(k or "set") sleep(500) end end c("menu") c("down",4) c() c("up") c() c("right") c() sleep(40000)

:o DON´T INVOKE THIS SPELL IF YOU DON´T WANT NO IMAGE!  :o

https://chdk.setepontos.com/index.php?topic=14302.msg147262#msg147262
This really has nothing to do with ikercito's question. They already have a way to delete files, the problem is integrating with multicam in a way that gracefully handles failures. Please, take the time to understand the context before posting a suggestion. Otherwise, people can spend a lot of time trying to understand your answer, only to find out that it doesn't help them at all.

@ikercito:
The current code doesn't support deleting after each download.

Is your main concern not deleting files that have not been successfully download, or just deleting them all?

download_images returns the list of files, so instead of using delete=true, you could do something like
Code: [Select]
files=mc:download_images({...})
mc:delete_files_list(files,{verbose=true})
The advantage of this is if download_images fails, you re-run the delete command.
Or, if you just want to delete all files, no matter what, you can get the list separately:
Code: [Select]
files=mc:imglist({... options ...})
mc:delete_files_list(files,{verbose=true})
mc:imglist takes the same options as download, except obviously the ones that deal with file destination and deleting.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 14 / January / 2022, 04:56:10
Hey Reyalp, thanks! But I'm not sure I understood your solution there.. :) Every shot produces around 400-500Mb of data (jpg and dng), so if the download process fails at any time, those pics are not deleted (cause they are only deleted at the end) So next shot there's double the amount of data to be downloaded thru USB1, that can easily start adding up and requiring 20-30 minutes of download (that can eventually crash again!). My main concern (since I already have a "working" download sequence in the code) would be adding an easy option to erase everything, clear the queue, start fresh, specially when doing test shots. Should I use mc:delete_files_list to point towards DCIM and erase the pics? How?

Thx. :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 14 / January / 2022, 14:05:05
My main concern (since I already have a "working" download sequence in the code) would be adding an easy option to erase everything, clear the queue, start fresh, specially when doing test shots. Should I use mc:delete_files_list to point towards DCIM and erase the pics? How?
Yes, if you just want to delete all the files, get the list with mc:imglist and delete with mc:delete_files_list. Minimal version
Code: [Select]
mc:delete_files_list(mc:imglist())
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 18 / January / 2022, 09:23:34
I had doubts on how to add the code but i finally got it to work, and even added an IF to be sure to delete. It makes my life so much easier now :)

Code: [Select]
elseif option == '8' then        ---------DELETE
  mc:cmdwait('play')
if cli.readline('DELETE (y/n)>') == 'y' then
  files=mc:imglist({...})
  mc:delete_files_list(files,{verbose=true})
  end
And here comes two more questions. Would it be possible to generate a cumulative local log file with the output of mc:start (or mc:check_connections?) with the camera model, libusb port, serial, etc... (basically the verbose that mc:start produces). It would be handy to keep track of cameras and debug in some situations. And also, cameras are all set to shoot jpg and dng, but I see that I'm not using DNGs lately and they weight quite a bit, making the downloads quite long. Is there any option to change this from multicam? Maybe make it conditional and only produce DNGs on certain occasions? Or maybe just ignore them in download and delete them afterwards as a possible solution??
And one final thing, there is one particular camera that always crashes the download. It's the only Canon G9 i have, it works perfectly on every other stage, but despite updating CHDK, changing USB ports and cables (power is the only thing i didn't touch, but it has its own third party adapter and not one of my DIYs), it keeps crashing no matter what I do (read_data failed 0x2ff Error: call failed:I/O error). Any idea to try and save it?
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 18 / January / 2022, 12:16:14
It's the only Canon G9 i have, it works perfectly on every other stage,  ...
;) ... I expect the FAQs "Which firmware?" && "What happens with ... "
Code: [Select]
exec require'camtests'.runbatch{bench=true,shoot=true,filexfer=true,xfersizebugs=true}
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 18 / January / 2022, 12:49:31
And here comes two more questions. Would it be possible to generate a cumulative local log file with the output of mc:start (or mc:check_connections?) with the camera model, libusb port, serial, etc... (basically the verbose that mc:start produces). It would be handy to keep track of cameras and debug in some situations.
The output comes from from the printf and warnf lines lines in mc:connect, which write to stdout and stderr respectively by default (set in util.lua). If you want those lines to log a file, *in addition* to printing to stdout or stderr, you could override those functions like
Code: [Select]
function util.printf(format,...)
 if multicam_log then
    util.fprintf(multicam_log,format,...)
 end
 util.fprintf(util.stdout,format,...)
end
function util.warnf(format,...)
 if multicam_log then
  util.fprintf(multicam_log,"WARNING: "..format,...)
 end
 util.fprintf(util.stderr,"WARNING: "..format,...)
end
-- in chdkptp, these functions are sometimes accessed through util and sometimes
-- through the global, override both
printf = util.printf
warnf = util.warnf
Then you can add functions to start and stop logging:
Code: [Select]
-- open the log
function start_log()
 multicam_log = io.open('multicam.log','a') -- 'a' is a append, use 'w' to overwrite
end
-- close the log and unset log handle
function stop_log()
 multicam_log:close()
 multicam_log = nil
end
Note the above is all untested, typos and other errors are possible.

Quote
And also, cameras are all set to shoot jpg and dng, but I see that I'm not using DNGs lately and they weight quite a bit, making the downloads quite long. Is there any option to change this from multicam? Maybe make it conditional and only produce DNGs on certain occasions?
Sure, you can change the CHDK raw enable setting using the camera side lua function set_raw. To turn raw off, you'd just use
Code: [Select]
mc:cmdwait('call set_raw(false)')
Use true to turn it back on.

Quote
Or maybe just ignore them in download and delete them afterwards as a possible solution??
mc:imglist supports a bunch of filtering options, generally equivalent to what is described in the help for the imls command. The options are mostly documented in rlibs.lua, above ff_findfiles and ff_imglist. To match only jpeg files, you could use fmatch='%.JPG$'. To match only DNG, '%.DNG$'

Quote
And one final thing, there is one particular camera that always crashes the download. It's the only Canon G9 i have, it works perfectly on every other stage, but despite updating CHDK, changing USB ports and cables (power is the only thing i didn't touch, but it has its own third party adapter and not one of my DIYs), it keeps crashing no matter what I do (read_data failed 0x2ff Error: call failed:I/O error). Any idea to try and save it?
Can you get a romlog? https://chdk.fandom.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

When in the process does it crash? Immediately when you try to download, or after downloading, or at some random point?
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 18 / January / 2022, 13:49:56
Now that I'm trying the camera to have a crash and produce a romlog.... Murphy's law, it's not crashing. About the log printing, I'm gonna have to study it a bit longer to understand where to add it. And raw has been succesfully turned off, and downloads are blazing fast now. I'm off from the studio, will report back tomorrow with new findings. As always, thanks so much for your patience and dedication :)
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 18 / January / 2022, 14:02:21
Now that I'm trying the camera to have a crash and produce a romlog.... Murphy's law, it's not crashing. ... :)
The Romlog of the last (multicam-setup) crash is to save ... :-[
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 18 / January / 2022, 16:15:45
Yeah, but for some reason it was empty, or i couldn't save it on time. That particular camera is on a difficult position to reach, is it possible to produce the romlog from CLI?
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 18 / January / 2022, 16:49:40
Yeah, but for some reason it was empty, or i couldn't save it on time. That particular camera is on a difficult position to reach, is it possible to produce the romlog from CLI?
Probably You need to upload a build with Lua Native Calls enabled first.
So, what´s easier to reach...  :-[
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 19 / January / 2022, 01:22:03
Yeah, but for some reason it was empty, or i couldn't save it on time. That particular camera is on a difficult position to reach, is it possible to produce the romlog from CLI?
As caefix says, you need native functions calls enabled to get it via the CLI. This can be done by setting in the CHDK (have to physically access the camera, but only once), setting it in the CFG (perhaps by uploading one from a camera that's easier to reach) or uploading a build that has native calls hard coded on.

If native calls are enabled, you can use
Code: [Select]
!require'extras/devutil'.init_cli()
dromlog
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 26 / January / 2022, 12:25:44
Where/in which file can I find the setting to allow Native Calls? I'm gonna have to upload it from some other camera (must be same model?), cause the G9, aside from being impossible to reach, has a faulty screen (which may be the culprit??) and can't activate the setting in the menus. Camera is quite possibly gonna go to waste, but I'd like to give it a last chance and check the romlog :(
Edit1: Also for some time I couldn't get STICK to work with new builds and installed them manually (it's probably deprecated? any alternative?). Now I'm seeing some 1.5.1 versions error out when downloading, I could only get to download 1.6 unstable for A2300 - 100e and SX150 100a
Edit2: Here's a Romlog for another camera that failed today. SX150-100a, CHDK just updated today after failing a few times before. Any ideas?
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 26 / January / 2022, 12:54:11
Where/in which file can I find the setting to allow Native Calls? I'm gonna have to upload it from some other camera (must be same model?),
You should be able to set it on another camera, and then copy CHDK/CCHDK4.CFG from the camera where you set the setting to the G9, and then immediately restart the G9 without touching any CHDK settings. It does not need to be the same model. (Some model specific settings are reset when you load a CFG on a different model, but not native calls)
Quote
cause the G9, aside from being impossible to reach, has a faulty screen (which may be the culprit??) and can't activate the setting in the menus.
FWIW, you should be able to use chdkptp live view to see the menus even if the physical display is broken. You'd still need to access the physical buttons to navigate the CHDK menu though, so the CFG route is probably easier.

Quote
Camera is quite possibly gonna go to waste, but I'd like to give it a last chance and check the romlog
An otherwise functional camera with a broken screen is still useful for development, so if you're planning to throw someone here would probably take it.

Quote
Also: For some time I couldn't get STICK to work with new builds and installed them manually. Now I'm seeing some 1.5.1 versions error out when downloading, I could only get to download 1.6 unstable for A2300 - 100e and SX150 100a
Do you mean errors downloading from  http://mighty-hoernsche.de/ or through stick?
The 1.5.1 build looks OK to me, but sometimes you have to do a full page refresh.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 26 / January / 2022, 18:42:20
Thanks Reyalp, I never thought about the Live view! Not in this case maybe, but sounds handy for other situations. I'll go the CFG way for now and post the romlog. G9's been functional up until now, I hope I can keep it.
Regarding the downloads, I don't know maybe it was me, but there were a couple of builds that errored out on mighty-hoernsche. I suppose Stick has been deprecated? It was very handy :(
And did you have time to check the romlog of the Sx150 I posted before? That camera has been functioning perfectly since the first day I started all this, first one I bought! I hope it can go back to the rig.
Thanks again mate :)
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 26 / January / 2022, 20:16:18
That camera has been functioning perfectly since the first day I started all this, first one I bought! I hope it can go back to the rig.
I missed that. Can you give any detail of what of what you were doing when the camera crashed? Also, if possible, what CHDK version was running at the time?

Note the romlog says "Occured Time  2017:12:17 14:56:24"
Can you check if the clock is set to 2017? If not, this is probably a very old one from a different failure.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / January / 2022, 10:28:43
I'll check, but most probably the date is not set correctly (in any of the cameras, since they're most of the time without power). Just wondering... Is there an option to feed the date and time of PC to all the cameras at every startup? I remember we skipped this at the beginning of this thread, for simplicity. I believe it had version 1.4.1 with the first crashes, and I updated to 1.6 to see if it helped. Im on my way to the studio now, but I think camera refused to connect or sync, I don't remember it getting it to the shooting stage.
Edit: Confirmed SX150 errors at mc:connect
Title: Re: A couple of Multicam doubts and general help
Post by: Caefix on 27 / January / 2022, 11:23:11
Regarding the downloads, I don't know maybe it was me, but there were a couple of builds that errored out on mighty-hoernsche. I suppose Stick has been deprecated? It was very handy :(
You could compare the dates of DISKBOOT.BIN & /../MODULES/..  8)
Maybe the transfere had a leak...  :-X
Code: [Select]
if so then where() end
Edit: Might help, too ... http://zenoshrdlu.com/cfgedit/chdkcfgedit.html
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 27 / January / 2022, 11:29:59
Ok, just checking dates, i thought I got the correct romlog but seems to be old. Will provide new one.
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 27 / January / 2022, 12:45:35
I'll check, but most probably the date is not set correctly (in any of the cameras, since they're most of the time without power). Just wondering... Is there an option to feed the date and time of PC to all the cameras at every startup?
Yes,
Code: [Select]
mc:setclock()
This requires at least CHDK 1.5.1 and chdkptp r941, and should be run after init_sync()

Quote
I remember we skipped this at the beginning of this thread, for simplicity. I believe it had version 1.4.1 with the first crashes, and I updated to 1.6 to see if it helped. Im on my way to the studio now, but I think camera refused to connect or sync, I don't remember it getting it to the shooting stage.
Edit: Confirmed SX150 errors at mc:connect
Can you describe what happens when it errors? Does the camera immediately shut down? What is the error on the chdkptp side?
Can you connect to the camera with chdkptp normally, without involving multicam?

Ok, just checking dates, i thought I got the correct romlog but seems to be old. Will provide new one.
The way the romlog works is when the camera crashes, the firmware saves the crash information to a specific block in the camera onboard flash memory (the "ROM" where the firmware is stored) and then when you get the romlog, that block is read out to a file on the SD card. Both the CHDK romlog menu and the chdkptp dromlog command delete any existing romlog file form SD  beforehand, so the only way you should be able to get an old one is if that's what actually stored in flash.

It is possible for the camera to crash or have other errors without recording a romlog.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 10 / February / 2022, 09:13:27
Hey guys, I've been out for a few days and I'm back at it now. I finally did not produce any romlog, since I realized there was no crash as such, only these cameras failed to connect. They'd continue on after the error, so there was no actual crash, they just disconnected from chdkptp. I suspect it all comes from the USB network I have, since after swapping a few things around, cameras that failed to connect are now working perfectly. BUT... Most of the times there's some camera that refuses to connect (ptp_opensession error, or failed i/o error...), so I'm beginning to think that it's all related to the USB network being somehow saturated (I have only 32 cameras, is this possible??)


If I test it by individual groups (I have 4 independent groups of cameras) they all seem to work fine, but if I try them all at once, there's surely gonna be one camera that'll fail. I can't come to any conclusion right now, this is nerve wracking, seems so random...

Is there any big rule for USB connections that I'm missing out? I have the cameras distributed on 5 different powered USB hubs, each comes to a different USB port on PC thru an array of different lenghts of cable, three are 3 meters long, and two others are "special" 5 meter ones. Cabling seems not to be the issue here, but i just don't know anymore. I'm absolutely puzzled by what's happening.... :(

EDIT: Also, I tried setclock command and gave errors on a few cameras (outdated CHDK surely), can anyone remind me how to update CHDK remotely? My mind is blocked right now  :-[
Title: Re: A couple of Multicam doubts and general help
Post by: reyalp on 10 / February / 2022, 13:13:45
BUT... Most of the times there's some camera that refuses to connect (ptp_opensession error, or failed i/o error...), so I'm beginning to think that it's all related to the USB network being somehow saturated (I have only 32 cameras, is this possible??)
The number of cameras should be ok, but the chance of running into electrical issue or flaky hubs goes up.

Quote
EDIT: Also, I tried setclock command and gave errors on a few cameras (outdated CHDK surely), can anyone remind me how to update CHDK remotely? My mind is blocked right now  :-[
You just need to unzip the CHDK zip somewhere, and then use

Code: [Select]
mup c:/path/to/zip/files A/
That's for a single camera using the regular cli. You can do multiple cameras using multicam like the example on https://chdk.setepontos.com/index.php?topic=11667.msg124777#msg124777 but you need to be sure only cameras of a single model and firmware version are connected.

Also, you might want to keep a copy of the version currently installed on the camera, so you can go back to a known configuration if the update breaks something.

You can use something like
Code: [Select]
mdl DISKBOOT.BIN PS.FI2 c:/path/to/save/on/pc
to backup your CHDK install.
Title: Re: A couple of Multicam doubts and general help
Post by: ikercito on 25 / October / 2022, 12:28:17
Hi guys, this is a message to thank everyone of you who helped in the development of the project. Unfortunately the project is going to be finally shut down during the next month. It's been a rollercoaster of emotions, of many successes but also many frustrations. In the process I've learned all sorts of subjects, from electronics, coding, engineering, 3d printing... all in which I started from scratch.
The great help from this community helped in bringing it forward, but there's three main reasons I must call this a failure. First my lack of expertise to deal with such a complex task involving so many subjects, second the realization that with such a tiny budget a 360 full body photogrammetry scanner is an almost impossible feat to achieve (one cannot compete with a proper array of high end Dslr cameras and a professional system to do so), and third realizing that with the hardware I had, despite adding more and more cameras the quality that resulted would never match the systems i mentioned earlier.
But it's been an amazing project to work on and a learning process that I've loved (and hated at times). I wanna thank Reyalp for all the help he provided in the process. You're a godsend with infinite patience, without you this would have never been possible. Thanks so much.
I hope all the info that was shared here can help people develop their own projects, I wish them the best luck. It's been an incredible journey, thanks again.