CHDK DNG header structure - General Discussion and Assistance - CHDK Forum supplierdeeply

CHDK DNG header structure

  • 13 Replies
  • 4142 Views
CHDK DNG header structure
« on: 03 / December / 2010, 08:27:23 »
Advertisements
Following-on from discussions on the SX30 thread, I have a question regarding tag 0x132 in the DNG header.

This is the DataTime in YY:MM:DD HH:MM:SS format.

Although the tag is in the thumbnail header it is never processed, it is always the default null.
There must be a reason for that.

(DataTime IS in the EXIF IFD).

If I add the following :-

Code: [Select]
    case 0x132 :   IFD_LIST[j].entry[i].offset=(int)get_date_for_exif(exif_data->time);
                    strcpy(dngbuf,(char *)IFD_LIST[j].entry[i].offset);
                    break;

and display 'dngbuf' , the format is correct.
The offset to the string in the header is correct but contains garbage and is not null-terminated (as verified with a hex editor or dng_validate).

Any confirmation or explanation ?

« Last Edit: 03 / December / 2010, 08:37:01 by Microfunguy »

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: CHDK DNG header structure
« Reply #1 on: 03 / December / 2010, 12:08:01 »
Following-on from discussions on the SX30 thread, I have a question regarding tag 0x132 in the DNG header.
This tag is probably there because people thought it was mandatory (see, e.g., http://chdk.setepontos.com/index.php?topic=156.msg24483#msg24483). I don't believe it is. Throw it out, if you don't like it.

No idea about your coding problems.

Re: CHDK DNG header structure
« Reply #2 on: 03 / December / 2010, 12:35:49 »
Throw it out, if you don't like it.

I probably will

Quote
No idea about your coding problems.

That is what I am more interested in.

Just cannot understand why it does not work.

EDIT:

Hmmm .. it is working now  ;)
« Last Edit: 03 / December / 2010, 13:39:03 by Microfunguy »

Re: CHDK DNG header structure
« Reply #3 on: 04 / December / 2010, 18:03:46 »
Well, everything is working and I am generating two strip images per shot  stored in folders LEFT and RIGHT.
The main folder is named after the number of the first image in the sequence.
Eventually, there will be 180 strips in each folder.

Consider the following directory structure :-

DCIM/
         3350/LEFT/
                /RIGHT/
         3353/LEFT/
                /RIGHT/
         3356/LEFT/
                /RIGHT/

The LEFT and RIGHT folders contain images (3350_001.RAW, 3350_002.RAW and 3350_003.RAW, for example).
Each folder also contains file STRIPS.HDR.

I can run the following commands in each left/right folder  :-

for  %%f in (*.raw) do copy /b strips.hdr + %%f %%~nf.dng
for  %%f in (*.jpg) do del %%f

That creates the DNG's and deletes the JPG's (which are blank and only 12.5K in size).

Question is, how do I do this recursively with a single BAT file in DCIM ?

So far, I have not succeeded.
« Last Edit: 04 / December / 2010, 18:09:10 by Microfunguy »


*

Offline reyalp

  • ******
  • 12431
Re: CHDK DNG header structure
« Reply #4 on: 04 / December / 2010, 18:10:47 »
Is there any benefit to putting the raws in the DCIM tree ? It might be simpler just to make /left and /right with all the pictures in them. You'd still want to delete all the jpegs I guess, but the camera delete all can do that.

You should be able to use
for /r
to recurse directories. for /? for more info
Don't forget what the H stands for.

Re: CHDK DNG header structure
« Reply #5 on: 04 / December / 2010, 18:21:10 »
Is there any benefit to putting the raws in the DCIM tree ? It might be simpler just to make /left and /right with all the pictures in them.

It is for a number of panoramas.
Each panorama will consist of 180 left strips and 180 right strips.
So, you need a folder for each panorama for subsequent processing.


Quote

You should be able to use
for /r
to recurse directories.

You certainly should but I have not succeeded so far.

Quote
for /? for more info

 ::)

I did not bother, I assumed it would be as obscure as Microsofts website.

I will do more searching.

EDIT:

I should add that when I tried the /r option, STRIPS.HDR had to be in DCIM and the resulting DNG's also ended-up in DCIM instead of each folder.

I will confirm that and post the exact commands.
« Last Edit: 04 / December / 2010, 18:25:33 by Microfunguy »

Re: CHDK DNG header structure
« Reply #6 on: 04 / December / 2010, 18:35:41 »
This is the command run from DCIM folder :-

for /R %%f in (*.raw) do copy /b strips.hdr + %%f %%~nf.dng

MSDOS executes copy /b strips.hdr + [full path].raw *.dng

So, it expects strips.hdr to be in DCIM rather than using the version in the appropriate folder.
It seems that somehow the path to the destination folder for the DNG's also has to be specified or they will end-up in the DCIM folder.
« Last Edit: 04 / December / 2010, 18:41:31 by Microfunguy »

*

Offline reyalp

  • ******
  • 12431
Re: CHDK DNG header structure
« Reply #7 on: 04 / December / 2010, 19:54:43 »
::)

I did not bother, I assumed it would be as obscure as Microsofts website.
Odds of success are low if you are unwilling or unable to do some RTFMing.

FWIW, you don't really need to recurse, since you are only doing two levels. You could have an outer for loop go through the directories (for /D might be helpful) and an inner one to do the files.

In any non-braindead shell, this would be quite straight forward, but batch file syntax will probably make it a royal pain in the rear.
Don't forget what the H stands for.


Re: CHDK DNG header structure
« Reply #8 on: 04 / December / 2010, 20:12:38 »

Odds of success are low if you are unwilling or unable to do some RTFMing.

The for /?  help is exactly the same as the website.

Quote
batch file syntax will probably make it a royal pain in the rear.

If you search the 'pro' programming forums, there are plenty of people asking the same question and who have spent days on it.

The following test code finds and switches to all the subfolders and echos the desired command :-

for /F "delims=" %d in ('dir /ad /b /s') do cd "%d"&cd&echo copy /b strips.hdr + %%f %%~nf.dng

This has to be from a command line.
The batch version (with %% variables) does not work so far.

'cd' and 'echo' require the '&' if they are on the same line.
The &cd&  simply echos the directory.

Problem is, I only want to perform the command on all subfolders LEFT and RIGHT, not their parent folders.

To be continued  ........

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: CHDK DNG header structure
« Reply #9 on: 05 / December / 2010, 06:03:17 »
In any non-braindead shell, this would be quite straight forward, but batch file syntax will probably make it a royal pain in the rear.
This is not about syntax. This is about the whole thing being broken by design. Or rather designed in such a way as to inflict maximum pain on the user who is obviously regarded as a gullible idiot.

Question is, how do I do this recursively with a single BAT file in DCIM ?
Thy this,  it should do the trick for you:
Code: [Select]
@echo off

for /D %%A in (*) do call :doCopy "%%A"
goto :eof

:doCopy

cd %~1%\LEFT
for %%F in (*.raw) do copy /b strips.hdr + %%F %%~nF.dng
cd ..\RIGHT
for %%F in (*.raw) do copy /b strips.hdr + %%F %%~nF.dng
cd ..\..

:endsub

 

Related Topics