Author Topic: Added sequence number to RAW file name within bracketing mode  (Read 3326 times)

Offline rr807

  • Rookie
  • *
  • Posts: 6
Added sequence number to RAW file name within bracketing mode
« on: 08 / October / 2008, 12:24:03 »
Hi CHDK fans,

i addes a sequence number to the raw file names when shooting in bracketing mode:

Example directory list:
CRW_1000.CRW
CRW_1001.CRW
CRW_1002_01.CRW
CRW_1003_02.CRW
CRW_1004_03.CRW
CRW_1005_01.CRW
CRW_1006_02.CRW
CRW_1007_03.CRW

In this example I took 2 "normal" shots. Then I switched to "bracketing in continous mode" and took two EV bracketing sequences, containing of each 3 pictures. This makes it easyer to idetify the shots, belonging together.

Do you think, this might be important for all CHDK users?
If yes, thhis ist my diff to the CHDK trunk:

Code: [Select]
Index: trunk/core/raw.c
===================================================================
--- trunk/core/raw.c   (Revision 524)
+++ trunk/core/raw.c   (Arbeitskopie)
@@ -9,6 +9,7 @@
 #define RAW_TARGET_DIRECTORY    "A/DCIM/%03dCANON"
 //#define RAW_TMP_FILENAME        "HDK_RAW.TMP"
 #define RAW_TARGET_FILENAME     "%s%04d%s"
+#define RAW_BRACKETING_FILENAME "%s%04d_%02d%s"
 
 //-------------------------------------------------------------------
 static char fn[64];
@@ -26,6 +27,7 @@
 int raw_savefile() {
       int fd, m=(mode_get()&MODE_SHOOTING_MASK);
     static struct utimbuf t;
+    static int br_counter;
 
     if (state_kbd_script_run && shot_histogram_enabled) build_shot_histogram();
 
@@ -46,6 +48,15 @@
 
     shooting_bracketing();
 
+    if(conf.tv_bracket_value || conf.av_bracket_value || conf.iso_bracket_value || conf.subj_dist_bracket_value) {
+        if(state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)
+            br_counter = 1;
+        else
+            br_counter++;
+    }
+    else
+        br_counter=0;
+
     // got here second time in a row. Skip second RAW saving.
     if (conf.raw_save_first_only && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) {
         return 0;
@@ -65,7 +76,10 @@
         mkdir(dir);
 
         sprintf(fn, "%s/", dir);
-        sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
+        if(br_counter)
+            sprintf(fn+strlen(fn), RAW_BRACKETING_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), br_counter, img_exts[conf.raw_ext]);
+        else
+            sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
 
         fd = open(fn, O_WRONLY|O_CREAT, 0777);
         if (fd>=0) {

Have fun
Randolf



Offline reyalp

  • Guru Member
  • ******
  • Posts: 4490
Re: Added sequence number to RAW file name within bracketing mode
« Reply #1 on: 08 / October / 2008, 12:59:02 »
Note that this no longer conforms to Design rule for Camera File system - Wikipedia, the free encyclopedia

This changes how the camera treats the files in various ways, see here Some notes on file prefix and extension treatment

ISTR that dryos also has issues with long filenames, but I might be mistaken there. You might want to use a different 8.3 pattern instead. For example BNN_NNNN.CRW

Or you maybe you could abuse the stitch assist naming convention: ST[A-Z]_NNNN.CRW
Don't forget what the H stands for.

Offline ewavr

  • Developers
  • Hero Member
  • ****
  • Posts: 1057
  • A710IS
Re: Added sequence number to RAW file name within bracketing mode
« Reply #2 on: 08 / October / 2008, 13:28:20 »
ISTR that dryos also has issues with long filenames, but I might be mistaken there.


AFAIK, DryOS can create (read etc.) files with long names, but filebrowser in CHDK can operate only with short filenames. Here it is discussed

Offline rr807

  • Rookie
  • *
  • Posts: 6
Re: Added sequence number to RAW file name within bracketing mode
« Reply #3 on: 08 / October / 2008, 14:37:47 »
OK, while trying different things, I recovered, that filenames up to 18 characters will work. Maybe that this is different with other camera models. Even I'm using Linux instead of Canon ZoomBrowser...

The idea with the stitch naming seems good. For bracketing the raw files might be named

BRA_1000.CRW / BRB_1000.CRW / BRC_1000.CRW  or
B01_1000.CRW / B02_1000.CRW / B03_1000.CRW

I'll read the notes on file prefix and extension treatment to find a solution.
An update will take until tomorrow. I don't have my camera with me.
Randolf
« Last Edit: 08 / October / 2008, 15:08:43 by rr807 »

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: Added sequence number to RAW file name within bracketing mode
« Reply #4 on: 08 / October / 2008, 15:18:00 »
well if you keep the ST[A-Z] scheme, people can download the raws without having to use a cardreader.

Offline rr807

  • Rookie
  • *
  • Posts: 6
Re: Added sequence number to RAW file name within bracketing mode
« Reply #5 on: 08 / October / 2008, 15:38:45 »
well if you keep the ST[A-Z] scheme, people can download the raws without having to use a cardreader.

Hi PhyrePhoX,

do you mean to use "ST[A-Z]" or just this scheme?

"ST" means "stitch". I'd like to use "BR" for "bracket".
But if ZoomBrowser only supports "ST[A-Z]" I'll take this...

Randolf



Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: Added sequence number to RAW file name within bracketing mode
« Reply #6 on: 08 / October / 2008, 15:56:25 »
well yeah, i meant to use ST, for convenience. however, i dont know how many people who use raw are using the canon utilities.

Offline paulgfx

  • Rookie
  • *
  • Posts: 13
Re: Added sequence number to RAW file name within bracketing mode
« Reply #7 on: 08 / October / 2008, 16:06:30 »
If the information about sequence number is not present in EXIF, you can add it there.
Paul

Offline rr807

  • Rookie
  • *
  • Posts: 6
Re: Added sequence number to RAW file name within bracketing mode
« Reply #8 on: 08 / October / 2008, 17:33:38 »
If the information about sequence number is not present in EXIF, you can add it there.
Paul

This is what I tried first, but I don't know, if it is possible to write to an exif tag.
I searced for a related function in CHDK, but didn't find one.

This would even match only JPG files. CHDK raw files don't contain any exif data...

Randolf


CHDK Forum

Re: Added sequence number to RAW file name within bracketing mode
« Reply #8 on: 08 / October / 2008, 17:33:38 »

Offline reyalp

  • Guru Member
  • ******
  • Posts: 4490
Re: Added sequence number to RAW file name within bracketing mode
« Reply #9 on: 09 / October / 2008, 06:31:31 »
This is what I tried first, but I don't know, if it is possible to write to an exif tag.
I searced for a related function in CHDK, but didn't find one.

This would even match only JPG files. CHDK raw files don't contain any exif data...

Randolf

Correct, CHDK does not yet have control of the exif data.

The CRWs don't have metadata, but programs such as dng4ps2 can get it from the jpeg.

The "special" treatment of the various prefixes and extensions isn't just canons ZoomBrowser, AFAIK it affects anything that accesses the camera using PTP, i.e. using the USB cable, and also affects how the camera itself deals with the files.

If you don't use one of the recognized prefixes, deleting the jpeg on the camera will not delete the raw, but otherwise it should be fine. If you don't use a recognized extension, you would have to use a card reader to transfer.

I'm not sure what will happen if you have IMG_XXXX.JPG and ST<char>_XXXX.CRW with the same number, but if it works, the fact that ST is also used for stitch assist shouldn't be a problem, since stitch+bracketing really doesn't make much sense (and is not currently possible AFAIK)

Note that all my information on this is from experimenting with one camera, it's quite possible they don't all work exactly the same.
Don't forget what the H stands for.

Offline rr807

  • Rookie
  • *
  • Posts: 6
Re: Added sequence number to RAW file name within bracketing mode
« Reply #10 on: 09 / October / 2008, 16:39:16 »
It works!

I changed it to ST[A-Z] and everything works fine.
Especially deleting images within the camera works!
If I delete a JPEG named IMG_0001.JPG the assotiated RAW STA_0001.CRW is deleted too.
Accessing raw images named ST#... via USB cabel is working as well.

I tested this with my IXUS 950 (DIGIC III). Tomorrow I'll test with my Powershot S3 (DIGIC II).

So this is my svn diff. In bracketing mode the raw files are named ST[A-Z]. If there are more then 26 shots in one sequence, they are named STZ.
Code: [Select]

Index: trunk//core/raw.c
===================================================================
--- trunk//core/raw.c (Revision 530)
+++ trunk//core/raw.c (Arbeitskopie)
@@ -9,6 +9,7 @@
 #define RAW_TARGET_DIRECTORY    "A/DCIM/%03dCANON"
 //#define RAW_TMP_FILENAME        "HDK_RAW.TMP"
 #define RAW_TARGET_FILENAME     "%s%04d%s"
+#define RAW_SEQUENCE_PREFIX     "ST#_"
 
 //-------------------------------------------------------------------
 static char fn[64];
@@ -26,6 +27,7 @@
 int raw_savefile() {
  int fd, m=(mode_get()&MODE_SHOOTING_MASK);
     static struct utimbuf t;
+    static int bracket_count;
 
     if (state_kbd_script_run && shot_histogram_enabled) build_shot_histogram();
 
@@ -46,6 +48,16 @@
 
     shooting_bracketing();
 
+    // count sequence if in bracketing mode
+    if (conf.tv_bracket_value || conf.av_bracket_value || conf.iso_bracket_value || conf.subj_dist_bracket_value) {
+        if (state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)
+            bracket_count = 1;
+        else
+            bracket_count++;
+    }
+    else
+        bracket_count=0;
+
     // got here second time in a row. Skip second RAW saving.
     if (conf.raw_save_first_only && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) {
         return 0;
@@ -65,7 +77,13 @@
         mkdir(dir);
 
         sprintf(fn, "%s/", dir);
-        sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
+        if (bracket_count) {
+     char* prefix = RAW_SEQUENCE_PREFIX;
+            *(prefix+2) = (char)('@'+(bracket_count<26?bracket_count:26)); 
+     sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, prefix, get_target_file_num(), img_exts[conf.raw_ext]);
+ }
+ else
+     sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
 
         fd = open(fn, O_WRONLY|O_CREAT, 0777);
         if (fd>=0) {

When testing I recognized, that raw stitch files are NOT named with the prefix ST[A-Z]. Is there a property or a function in CHDK to check whether the camera is in stitching mode?

Randolf




« Last Edit: 09 / October / 2008, 16:43:24 by rr807 »

Offline rr807

  • Rookie
  • *
  • Posts: 6
Re: Added sequence number to RAW file name within bracketing mode
« Reply #11 on: 09 / October / 2008, 21:11:14 »
Here I'm again with a little improvement:

Now raw stitch files are named ST[A-Z] too.

Randolf

Code: [Select]
Index: trunk/core/raw.c
===================================================================
--- trunk/core/raw.c (Revision 530)
+++ trunk/core/raw.c (Arbeitskopie)
@@ -9,6 +9,7 @@
 #define RAW_TARGET_DIRECTORY    "A/DCIM/%03dCANON"
 //#define RAW_TMP_FILENAME        "HDK_RAW.TMP"
 #define RAW_TARGET_FILENAME     "%s%04d%s"
+#define RAW_SEQUENCE_PREFIX     "ST#_"
 
 //-------------------------------------------------------------------
 static char fn[64];
@@ -26,6 +27,7 @@
 int raw_savefile() {
  int fd, m=(mode_get()&MODE_SHOOTING_MASK);
     static struct utimbuf t;
+    static int bracket_count;
 
     if (state_kbd_script_run && shot_histogram_enabled) build_shot_histogram();
 
@@ -46,6 +48,16 @@
 
     shooting_bracketing();
 
+    // count sequence if in bracketing mode
+    if (conf.tv_bracket_value || conf.av_bracket_value || conf.iso_bracket_value || conf.subj_dist_bracket_value || (mode_get()&MODE_SHOOTING_MASK)==MODE_STITCH) {
+        if (state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)
+            bracket_count = 1;
+        else
+            bracket_count++;
+    }
+    else
+        bracket_count=0;
+
     // got here second time in a row. Skip second RAW saving.
     if (conf.raw_save_first_only && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) {
         return 0;
@@ -65,7 +77,13 @@
         mkdir(dir);
 
         sprintf(fn, "%s/", dir);
-        sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
+        if (bracket_count) {
+     char* prefix = RAW_SEQUENCE_PREFIX;
+            *(prefix+2) = (char)('@'+(bracket_count<26?bracket_count:26)); 
+     sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, prefix, get_target_file_num(), img_exts[conf.raw_ext]);
+ }
+ else
+     sprintf(fn+strlen(fn), RAW_TARGET_FILENAME, img_prefixes[conf.raw_prefix], get_target_file_num(), img_exts[conf.raw_ext]);
 
         fd = open(fn, O_WRONLY|O_CREAT, 0777);
         if (fd>=0) {
[/codr]


Offline reyalp

  • Guru Member
  • ******
  • Posts: 4490
Re: Added sequence number to RAW file name within bracketing mode
« Reply #12 on: 10 / October / 2008, 00:59:26 »
rr807: be careful, in my experience the camera would get confused if the jpeg and crw have the same prefix. e.g. IMG_XXXX.JPG and IMG_XXXX.CRW would cause the jpeg to be listed twice on PTP.
Don't forget what the H stands for.

Offline Microfunguy

  • Developers
  • Guru Member
  • ****
  • Posts: 3027
    • StereoData Maker
Re: Added sequence number to RAW file name within bracketing mode
« Reply #13 on: 13 / October / 2008, 16:00:39 »
It works!
Accessing raw images named ST#... via USB cabel is working as well.


Are you saying that you are able to upload the raw images via the USB ?

How are you doing that  ?


David

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: Added sequence number to RAW file name within bracketing mode
« Reply #14 on: 13 / October / 2008, 16:27:13 »
using ptp (gphoto on linux for example) or the canon software on windows i guess.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal