chdkptp - alternative ptp client - page 76 - General Discussion and Assistance - CHDK Forum

chdkptp - alternative ptp client

  • 1106 Replies
  • 517727 Views
*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: alternative ptp client
« Reply #750 on: 29 / November / 2014, 14:56:49 »
Advertisements
I would like to add a progress bar for the image download function in the user tab. Is there a way to get informations about the progress and the total number of files from the cli functions 'imdl' and 'mdl'?

msl
CHDK-DE:  CHDK-DE links

*

Offline reyalp

  • ******
  • 14082
Re: alternative ptp client
« Reply #751 on: 29 / November / 2014, 16:52:29 »
I would like to add a progress bar for the image download function in the user tab. Is there a way to get informations about the progress and the total number of files from the cli functions 'imdl' and 'mdl'?
Not from the CLI command, but it should be possible using the underlying chdku functions, possibly with minor changes.

If you look at cli.lua imdl, it uses con:imglist to get a list of files, so you can get the total number. It includes stat values, so you could get size too.

imglist_download accepts an opt value called info_fn. This is normally used in verbose mode to display the file names, but you could provide your own. For a download, it will be called like
      opts.info_fn('%s->%s\n',src,dst)
but it may also be called with other values, so you'd have to do some fiddling to get the file download.

Adding a new callback like progress_fn() would probably be better.

chdku mdownload doesn't use a separate function to make the file list, so it would need additional changes. A simple way to do it would be to add a callback to opts that gets called with files after the ff_mdownload call. Splitting it to work like imdl might be better.

You might also run into issues actually updating the GUI: If you call chdku code directly the gui will be blocked until the entire operation completes. If you use the cli:execute, it uses a coroutine that yields to the gui when chdku code sleeps. You might be able to work around this by calling your code through the exec (!) cli command. However, I don't think the current code yields while it's actually downloading the files anyway, so that might need to be done in the progress function.

This is something I would like to have, so I'd be willing to help add the necessary hooks if the above is more than you want to get into.

If you make major changes outside of the gui_user file, I'd prefer to have a patch to look at before it gets checked in.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14082
Re: alternative ptp client
« Reply #752 on: 22 / December / 2014, 19:40:03 »
In r660, I added the ability to use a file with lua, luar, and exec. So if you have a long complicated thing you don't want to type every time, you can just edit in an editor and then use
Code: [Select]
= <myfile.lua

to run it on the camera.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #753 on: 22 / December / 2014, 21:16:49 »
In r660, I added the ability to use a file with lua, luar, and exec.
Nice.   I actually thought it already did that but that I had just not puzzled it out.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: alternative ptp client
« Reply #754 on: 19 / January / 2015, 12:07:14 »
reyalp, how could my application have live view streamed to it from chdkptp commands? If it's lvdump, how do I use it?

I'm creating a stop motion application with onion skinning, using Visual Basic 2010.

*

Offline reyalp

  • ******
  • 14082
Re: alternative ptp client
« Reply #755 on: 19 / January / 2015, 12:57:50 »
reyalp, how could my application have live view streamed to it from chdkptp commands? If it's lvdump, how do I use it?

I'm creating a stop motion application with onion skinning, using Visual Basic 2010.
I'm not really clear what you are trying to do. If you want to display the live view inside your application, you will probably need to do some hacking, chdkptp is primarily designed to be a standalone client, not something embedded in other apps.

The lvdumpimg command can send a stream of netpbm images to a pipe (or sequential files), but it will only do that for a fixed count, and you can't control the camera in any other way until all the frames are saved.  See discussion around http://chdk.setepontos.com/index.php?topic=6231.msg114468#msg114468

It wouldn't be too hard to come up with a control mechanism that let you end the sequence from an external application. It might be OK if you just closed the pipe on the target, or you could use a control file.

The lvdump command is similar to lvdumpimg, except it saves raw protocol data to a single file. It doesn't currently support piping, but that wouldn't be too hard to add.

The GUI lets you display live view while controlling the camera, but it would probably be inconvenient to integrate with your application. You could probably modify the code to send each live view frame to some form of IPC.

Almost all of chdkptp except the low level communication and bulk data processing is done written in Lua. This includes the GUI, which uses IUP (http://www.tecgraf.puc-rio.br/iup/). It's intended to be customizable, if you can program in  VB, you can probably learn Lua too.

If I was going to embed chdkptp in another application, I would probably write a new front end like the CLI or GUI, but with some IPC interface to talk to the application. Doing this in some generic way is on my TODO list, but so are a lot of other things...
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #756 on: 19 / January / 2015, 16:31:30 »
I'm not really clear what you are trying to do. If you want to display the live view inside your application, you will probably need to do some hacking, chdkptp is primarily designed to be a standalone client, not something embedded in other apps.

I just want to use chdkptp like ffmpeg.

Thanks for the link. Not sure how to access live view piped images with VB. I tried to at least save them to my hard drive to access them that way, but the below code didn't work:
Code: [Select]
lvdumpimg -pipebm -count=3 -vp=tmp.ppm -bm='convert tmp.ppm - -resize 720x405! -layers merge C:\Users\Web\Pictures\liveview.png'
Has something changed? Until I figure out how to recieve piped images, saving them to my hard drive for retrieval also works, preferably without my camera's UI overlay.
« Last Edit: 19 / January / 2015, 16:38:19 by JeremyLavine »

*

Offline reyalp

  • ******
  • 14082
Re: alternative ptp client
« Reply #757 on: 19 / January / 2015, 16:55:36 »

Thanks for the link. Not sure how to access live view piped images with VB. I tried to at least save them to my hard drive to access them that way, but the below code didn't work:
Code: [Select]
lvdumpimg -pipebm -count=3 -vp=tmp.ppm -bm='convert tmp.ppm - -resize 640x480! -layers merge C:\Users\Web\Pictures\liveview.png'
Has something changed? Until I figure out how to recieve piped images, saving them to my hard drive for retrieval also works, preferably without my camera's UI overlay.
If you can describe how it didn't work, that would be helpful.

The most current syntax should be described in the help and USAGE.TXT.

One thing to watch out for is that there is an unrelated windows command called convert. The above command expects the imagemagick convert command. You can specify the absolute path, or copy the imagemagick convert.exe to something like imconvert.exe

Your example works for me if I make sure it gets the right convert command.

The pipe functionality expects to start the executable being piped to, it can't send directly to an already running executable. On unix you could probably send to a named pipe using regular file syntax, but windows doesn't support this. You could write a shim program that receives data from stdin and sends it to a windows named pipe, socket or whatever.
Don't forget what the H stands for.


Re: alternative ptp client
« Reply #758 on: 19 / January / 2015, 17:11:03 »
imagemagick?

Thought chdkptp converted netpbm images to pngs, or jpegs when I saw that command. So I also need imagemagick to convert for Windows? No wonder it didn't work.

*

Offline reyalp

  • ******
  • 14082
Re: alternative ptp client
« Reply #759 on: 19 / January / 2015, 20:45:47 »
Thought chdkptp converted netpbm images to pngs, or jpegs when I saw that command. So I also need imagemagick to convert for Windows? No wonder it didn't work.
chdkptp outputs ppm and pam for the live view and UI overlay, respectively. The command you quoted converts this to a single png, by outputting the the viewport to a file (-vp=tmp.ppm) and then piping the the bitmap data to convert (-pipebm -bm=...) which scales, merges and corrects the aspect ratio of the results.

If you want to work directly with the ppm and pam files (which are incredibly simple formats) you can just use -vp=foo.ppm -bm=foo.pam, without involving imagemagick. You will have to take care of alpha blending, scaling and aspect ratio correction yourself in that case.

Note if you don't care about showing the camera OSD, you can leave the bitmap out entirely.
Don't forget what the H stands for.

 

Related Topics