Dark frame control - General Discussion and Assistance - CHDK Forum supplierdeeply

Dark frame control

  • 15 Replies
  • 11145 Views
*

Offline reyalp

  • ******
  • 14121
Dark frame control
« on: 25 / July / 2008, 04:42:09 »
Advertisements
I've managed to get my a540 to save a raw before and after dark frame subtraction. This should allow you to create a proper dark frame by subtracting the the after from the before, which then could be applied to other images.

With the dark function identified, it may be possible to do dark frame only (e.g. shoot_darkframe in a script), but I haven't explored that yet. If someone is interested in doing that, there appear to be some test routines that might be helpful. See FFEA31F4 for example.

very very rough hacky diff (via tortioisesvn, from juciphox branch) attached. The unprocessed image is saved with the normal raw file name, and the processed on is saved as DRK_*

The jpeg always has the subtraction done, for obvious reasons.

One thing I noticed when doing this is that the camera actually handles a third possible value of the location (0x6130) that controls dark frame subtraction. CHDK sets it to 1 or 2, but there is clearly code for handling 3 as well. I tried forcing it to 3, but wasn't really able to figure out how it's different.

edit:
test images can be found at Picasa Web Albums - reyalp - CHDK cropped, but the jpeg has original exif info. 15 sec exposure @F2.6
« Last Edit: 25 / July / 2008, 06:29:11 by reyalp »
Don't forget what the H stands for.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Dark frame control
« Reply #1 on: 25 / July / 2008, 07:31:22 »
Given that the assembly hacking is beyond me for the time being, I'll ignorantly ask if what you're doing is change the OS's own routines in assembly to make it call CHDK's raw hooks twice, once before and once after the dark frame is taken...?

It's just not clear to me just how much of the firmware we can modify. I know we aren't actually (permanently) modifying any, but still we're subtly changing some, aren't we? And specifically I'm wondering wether it would be at all possible to completely skip the JPEG processing and saving routines.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Dark frame control
« Reply #2 on: 25 / July / 2008, 08:23:29 »
very cool. how did you find it?

*

Offline jetzt

  • ****
  • 316
  • [A710IS,(SD200)]
Re: Dark frame control
« Reply #3 on: 25 / July / 2008, 08:42:42 »
Seems that someone read my (and others) feature request and had an idea about it, awesome.
(I hope I didn't translate it wrongly in my head: this is about a darkframe without lens cap? ;))
 :D :D


*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Dark frame control
« Reply #4 on: 25 / July / 2008, 08:50:44 »
Yeah, although it's also taking a "real" photograph that gets subtracted out.

*

Offline reyalp

  • ******
  • 14121
Re: Dark frame control
« Reply #5 on: 25 / July / 2008, 15:02:31 »
Given that the assembly hacking is beyond me for the time being, I'll ignorantly ask if what you're doing is change the OS's own routines in assembly to make it call CHDK's raw hooks twice, once before and once after the dark frame is taken...?
Exactly. Specifically, copying the disassembled ROM code and modifying the copy.
Quote
It's just not clear to me just how much of the firmware we can modify. I know we aren't actually (permanently) modifying any, but still we're subtly changing some, aren't we? And specifically I'm wondering wether it would be at all possible to completely skip the JPEG processing and saving routines.
It should be possible. You might have to copy a lot more ROM code into CHDK. However, you'd want to grab the exif data somehow. One thing I want to look into is writing proper CRW format images, rather than just a raw buffer dump. It appears that code to do this exists in the firmware (in the debug stuff I mentioned). That would get you the the information, and get rid of a bunch of hassle with tools having to update for every camera.

I also wonder if the imager can be told to add instead of subtract. If you can do that, you could do stacking right in memory, which would open up all kinds of neat stuff.

@PhyrePhoX
I basically looked for everywhere the dark frame control address was used, on the assumption there must be a period of time where the unsubtracted image is still in memory, and the subtracted one hasn't been taken yet. Actually I started out thinking that the firmware might do the actual subtraction (so I spent some time looking for a big loop involving the raw buffer address), but that wasn't very smart  :P

@jetzt
Yes that's where I'm going with this, but what I posted isn't all the way there. Currently, it gives to two raws from which you can produce a dark frame. You could do this on the camera, either automatically or via a "raw-subtract" but I haven't done that yet.
Don't forget what the H stands for.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Dark frame control
« Reply #6 on: 25 / July / 2008, 15:34:48 »
I'm also looking into CRW with metadata (and implemented it partially), but I don't think you need to get the EXIF data that the camera provides... I strongly suspect, as I've said in this thread, that you can reconstruct everything (and more, and better - such as giving the real shutter speed and aperture, as overridden by CHDK) with available functions.

Although the reason why I'm interested in skipping the JPEG processing is that it might speed up continuous shooting a lot - you'll say, what use if you aren't saving the shots? Well, just as you said, you could sum in memory, for a start, and maybe you could get fast burst shooting at low resolution by only making the camera save one last JPEG containing a mosaic of several (well, four 1600x1200) shots.

*

Offline reyalp

  • ******
  • 14121
Re: Dark frame control
« Reply #7 on: 25 / July / 2008, 15:56:53 »
Your right, you don't need the exif specifically, and recording the actual settings used would be a plus. However, being lazy, I like the idea of hijacking the cameras own code to write it for me. It's certainly possible to save all the same settings the camera does, it's just a matter of tracking them down.

Disabling jpeg should be fairly easy... we ought to be able to just jump past it after writing the raw. If you are lucky, you can just jump to the end of one of those functions that we've hooked, but there might be some essential housekeeping that has to happen after you take an image. Try it and see...
Don't forget what the H stands for.


*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Dark frame control
« Reply #8 on: 25 / July / 2008, 16:22:54 »
This sounds ridiculous, but first CHDK versions wrote RAW twice -  before and after DF subtraction (first RAW was overwritted by second) - and without any capt_seq_task :D

*

Offline reyalp

  • ******
  • 14121
Re: Dark frame control
« Reply #9 on: 25 / July / 2008, 16:49:15 »
This sounds ridiculous, but first CHDK versions wrote RAW twice -  before and after DF subtraction (first RAW was overwritted by second) - and without any capt_seq_task :D
Hehe. Aside from capture twice, was it moved to solve some other problem ?

also, I have this great new invention for moving stuff around... You put some round things on a stick, and then you can just roll them instead of carrying :haha!
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal