chdkptp - alternative ptp client

  • 1034 Replies
  • 192535 Views
*

Offline Ant

  • ****
  • 367
Re: chdkptp - alternative ptp client
« Reply #1020 on: 24 / January / 2018, 13:46:25 »
Advertisements
How to make DNG Remote Shoot without capturing the picture?
i.e. camera's raw buffer already contains raw data and I need to create DNG file on PC without saving it on SD card.
Or maybe there is a simple way to create DNG file in RAM?
At the moment I just call capt_seq_hook_raw_here() but this is not convenient for experiments because I have to select and copy DNG file manually.
« Last Edit: 24 / January / 2018, 13:57:39 by Ant »

*

Offline reyalp

  • ******
  • 11440
Re: chdkptp - alternative ptp client
« Reply #1021 on: 24 / January / 2018, 16:39:47 »
How to make DNG Remote Shoot without capturing the picture?
Remoteshoot is pretty complicated and tightly connected to the shooting process, so you'll need to dig into both the chdkptp and camera side code. I think the actual capture_get_data stuff should be mostly but you need a new camera side script (rlibs.lua rs_shoot) to initiate it. On the CHDK side you'd need to make sure remotecap_is_ready and remotecap_get_data_chunk do the right thing.

If your shooting process calls the raw hook code this might "just work", as long as init_usb_capture is called from lua with appropriate values beforehand.

Quote
i.e. camera's raw buffer already contains raw data and I need to create DNG file on PC without saving it on SD card.
Or maybe there is a simple way to create DNG file in RAM?
You could use con:getmem to just read the data directly, and then reverse byte order and combine it with a pre-exisiting DNG header. Note getmem returns a lua string, which you'd need to convert to an lbuf to use the existing chdkptp DNG code. I should add an lbuf option added in r829.

The CHDK DNG header code relies on propcases which probably aren't valid if you aren't using the normal shoot process, so using a fake header may not be much of a disadvantage.

Most of the propcases should update in halfshoot, so you could potentially get reasonable data if the non-shoot exposure uses those values.
« Last Edit: 25 / January / 2018, 01:33:49 by reyalp »
Don't forget what the H stands for.

*

Offline ftm

  • *
  • 43
Re: chdkptp - alternative ptp client
« Reply #1022 on: 26 / January / 2018, 02:21:19 »
Inspired by ftm's script, I decided to put together a quick script that worked for other platforms too. It uh... got a little out of hand  :haha

Anyway, misc/setup-ext-libs.bash in the chdkptp source is the result.

It probably doesn't work completely on mac, but I think it should be pretty close. Feedback would be greatly appreciated.



@ reyalp -- Thanks for working on this script. I have not had time to fully explore it but the build seemed to fail on my Mac. This happened when 'cd' was being built. A quick look at the log showed that the problem was when compiling cdcairoprn_unix.c. Errors such as
Code: [Select]

In file included from cairo/cdcairoprn_unix.c:15:0:
/opt/local/include/gtk-3.0/unix-print/gtk/gtkprintunixdialog.h:22:2: error: #error "Only <gtk/gtkunixprint.h> can be included directly."
 #error "Only <gtk/gtkunixprint.h> can be included directly."
  ^~~~~
In file included from /opt/local/include/gtk-3.0/unix-print/gtk/gtkprintunixdialog.h:26:0,
                 from cairo/cdcairoprn_unix.c:15:
/opt/local/include/gtk-3.0/unix-print/gtk/gtkprinter.h:22:2: error: #error "Only <gtk/gtkunixprint.h> can be included directly."
 #error "Only <gtk/gtkunixprint.h> can be included directly."
  ^~~~~
/opt/local/include/gtk-3.0/unix-print/gtk/gtkprinter.h:71:1: error: unknown type name 'GDK_AVAILABLE_IN_ALL'; did you mean 'ATK_AVAILABLE_IN_ALL'?
 GDK_AVAILABLE_IN_ALL
 ^~~~~~~~~~~~~~~~~~~~
 ATK_AVAILABLE_IN_ALL
I will try to play with it some more over the weekend.   

*

Offline reyalp

  • ******
  • 11440
Re: chdkptp - alternative ptp client
« Reply #1023 on: 26 / January / 2018, 03:22:37 »
I will try to play with it some more over the weekend.
Thanks for testing. Those errors look like they are somehow related to the
CPATH=/opt/local/include/gtk-3.0/unix-print
stuff. I put this as a makefile command line option instead of an environment variable, but I think that should be equivalent. Quite possible I messed something up though...
Don't forget what the H stands for.


*

Offline Ant

  • ****
  • 367
Re: chdkptp - alternative ptp client
« Reply #1024 on: 26 / January / 2018, 11:18:49 »
You could use con:getmem to just read the data directly, and then reverse byte order and combine it with a pre-exisiting DNG header.

I created dng using this code:
Code: [Select]
local hh,err=io.open("dng_header.bin","rb")
if not hh then
return false, err
end
local h = hh:read("*a")
hh:close()
local r = con:getmem(0x4464F8C8, 0x02969FE0)
local fh,err=io.open("test_raw.dng","wb")
if not fh then
return false, err
end
fh:write(h)
fh:write(r)
fh:close()

But how to reverse byte order on PC side using LUA only? (I did not found WIN32 binary for r829)

*

Offline reyalp

  • ******
  • 11440
Re: chdkptp - alternative ptp client
« Reply #1025 on: 26 / January / 2018, 13:26:34 »
You could use con:getmem to just read the data directly, and then reverse byte order and combine it with a pre-exisiting DNG header.

I created dng using this code:
Code: [Select]
local hh,err=io.open("dng_header.bin","rb")
if not hh then
return false, err
end
local h = hh:read("*a")
hh:close()
local r = con:getmem(0x4464F8C8, 0x02969FE0)
local fh,err=io.open("test_raw.dng","wb")
if not fh then
return false, err
end
fh:write(h)
fh:write(r)
fh:close()

But how to reverse byte order on PC side using LUA only? (I did not found WIN32 binary for r829)
You can make an lbuf from from the string returned by getmem
Code: [Select]
local lb=lbuf.new(r)
lb:reverse_bytes()
To write the lbuf, you need to use lb:fwrite(fh)

lbuf.c is fairly well commented.

Note this will use 2x DNG memory size for each shot. If you shoot a lot, you might want to do collectgarbage('collect') occasionally. Lua collects automatically, but in some cases it can let a lot of uncollected stuff pile up.
Don't forget what the H stands for.

*

Offline Ant

  • ****
  • 367
Re: chdkptp - alternative ptp client
« Reply #1026 on: 26 / January / 2018, 13:47:13 »
Note this will use 2x DNG memory size for each shot. If you shoot a lot, you might want to do collectgarbage('collect') occasionally. Lua collects automatically, but in some cases it can let a lot of uncollected stuff pile up.

Will this prevent the creation of 2 buffers?
Code: [Select]
local lb=lbuf.new(con:getmem(0x4464F8C8, 0x02969FE0))

*

Offline reyalp

  • ******
  • 11440
Re: chdkptp - alternative ptp client
« Reply #1027 on: 26 / January / 2018, 14:04:16 »
Will this prevent the creation of 2 buffers?
Code: [Select]
local lb=lbuf.new(con:getmem(0x4464F8C8, 0x02969FE0))
No, con:getmem will still create the string, it will just be eligible for garbage collection as soon as the call completes. In a local, it would be eligible when the local went out of scope.

This shouldn't be a big deal, I only mentioned it because it's possible if you took lots of shots you'd find chdkptp taking up hundreds of megs of memory when you didn't expect it.
Don't forget what the H stands for.


*

Offline reyalp

  • ******
  • 11440
Re: chdkptp - alternative ptp client
« Reply #1028 on: 01 / April / 2018, 20:00:13 »
In r832, I added support for remoteshoot to control shooting with a user supplied script. 

With a little "glue" code to set the menu options, this allows you to use normal camera side intervalometers, bracketing scripts etc without modification, or write your own logic to control exposure etc. Discussion and example with rawopint in https://chdk.setepontos.com/index.php?topic=13386.msg136688#msg136688

A minimal script just needs to shoot the same number of shots as passed to remoteshoot with the -shots= option. Remoteshoot setup (init_usb_capture etc) is handled in the usual way prior to running the user script.

The options normally passed to camera side code are available in rs_opts. The functions from rlibs rs_shoot are also available.

A minimal example:
Code: [Select]
for i=1,rs_opts.shots do
shoot()
end

Thanks @Bluestone_7 for the discussion that prompted this.
Don't forget what the H stands for.

Re: chdkptp - alternative ptp client
« Reply #1029 on: 02 / April / 2018, 09:09:47 »
Hi reyalp,

thanks a lot for your excellent job.
Yesterday I played with the remoteshoot function.
Quote
This shouldn't be a big deal, I only mentioned it because it's possible if you took lots of shots you'd find chdkptp taking up hundreds of megs of memory when you didn't expect it.
My Windows 7 PC (8gb RAM) will clear the RAM if chdkptp exceeds 900 mb of memory. It shot 1500 pictures (about 6gb) without any problem.
My RPi3 (1gb RAM) with Raspian does not clear the RAM, so it crashes. The following pictures are saved to the camera SD card (as you mentioned in https://chdk.setepontos.com/index.php?topic=13386.msg136688#msg136688). Sometimes the RPi will clear the RAM once or maybe twice, but it crashes always. My best attempt was about 800 pictures.

code I used:
Code: [Select]
rs /media/pi/KINGSTON/1500fotos/${ldate}${ext} -shots=1500 -int=2Saving the pictures to the OS-microSD card or to an USB device, doesn´t change the problem.

 

Related Topics