RAW related functions for the scripts - page 2 - Feature Requests - CHDK Forum  

RAW related functions for the scripts

  • 26 Replies
  • 12119 Views
Re: RAW related functions for the scripts
« Reply #10 on: 21 / November / 2008, 05:26:22 »
Advertisements
deleted :)

Thanks!

What's the syntax for the new function?
« Last Edit: 21 / November / 2008, 05:31:44 by dsvilko »

*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: RAW related functions for the scripts
« Reply #11 on: 21 / November / 2008, 05:55:51 »
Well, the (mini)patch has:
Quote
Index: core/luascript.c
===================================================================
--- core/luascript.c   (revision 586)
+++ core/luascript.c   (working copy)
@@ -759,6 +759,13 @@
   return 3;
 }
 
+extern void raw_prepare_develop(const char *filename);
+static int luaCB_set_raw_develop( lua_State* L )
+{
+  raw_prepare_develop(luaL_checkstring( L, 1 ));
+  return 0;
+}
+
 void register_lua_funcs( lua_State* L )
 {
 #define FUNC( X )         \
@@ -884,4 +891,6 @@
 
   FUNC(get_buildinfo);
   FUNC(get_mode);
+
+  FUNC(set_raw_develop);
 }

..so i suppose it's 'set_raw_develop(filename)' ?

mind you, all i've done is applying reyalp's patch to a vanilla '586' and compiling it,
which does not necessarily imply i understand it ...

wim
« Last Edit: 21 / November / 2008, 06:09:31 by whim »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: RAW related functions for the scripts
« Reply #12 on: 21 / November / 2008, 08:10:28 »
And to clarify, I think (no, I haven't tried it yet either) you first call the function as whim said (using full file path) and then set your ISO overrides and shoot (using shoot() or a full shutter press press) to actually develop. The next time you shoot, the camera shoots normally without developing anything.

Re: RAW related functions for the scripts
« Reply #13 on: 21 / November / 2008, 08:47:06 »
I have tested it and it works! :)

Code: [Select]
--[[
@title rawdevelop test
--]]

function fastshoot()
  press("shoot_half")
  repeat
    sleep(1)
  until get_shooting() == true
  print("shooting...")
  press("shoot_full")
  release("shoot_full")
  release("shoot_half")
  repeat
    sleep(1)
  until get_shooting() ~= true
end

iso=get_iso_real()
set_raw(1)
fastshoot()
dir = os.listdir("A/DCIM/100CANON", false)
raw = dir[table.getn(dir)]
set_raw_develop("A/DCIM/100CANON/"..raw)
set_raw(0)
set_iso_real(50)
fastshoot()
os.remove("A/DCIM/100CANON/"..raw)
set_iso_real(iso)

I seem to have a problem with the os.remove(raw) as the screen completely blanks. Will have to test further.
Any chance of adding raw_average(table)? :)
EDIT: my bad... os.remove works (forgot the path).
« Last Edit: 21 / November / 2008, 08:53:57 by dsvilko »


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: RAW related functions for the scripts
« Reply #14 on: 21 / November / 2008, 18:17:18 »
Looks like raw averaging can be implemented smoothly as well. A very preliminary patch, even more preliminary test script and binaries for s3is against trunk 586 included.

It worked fine on my a570is in both rec and play modes but be careful. I didn't try giving the functions incorrect input such as nonexistant file names and didn't even think what might happen if I did.

You probably know this, but in your script above (like my test script which doesn't check anything either) you assume DCIM/100CANON. My cam's currently at 129CANON (those lua timelapse scripts seem to increase the directory name counter randomly even when 9999 hasn't been achieved...I wonder why this is?)

The script doesn't develop since you already tested it. The averaging result will be in A/DCIM/100CANON/IMG_0004.WAV

my gcc gives warnings from these patches btw:
warning: passing arg 1 of `raw_prepare_develop' discards qualifiers from pointer target type
warning: passing arg 1 of `raw_merge_add_file' discards qualifiers from pointer target type


Re: RAW related functions for the scripts
« Reply #15 on: 22 / November / 2008, 09:32:58 »
Thanks!
I'll try it out. I had some problems with deleting jpeg images even though deleting raw files works ok. Will have to investigate that further as it wouldn't be convenient to leave the individual jpegs after averaging.

Re: RAW related functions for the scripts
« Reply #16 on: 22 / November / 2008, 11:22:04 »
Ok, here is first the modified 'high ISO without NR' script that should now find the directory where jpegs are saved. The script still assumes that the RAW and only RAW files go to 100CANON (jpegs go somewhere else). The script now also deletes the original jpg (with NR applied). The camera still tries to show the deleted jpeg in the playback mode but this problem goes away the next time you turn on the camera.

Code: [Select]
--[[
@title disable NR
--]]

--[[
This script let's you shoot high ISO images without any
noise reduction applied to them.
At the time of writing, this script requires a special
(patched) build. Under RAW parameters, 'RAW file in dir with jpg'
should NOT be set (all the RAW files have to be stored to 100CANON)
The script is tested to work on S3is. Both the original jpeg file
with NR applied and the RAW file are deleted (only the jpeg without
NR remains).
--]]

function fastshoot()
  press("shoot_half")
  repeat
    sleep(1)
  until get_shooting() == true
  print("shooting...")
  press("shoot_full")
  release("shoot_full")
  release("shoot_half")
  repeat
    sleep(1)
  until get_shooting() ~= true
end

iso=get_iso_real()
set_raw(1)
fastshoot()
dir = os.listdir("A/DCIM/100CANON", false)
raw = dir[table.getn(dir)]
foo = os.listdir("A/DCIM", false)
imdir = foo[table.getn(foo)]
dir2 = os.listdir("A/DCIM/"..imdir, false)
jpg = dir2[table.getn(dir2)]
set_raw_develop("A/DCIM/100CANON/"..raw)
set_raw(0)
set_iso_real(50)
fastshoot()
os.remove("A/DCIM/100CANON/"..raw)
print("remove: A/DCIM/"..imdir.."/"..jpg)
os.remove("A/DCIM/"..imdir.."/"..jpg)
set_iso_real(iso)

And here is the 'average' script (the same requirements as the last one):

Code: [Select]
--[[
@title average
@param n Shots to average
@default n 4
@param d Delay between shots (s)
@default d 0
--]]

function fastshoot()
  press("shoot_half")
  repeat
    sleep(1)
  until get_shooting() == true
  print("shooting...")
  press("shoot_full")
  release("shoot_full")
  release("shoot_half")
  repeat
    sleep(1)
  until get_shooting() ~= true
end

set_raw(1)
for i=1,n do
  sleep(d*1000)
  fastshoot()
end
set_raw(0)

-- average
dir = os.listdir("A/DCIM/100CANON", false)
raw_merge_start()
for i=0,n-1 do
  raw = dir[table.getn(dir)-i]
  print("adding "..raw)
  raw_merge_add_file("A/DCIM/100CANON/"..raw)
end
print("averaging ...")
raw_merge_end()

-- delete the RAW images
for i=0,n-1 do
  raw = dir[table.getn(dir)-i]
  print("deleting "..raw)
  os.remove("A/DCIM/100CANON/"..raw)
end

-- delete the JPEG images
foo = os.listdir("A/DCIM", false)
imdir = foo[table.getn(foo)]
dirjpg = os.listdir("A/DCIM/"..imdir, false)
for i=0,n-1 do
  jpg = dirjpg[table.getn(dirjpg)-i]
  print("deleting "..jpg)
  os.remove("A/DCIM/"..imdir.."/"..jpg)
end

-- develop the averaged RAW
dir = os.listdir("A/DCIM/100CANON", false)
raw = dir[table.getn(dir)]
set_raw_develop("A/DCIM/100CANON/"..raw)
fastshoot()

-- delete the averaged RAW
os.remove("A/DCIM/100CANON/"..raw)
« Last Edit: 22 / November / 2008, 12:09:08 by dsvilko »

*

Offline reyalp

  • ******
  • 14080
Re: RAW related functions for the scripts
« Reply #17 on: 23 / November / 2008, 03:49:00 »
Good stuff.  I'll check these functions in when I get the chance.

Just a thought, it would probably be good to add an option to chdk itself to control the canon NR, rather than jumping through hoops with raw develop. CHDK refers to dark frame subtraction as NR in some places, but AFAIK we don't yet have control the high ISO NR.

edit:
I'm tempted to make raw average (and sum, which I may as well do at the same time) just take an array of files, and do the whole start/add/finish thing by itself. Objections ?
« Last Edit: 23 / November / 2008, 04:12:03 by reyalp »
Don't forget what the H stands for.


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: RAW related functions for the scripts
« Reply #18 on: 23 / November / 2008, 04:58:58 »
Just a thought, it would probably be good to add an option to chdk itself to control the canon NR, rather than jumping through hoops with raw develop. CHDK refers to dark frame subtraction as NR in some places, but AFAIK we don't yet have control the high ISO NR.

Yes, that is a very old thing in our wishlist. Doing this with RAWs is a lot slower than disabling JPEG  NR (which actually would speed up the camera, allowing fastest burst speeds on high ISOO too). But doing it the RAW way is a good thing to have too, because it allows developing both versions from the same photo.

I'm tempted to make raw average (and sum, which I may as well do at the same time) just take an array of files, and do the whole start/add/finish thing by itself. Objections ?

No not at all, that's actually how I was going to do it but had no clue how to do that to lua. Your raw develop function was a neat example so I didn't really have to do anything but read how the file browser did raw average.

Re: RAW related functions for the scripts
« Reply #19 on: 23 / November / 2008, 05:47:43 »
It makes little difference how the averaging functions are implemented. Even the current implementation is convenient to use from lua as you don't first have to build  an array. In any case I plan to write lua functions that would return the last n raw or jpeg files regardles of where they are kept.

 

Related Topics