Barrel distortion correction - General Discussion and Assistance - CHDK Forum  

Barrel distortion correction

  • 6 Replies
  • 6128 Views
*

Offline waldo

  • ***
  • 238
Barrel distortion correction
« on: 31 / December / 2010, 16:08:36 »
Advertisements
Does anyone know where in the firmware the barrel distortion correction is done?  I'm trying to see if I can disable that part of the JPEG processing.

I have a need for a JPEG image that retains the pixels in the corner that are removed when Canon corrects for lens distortion.  Currently, I can use Raw but I'd rather avoid all the Raw post-processing of white balance, noise reduction, sharpening, etc. just to get those extra corner pixels.  I know there is a "fisheye" mode in some cameras, but that seems to take the image after lens distortion correction and just adds additional distortion.

*

Offline reyalp

  • ******
  • 14082
Re: Barrel distortion correction
« Reply #1 on: 31 / December / 2010, 16:34:54 »
Does anyone know where in the firmware the barrel distortion correction is done?  I'm trying to see if I can disable that part of the JPEG processing.

I have a need for a JPEG image that retains the pixels in the corner that are removed when Canon corrects for lens distortion.  Currently, I can use Raw but I'd rather avoid all the Raw post-processing of white balance, noise reduction, sharpening, etc. just to get those extra corner pixels.  I know there is a "fisheye" mode in some cameras, but that seems to take the image after lens distortion correction and just adds additional distortion.
This is new territory, I don't recall anyone reporting anything on that (other than the fact that new cameras do correct for barrel distortion)

I would guess the actual correction isn't done with the ARM CPU, but presumably something in the firmware code tells the other side of digic to do it.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Barrel distortion correction
« Reply #2 on: 31 / December / 2010, 16:45:09 »
I would guess the actual correction isn't done with the ARM CPU, but presumably something in the firmware code tells the other side of digic to do it.

(I was just about to say the same thing.)  :)

On the SX30 the camera is doing a lot of distortion correction at the wide end; but almost none at the tele end.
Perhaps there's some setting being passed to the Digic processor to control the amount of correction - finding it would be interesting.
Has anyone mapped out how the ARM and Digic interact and how processing settings get commincated to the Digic processor?

Regards,
Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline waldo

  • ***
  • 238
Re: Barrel distortion correction
« Reply #3 on: 31 / December / 2010, 16:49:24 »
I would guess the actual correction isn't done with the ARM CPU, but presumably something in the firmware code tells the other side of digic to do it.

I would also guess that they did it that way.  Having explored capt_seq task recently, I know that the JPEG processing is done heavily in hardware, but is started within the capt_seq task after the image capture.  That is why cap_seq_hook_raw_here contains a wait loop - it halts the capt_seq task and prevents starting the JPEG processing in hardware until things like raw develop have had a chance to finish.  I'm hoping that something similar could be done for lens distortion.


*

Offline reyalp

  • ******
  • 14082
Re: Barrel distortion correction
« Reply #4 on: 31 / December / 2010, 17:26:43 »
Has anyone mapped out how the ARM and Digic interact and how processing settings get commincated to the Digic processor?
My guess is EngDrv* is relevant.

There are also some chunks of stuff that appears to be non-ARM code related to jpeg processing. In older cameras (e.g. a540), the strings like
"jp52_firmware build#0014 2005/01/31 Akihiro Uehara, Satoshi Naito, Yukio Chiba"
"launcher.s rev-1.0 2001/07/17 author Satoshi Naitod"
are associated with these chunks.

Similar chunks exist in newer cameras, minus the strings.

Quote from: waldo
That is why cap_seq_hook_raw_here contains a wait loop - it halts the capt_seq task and prevents starting the JPEG processing in hardware until things like raw develop have had a chance to finish.
This just blocks capt_seq while our raw code runs in spytask.

FWIW, I believe there is at least one another task related to jpeg developing, maybe DevelopModule.
« Last Edit: 31 / December / 2010, 17:33:21 by reyalp »
Don't forget what the H stands for.

*

Offline waldo

  • ***
  • 238
Re: Barrel distortion correction
« Reply #5 on: 31 / December / 2010, 19:00:59 »
Here's what I have explored so far:

Capt_seq_task:
   I've looked at all 35 jumptable entries and none seem to do or to start the actual jpeg processing

SsDvlpSeq.c:
   Inside DvlpSeqTask, one of the sub calls is to a function that gets propcases for jpeg resolution, quality, date stamp, etc that may be promising.  So far, I haven't found a propcase that turns off distortion correction (wishful thinking!).  I've tried patching this task but I haven't found anything interesting so far.
There may be a table somewhere with lens geometry corrections, but patching a table would probably require patching the function that uses the table.
« Last Edit: 31 / December / 2010, 19:05:14 by waldo »

Re: Barrel distortion correction
« Reply #6 on: 19 / January / 2011, 10:09:28 »
have you maybe find during your tests what code do the Canon Noise reduction and sharpening ?

I mean not dark frame subtraction.
because cams have lots texture loss, maybe its possible to do less denoise or at least switch off complete and do all sharpen and denoise on PC.

sure there is raw, but RAW is slow and on IX1000 it not work
« Last Edit: 19 / January / 2011, 10:11:13 by Bernd R »
Ixus 1000 HS

 

Related Topics