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

A couple of Multicam doubts and general help

  • 159 Replies
  • 70938 Views
Re: A couple of Multicam doubts and general help
« Reply #10 on: 06 / November / 2019, 12:56:07 »
Advertisements
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! :)

*

Offline reyalp

  • ******
  • 14079
Re: A couple of Multicam doubts and general help
« Reply #11 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.
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #12 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
« Last Edit: 06 / November / 2019, 13:03:28 by ikercito »

*

Offline reyalp

  • ******
  • 14079
Re: A couple of Multicam doubts and general help
« Reply #13 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.
Don't forget what the H stands for.


Re: A couple of Multicam doubts and general help
« Reply #14 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 :)

*

Offline reyalp

  • ******
  • 14079
Re: A couple of Multicam doubts and general help
« Reply #15 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
« Last Edit: 06 / November / 2019, 16:07:04 by reyalp »
Don't forget what the H stands for.

Re: A couple of Multicam doubts and general help
« Reply #16 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!

*

Offline reyalp

  • ******
  • 14079
Re: A couple of Multicam doubts and general help
« Reply #17 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, 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.
Don't forget what the H stands for.


*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: A couple of Multicam doubts and general help
« Reply #18 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.
« Last Edit: 09 / November / 2019, 13:04:54 by Caefix »
All lifetime is a loan from eternity.

Re: A couple of Multicam doubts and general help
« Reply #19 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) ???
« Last Edit: 10 / November / 2019, 08:48:38 by ikercito »

 

Related Topics