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

chdkptp - alternative ptp client

  • 1106 Replies
  • 551945 Views
*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #580 on: 10 / March / 2014, 02:14:25 »
Advertisements
I've uploaded snapshot 492 to the files area https://www.assembla.com/spaces/chdkptp/documents

There are two major additions. Both were discussed earlier in the thread, but to get everything in one place I'll document them here.

1) rsint (remote shoot, interactive)
This is a module in extras that allows you to remote shoot in continuous mode, while controlling the timing of the shots yourself. This requires CHDK 1.3, because it uses the shoot hook functionality. It currently can only be used in console CLI mode, not in the GUI.

To load the module use
!require'extras/rsint'.init()
This adds the rsint cli command. It takes the same options as regular rs for exposure settings and file formats.
When you use the rsint command, you get a rsint>
The prompt accepts 3 commands
s - shoots and waits for another command
l - shoots and exits rsint
path <new file path> - sets the output path. This is treated the same way as the output path option to rs. If you don't specify a path, it resets to default (i.e IMG_NNNN.JPG)

2) lvdumpimg
This command allows dumping live view frames to netpbm format images. This saves the viewport data as ppm and the bitmap (ui overlay) as pam.

The output files are in their native resolution, meaning that the aspect ration is not correct. Programs like imagemagick can be used to rescale them. The pam format is used for the UI overlay to support the alpha channel, but it is not as widely supported as ppm. You can use imagemagick or the netpbm tools to convert it to other formats.

The -vp and -bm options are used to specify whether the bitmap (ui overlay) or viewport (viewfinder image) are saved. Each can be used to specify the output path.

To allow capturing multiple frames without name conflicts, the output paths accept substitution variables in the from ${name[,arguments]}. The available variables are
${date} - the date / time the frame was transferred, formatted with os.date. If no format string is given, %Y%m%d_%H%M%S is used.
${frame} - the frame counter for this command (from 1 to the -count value). Note this resets every command invocation, so cannot be used to just continuously increment the number. The value is formatted with string.format. If no format is specified, %06d is used.
${time} - the time the frame was transferred, as a floating point unix-like timestamp with sub-second precision.  The value is formatted with string.format. If no format is specified, %d is used, meaning you get a straight unix style timestamp without any sub second values.

There is currently no way to escape these patterns, so if you want a literal ${blahblah} in the name, you will have to hack the code.

The default filenames are
viewport vp_${time,%014.3f}.ppm
bitmap bm_${time,%014.3f}.pam

which gives you a unix timestamp with milliseconds. This gives you unique filenames that sort numerically.

tl;dr examples
con> lvdumpimg -count=2 -vp
vp_1394431593.054.ppm
vp_1394431593.177.ppm

con> lvdumpimg -vp=foo.ppm -bm=bar.pam
foo.ppm
bar.pam

con> lvdumpimg -vp=foo_${date,%H%M%S}_${frame,%02d}.ppm  -count=3
foo_230851_01.ppm
foo_230851_02.ppm
foo_230852_03.ppm


In the future, I plan to add support for using substitution variables to other commands, like remoteshoot, downloads etc. I also plan to add an option to pipe the pbm data directly to another command.

« Last Edit: 16 / March / 2014, 21:12:56 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #581 on: 12 / March / 2014, 02:43:17 »
In chdkptp r494, I added the ability to execute camera code from rsint.  This allows you to adjust exposure parameters on the fly, without quitting rsint. This only affects rsint.lua, so you can just update that.

code is sent with the exec command, so to set the exposure you could use something like
rsint> exec set_tv96_direct(96)

Note that this does not affect the next shot, it affects the one after, because point where the camera waits is after the exposure is set up.

I will add more convenient exposure commands later.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #582 on: 14 / March / 2014, 09:14:37 »
The remoteshoot doesn't work with a A490 firmware 100f.

With rs -jpg, The file transfer stop at 1 004 032 byte and the camera freeze and shut off.
With rs -dng the complete file seems to be transferred but the camera say 'memory card error' after one shoot and need to be reset.

The readme say:
'- remote shoot via chdkptp (rs -jpg | -dng) fails after a variable number of shoots.'

I have tried various chdk version, 1.2, 1.3, DE

It's perhaps not related to chdkptp but I would like to know if someone succesfully used rs -jpg with this camera.

Re: alternative ptp client
« Reply #583 on: 14 / March / 2014, 09:37:59 »
Posted by: reyalp
Quote
I also plan to add an option to pipe the pbm data directly to another command.

This would be very valuable !

Have you some tips on how to decode ppm and pam by program ?


*

Offline nafraf

  • *****
  • 1308
Re: alternative ptp client
« Reply #584 on: 14 / March / 2014, 11:15:47 »
The remoteshoot doesn't work with a A490 firmware 100f.
...
The readme say:
'- remote shoot via chdkptp (rs -jpg | -dng) fails after a variable number of shoots.'
Remote capture was tested, I guess that issue in notes.txt was solved too.
I made some tests with A495, if Image Quality = Fine, remote capture does not work.  Please check if that makes difference.

Additionally, if you are willing to test a new version, I can send you a version where CHDK is loaded in ARAM.
« Last Edit: 14 / March / 2014, 11:29:20 by nafraf »

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #585 on: 14 / March / 2014, 17:05:24 »
I've uploaded snapshot 492  ...
1) rsint (remote shoot, interactive)
The cmdwait parameter is very useful so it may help people new to rsint if you add this from upthread to the description in post #520:
the rsint timeout behavior "defaults to 60 seconds, and can be adjusted using the -cmdwait option to rsint.  So
 rsint -cmdwait=5
will time out after 5 seconds."

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #586 on: 14 / March / 2014, 17:08:17 »
The remoteshoot doesn't work with a A490 firmware 100f.
I have used rs -jpg many times with the A490 firmware 100f and currently use that camera with the command rsint. CHDK version a490-100f-1.3.0-3343-full_BETA, chdkptp version 492. Camera settings quality: fine and continuous mode.

*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #587 on: 14 / March / 2014, 17:36:18 »
Have you some tips on how to decode ppm and pam by program ?
You mean in your own code, or using another program?

If you are using your own code, you can use the netpbm library, or just refer to the specs: http://netpbm.sourceforge.net/doc/#formats These formats are very simple, by design.

If you want a program to convert them, many common imaging program support ppm. For pam, you have less choices but imagemagick convert and the netpbm tools should work. Both are readily available for linux and windows.

Some examples using imagemagick
First, get some frames
chdkptp -c -e"lvdumpimg -vp=foo.ppm -bm=foo.pam"

Convert the bitmap to a png
convert foo.pam foo.png

As above, but fix aspect ratio  (for a 4:3 camera)
convert foo.pam -resize 640x480! merge foo.png

The ! tells convert to not keep the original aspect ratio. Some shells you may need to use \! to prevent the shell from interpreting the !

You can also combine the viewport and bitmap to replicate how it appeared on the camera screen:

convert foo.ppm -resize 640x480! foo.pam -resize 640x480! -layers merge foo.jpg

Note on windows, convert conflicts with a system utility name. I rename copy it to imconvert.exe.

Note you can execute the above directly from chdkptp too
con> !return os.execute('imconvert.exe foo.ppm -resize 640x480! foo.pam -resize 640x480! -layers merge foo.jpg')

regarding remote capture failing, please use
set cli_verbose=2
and post the output from a failed capture.
In older versions of chdkptp (before r461) there as bug that would cause an "exceeded max_chunks" error when capturing jpegs in some cases. This did not affect dng.

@nafraf:
Can you clarify how it fails with fine quality, and whether DNG works?
« Last Edit: 14 / March / 2014, 17:57:38 by reyalp »
Don't forget what the H stands for.


*

Offline nafraf

  • *****
  • 1308
Re: alternative ptp client
« Reply #588 on: 14 / March / 2014, 22:56:14 »
@nafraf:
Can you clarify how it fails with fine quality, and whether DNG works?
I tested again, varying the image size.

If normal quality, jpeg and dng work for all image size.

Either L or M1 size, fine quality, rs -jpg, camera captures, LED blinks for a while and them camera beeps and reports "Memory Card Error", file is partially saved to PC (<1MB).
chdkptp reports:
WARNING: timed out waiting for shot script
ERROR: uninit a script is already running
Using M2, M3 or S size, remote capture works.

Either L or M2 size, fine quality, rs -dng, LED blinks once, and them camera beeps and reports "Memory Card Error", file is partially saved to PC (15MB).
Using M2, M3, or S size, remote capture works.

*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #589 on: 15 / March / 2014, 00:04:17 »
I tested again, varying the image size.

If normal quality, jpeg and dng work for all image size.

Either L or M1 size, fine quality, rs -jpg, camera captures, LED blinks for a while and them camera beeps and reports "Memory Card Error", file is partially saved to PC (<1MB).
Thanks. It seems like this would happen if the camera thought there were still more chunks to write. However, I'm pretty sure the MAX_CHUNKS_FOR_JPEG value is correct, there's not room in the structure for more. This would also break DNG, because the hook gets called to try to discard the jpeg.

Could filewrite get called more than once, like the r50+ cams? It clearly doesn't seem to have the seek code.

Can you post the output with cli_verbose=2 ?
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal