CHDKPTP File Downloading - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum  

CHDKPTP File Downloading

  • 92 Replies
  • 31297 Views
*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #10 on: 27 / November / 2017, 21:48:28 »
Advertisements
So I just started working on implementing the power sync and I'm having some trouble. When I plug my camera into the switch and the switch into my computer it won't connect to chdk_ptp. Does this mean my switch isn't wired properly or do I have to run a command first?
Does it work with a normal cable? If so, the issue is probably in the switch.

Do you know how the switch is wired? To use chdkptp with hardware remote triggering, the +5 volt line should normally be connected, and only disconnected to trigger a shot.
Quote
Edit 2: Nevermind I just had to put the command directly into the action function, but it no longer prints what it's supposed to in the console. Before I would type !return mc:stage(1) and it would print "__ Cameras Detected" by returning that string at the end of the function. Any advice?
Try
printf(mc:stage(1)), or just change mc:stage to do the printf itself.


Also, FWIW, the version of chdkptp I released yesterday supports some things you asked about earlier:
Quote
I can now change the download folder and delete the images off the cameras afterwards, but is there some way I can delete the DCIM sub directory as well?
To delete DCIM and everything it contains, you could use something like
Code: [Select]
local myfiles=t=mc:find_files('A/DCIM',{dmatch='.*',fmatch='.*',dirsfirst=false,ff_func='find_files_all_fn'})
mc:delete_files_list(myfiles)
If you want to see what would be deleted, you can use pretend, like
Code: [Select]
mc:delete_files_list(myfles,{pretend=true})
If you just want to delete the image directories without deleted DCIM or the CANONMSC directory, you could use something like
Code: [Select]
local myfiles=mc:find_files('A/DCIM',{dmatch='%d%d%d___%d%d',fmatch='%d%d%d___%d%d/.*',dirsfirst=false,ff_func='find_files_all_fn'})

For downloading images, you can use ${shotseq} substitution I mentioned was in SVN, so if you take several shots and want the images numbered by shot (rather than whatever the each camera counter is set at), you can use something like
Code: [Select]
mc:download_images({dst='${id}_${shotseq}${ext}'})
Don't forget what the H stands for.

Re: CHDKPTP File Downloading
« Reply #11 on: 30 / November / 2017, 14:42:38 »
I've got everything working well but when I execute
Code: [Select]
mc:cmdwait('rec')how to I stop it from printing "rec" to the console? I'll attach a pic of what I'm seeing.

How do I get rid of the highlighted bits?

edit: Oh also if there a variable I can grab that tells me how many images I downloaded with download_images, and how do I tell printf to start a new line in the console?

edit2: Sorry to keep asking questions, but is there a boolean that says whether or not there's a script currently running on the cameras, or a start function that only starts a script if there isn't one already running?
« Last Edit: 30 / November / 2017, 15:30:21 by jdstech »

*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #12 on: 30 / November / 2017, 16:15:14 »
I've got everything working well but when I execute
Code: [Select]
mc:cmdwait('rec')How do I get rid of the highlighted bits?
This is controlled by an option to mc:cmd/mc:cmdwait, described in the source:

https://app.assembla.com/spaces/chdkptp/subversion/source/781/trunk/lua/multicam.lua#ln682

so you could use mc:cmdwait('rec',{printcmd=false})

There currently isn't a way to set the default without modifying the code, but I'll add one in a bit.

Quote
edit: Oh also if there a variable I can grab that tells me how many images I downloaded with download_images,
You would have to modify the download_images function. I'll probably change to allow returning the list of images.

Quote
and how do I tell printf to start a new line in the console?
\n
is the newline character.

Quote
edit2: Sorry to keep asking questions, but is there a boolean that says whether or not there's a script currently running on the cameras, or a start function that only starts a script if there isn't one already running?
There isn't currently a way to do this in multicam. You can check if an individual camera is running a script by using script_status on the connection object, see https://app.assembla.com/spaces/chdkptp/subversion/source/781/trunk/lua/multicam.lua#ln333

It should be fairly easy to add an option to only start on cameras without a script running. Note however that this doesn't tell you if they are running the correct script.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #13 on: 02 / December / 2017, 17:30:20 »
There currently isn't a way to set the default without modifying the code, but I'll add one in a bit.
The current svn version (790) now allows setting the default. So you can use
!mc.cmd_defaults.printcmd=false
to disable command printing by default.

Quote
edit: Oh also if there a variable I can grab that tells me how many images I downloaded with download_images,
mc:download_images now returns the table of images downloaded, so you could use that to display a count. Note the returned table includes the file list for each camera (indexed by camera mc_id), and these could vary between cameras. So to get a count of total images downloaded, you'd need to do something like
Code: [Select]
local total=0
for id,imgs in pairs(list) do
 total=total+#imgs
end
printf("total %d\n",total)
If you want the total from a single camera, you'd have to pick one.
Quote
edit2: Sorry to keep asking questions, but is there a boolean that says whether or not there's a script currently running on the cameras, or a start function that only starts a script if there isn't one already running?
I thought about adding this, but if the camera is already running the multicam script, start() just prints a harmless warning, stops it, and restarts it. If it's running some other script (that doesn't respond to 'exit' as a message), it may fail, but I don't see the use case for ignoring that.
Don't forget what the H stands for.


Re: CHDKPTP File Downloading
« Reply #14 on: 28 / December / 2017, 12:40:06 »
Hello again, hope you guys had a happy holiday.

Lately I've been working on my image naming convention. I need the image names from each camera to stay consistent in order to save the camera positions, and naming using the cameras serial numbers seems like the best way.

Code: [Select]
self:download_images({dst = 'imgdump/${serial}.JPG'})
=>sjh1iu88ass291.JPG (This isn't an actual serial number, I just mashed random keys on my keyboard but you get the point)

Which is all well and good, but after taking 60 pictures and opening up my image folder I feel like I've just stepped into the matrix and/or a twitch chat. I'd like to condense the image names down to the first 3 characters of the serial code, but if I try to use something like
Code: [Select]
self:download_images({dst = 'imgdump/${string.sub(serial,1,3)}.JPG})
I get errors.

I assume I'm not allowed to use string.sub inside of download_images but since serial in a property of download images I'm not sure how to avoid this.

edit: Also these harmless errors I keep getting when I try to start a script while one is already running are a bit obstructive, is there some way to prevent them from printing to the console?

edit 2: Just commenting out the warnf line that printed them worked but I'm still getting one error occasionally,
Code: [Select]
update_mode_list failed a script is already running
« Last Edit: 28 / December / 2017, 13:09:35 by jdstech »

*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #15 on: 28 / December / 2017, 16:29:43 »
I'd like to condense the image names down to the first 3 characters of the serial code, but if I try to use something like
Code: [Select]
self:download_images({dst = 'imgdump/${string.sub(serial,1,3)}.JPG})
I get errors.

I assume I'm not allowed to use string.sub inside of download_images but since serial in a property of download images I'm not sure how to avoid this.
Yes, the ${blah} strings are chdkptp specific substitution strings, not Lua code. I've been meaning to add some generic string ones though, I'll take a look at this a bit later.

Quote
edit 2: Just commenting out the warnf line that printed them worked but I'm still getting one error occasionally,
Code: [Select]
update_mode_list failed a script is already running
I guess you are using the GUI. I would generally suggest using the CLI (terminal/console) interface for multicam. You can do this by starting chdkptp with -i.

You may also be able to avoid this by setting
set gui_dev_check_interval=0
This will prevent the gui from periodically trying to update the UI for the currently connected cameras. This is probably a good thing to do when running multicam regardless of the warnings. You can use the gui startup file user_gui.chdkptp (described in USAGE.TXT) to set this every time.
Don't forget what the H stands for.

Re: CHDKPTP File Downloading
« Reply #16 on: 28 / December / 2017, 17:00:51 »
I'd use CLI but I'm developing this system for commandlineaphobes (totally a real word).

So if I connect all 60 cameras and save their serial numbers, is there a way I can quickly iterate through all those serial numbers when one camera decides to die out and figure out which one died? So like if I can only connect to 58 the program would download a new list and cross reference the two list to see which serial numbers were missing?

*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #17 on: 28 / December / 2017, 19:42:10 »
I'd use CLI but I'm developing this system for commandlineaphobes (totally a real word).
Fair enough, though unless you rework the GUI to actually support multicam, it may be a source of confusion. The GUI is really only intended to work with one camera at a time, and doesn't expect other scripts to be running. You could of course implement your own multicam specific GUI in lua.

Quote
So if I connect all 60 cameras and save their serial numbers, is there a way I can quickly iterate through all those serial numbers when one camera decides to die out and figure out which one died? So like if I can only connect to 58 the program would download a new list and cross reference the two list to see which serial numbers were missing?
Not exactly the same thing, but this may a useful starting point https://chdk.setepontos.com/index.php?topic=13212.msg135500#msg135500

I can probably add an option or a similar function to just report the dead ones and remove them from the current list.
Don't forget what the H stands for.


Re: CHDKPTP File Downloading
« Reply #18 on: 29 / December / 2017, 06:03:06 »
I can probably add an option or a similar function to just report the dead ones and remove them from the current list.

I started to look at python serial in connection with mc.cam_powercycle_cmd and somehow then got distracted thinking to automate aspects of Blender (via python) as part of a photogrammetry pipeline so haven't yet implemented anything for powercycle testing.

Anyway, the addition you refer to could also, probably, be very useful generally (& in my own circumstances - hoping that 2018 speeds implementation a bit  :D

 

*

Offline reyalp

  • ******
  • 14080
Re: CHDKPTP File Downloading
« Reply #19 on: 30 / December / 2017, 03:19:40 »
Lately I've been working on my image naming convention. I need the image names from each camera to stay consistent in order to save the camera positions, and naming using the cameras serial numbers seems like the best way.
I forgot to mention this before, but FWIW, you can use the "list" functionality to persistently map serial numbers to multicam id, which is available in download_images as ${id}.

Essentially, connect to the cameras, use mc:save_list('mylist.txt') and then when you want to connect later, use mc:connect({list='mylist.txt'})

save_list uses the currently selected cameras, so you can use mc:sel() to make subset lists.

You can also change the ids of cams around using set_id(), and you can use the mc:cmdwait('id') camera side command to display IDs on the camera screens.

Quote
I assume I'm not allowed to use string.sub inside of download_images but since serial in a property of download images I'm not sure how to avoid this.
The lua files in the current SVN (r798) allow you to use ${s_sub,...} to do the equivalent of lua string.sub(). So to name using the last 3 digits of the serial number, you could use
mc:download_images{dst='${s_sub,${serial},-3}${ext}'}
As always, it's a good idea to use pretend=true to verify that you are getting what you want.
Note the above example would only work if you have one image per cam, otherwise you need to include something that is unique per shot like ${imgnum} or ${shotseq}

I also added a bunch of other string manipulation functions, described in USAGE.TXT.
Don't forget what the H stands for.

 

Related Topics