Remaining RAW+JPG shots + filespace icon/text- done :D - General Discussion and Assistance - CHDK Forum supplierdeeply

Remaining RAW+JPG shots + filespace icon/text- done :D

  • 175 Replies
  • 43787 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Remaining RAW+JPG shots + filespace icon/text- done :D
« on: 05 / February / 2008, 16:29:56 »
Advertisements
« Last Edit: 07 / March / 2008, 11:47:15 by PhyrePhoX »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #1 on: 06 / February / 2008, 17:40:34 »
Hi, i decided to give it a go myself.
With this little modification you are able to see the remaining filespace in megabyte directly in the OSD.
To achieve this, i replaced the batteryicon (which is of no use to me). This is a testbuild, the batteryicon is not meant to be replaced forever ;)
With the filespace info directly in OSD you can actually see the draining filespace when recording a video, this way you can directly compare the codec quality versus usage of filespace. You can also see when it is time to switch SD card in case of taking RAW pictures (imagine your raw files have a size of 10 megs, you have 6 Megs left and Canon tells you you can shoot 2 more pictures - don't trust Canon in that case :D).
At the end of the post i will explain what i tried to do next (my initial idea of showing the remaining RAW capabilities)

You can download the compiled build off of: DL link removed
I compiled for all supported CHDK Cameras. It is perfectly save to use these builds!

To do it on your own: Download revision 289 off CHDK trunk @ https://tools.assembla.com/chdk/changeset/289/trunk?old_path=%2F&format=zip
Go to trunk/core/gui_batt.c
Replace
Code: [Select]
static void gui_batt_draw_icon () {
    coord x;
    int perc = get_batt_perc();
    color cl = (perc<=10)?COLOR_RED:(conf.batt_icon_color&0xFF);
 
    // battery icon
    draw_rect(conf.batt_icon_pos.x+3-1,    conf.batt_icon_pos.y+1,     conf.batt_icon_pos.x+3+25+1, conf.batt_icon_pos.y+1+10,  cl);
    draw_rect(conf.batt_icon_pos.x+3-3,    conf.batt_icon_pos.y+1+2,   conf.batt_icon_pos.x+3-2,    conf.batt_icon_pos.y+1+8,   cl);
    draw_line(conf.batt_icon_pos.x+3-4,    conf.batt_icon_pos.y+1+2-1, conf.batt_icon_pos.x+3-4,    conf.batt_icon_pos.y+1+8+1, COLOR_BLACK);  // l
    draw_line(conf.batt_icon_pos.x+3-2,    conf.batt_icon_pos.y+1-1,   conf.batt_icon_pos.x+3+25+2, conf.batt_icon_pos.y+1-1,   COLOR_BLACK);  // t
    draw_line(conf.batt_icon_pos.x+3-2,    conf.batt_icon_pos.y+1+11,  conf.batt_icon_pos.x+3+25+2, conf.batt_icon_pos.y+1+11,  COLOR_BLACK);  // b
    draw_line(conf.batt_icon_pos.x+3+25+2, conf.batt_icon_pos.y+1-1,   conf.batt_icon_pos.x+3+25+2, conf.batt_icon_pos.y+1+10,  COLOR_BLACK);  // r
     
    // battery fill
    x=conf.batt_icon_pos.x+3+1+25-(perc/4);
    if (x<=conf.batt_icon_pos.x+3) x=conf.batt_icon_pos.x+3+1;
    if (x>conf.batt_icon_pos.x+3+25+1) x=conf.batt_icon_pos.x+3+25+1;
    draw_filled_rect(conf.batt_icon_pos.x+3, conf.batt_icon_pos.y+1+1, x-1, conf.batt_icon_pos.y+1+9, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK));
    draw_filled_rect(x, conf.batt_icon_pos.y+1+1, conf.batt_icon_pos.x+3+25, conf.batt_icon_pos.y+1+9, MAKE_COLOR(cl, cl));
}

with

Code: [Select]
static void gui_batt_draw_icon () {
    sprintf(osd_buf, "%3d%M", GetFreeCardSpaceKb()/1024);
    osd_buf[5]=0;
    draw_string(conf.batt_icon_pos.x, conf.batt_icon_pos.y, osd_buf, conf.osd_color);
}
And off you go compile.



In my next try i wanted to implement a function to calculate how many RAW pics i can take. it works like this: remainingfilespace / sizeofraw.
of course this function is not correct, as it completely ignores the jpg filesize, but it's much better than nothing (of course i will enhance the function by adding the jpgsize, i only have to find out how canon calculates their internal remaing shots value - any hints?).
The function works, at least on my canon a 620. the only problem is: i cannot enter alt-mode anymore, and i don't know whats causing this.
compilation was fine, booting is fine, taking pictures is fine, osd is fine, but alt-mode isn't fine.
what it is *supposed* to do: show the maximum number of raw pictures you can take. it *should* normally add an entry in the OSD battery dialog where you can enter your RAW file size (it is a fixed value for each camera, regardless of size of jpgs). for example on my a620 it is 9.004 KB.


i will supply the changed files (inside also is the compiled chdk for a620, with the raw size kind of hardcoded), maybe one of you more experienced "hackers" can tell me where i did a mistake?
I will also supply two pictures (taken with my cellphone and a macro lens :D) showing the filespace OSD and the remaining RAW OSD.
if you need a diff i can create one, if you tell me how to do it properly ;)
anyways, i changed the following files:

In core:
conf.c
gui.c
gui_batt.c
gui_lang.h

in include:
conf.h



Please test the changes i made and give comments. i really want to implement this feature, but i somehow must have failed in creating a new menu entry.

edit: of course to be able to see the remaining filespace you have to enable the battery icon in the osd menu.
« Last Edit: 19 / February / 2008, 17:32:53 by PhyrePhoX »

Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #2 on: 06 / February / 2008, 18:12:07 »
Deleted
« Last Edit: 22 / April / 2008, 11:04:33 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #3 on: 06 / February / 2008, 18:46:31 »
well i really want to leave the battery symbol in there, for a few reasons:
a) someone actually did draw this thing (look at the size of the function with all draw commands :D) and made some efforts
b) i actually normally use it right below the battery percentage
c) i really DO want to learn how to actually draw NEW icons or texts in the OSD, and especially new menu items, because i would like to add some more stuff in the future.
funny thing is, i actually study this in university, i think i'm a lazy bone.

like i said before, i need to find out how canon calculates their value of remaining possible shots. it clearly is related to the picture size & quality setting. i guess it is very dependent on the camera model, thus i cannot implement this function easily. maybe there is a way for me to read out the canon value and do a calculation like this:
(free space / canon_value_remaining_shots) = canon_value_estimated_size_PER_shot (depending on camera setting). using that value and the FIXED rawsize i can precisely calculate how many raw shots (INCLUDING the jpgs) i can take.
hm, first i go to bed :D


Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #4 on: 06 / February / 2008, 20:44:17 »
well i really want to leave the battery symbol in there, for a few reasons:
a) someone actually did draw this thing (look at the size of the function with all draw commands :D) and made some efforts
b) i actually normally use it right below the battery percentage
c) i really DO want to learn how to actually draw NEW icons or texts in the OSD, and especially new menu items, because i would like to add some more stuff in the future.
funny thing is, i actually study this in university, i think i'm a lazy bone.

like i said before, i need to find out how canon calculates their value of remaining possible shots. it clearly is related to the picture size & quality setting. i guess it is very dependent on the camera model, thus i cannot implement this function easily. maybe there is a way for me to read out the canon value and do a calculation like this:
(free space / canon_value_remaining_shots) = canon_value_estimated_size_PER_shot (depending on camera setting). using that value and the FIXED rawsize i can precisely calculate how many raw shots (INCLUDING the jpgs) i can take.
hm, first i go to bed :D

The estimated number of shots is based on the image size selected and likely an estimated compression ratio that varies with quality, this means that the number of RAWs should be estimated to be somewhat proportional to the quality and number of JPGs left, if that is the case, then all we really need to know are a) number of jpegs left b) quality setting c) approximate quality ratios, and these combined with the known RAW size to resolution ratio should be able to be used to calculate an estimated number of photos left, regardless of the selected resolution and possibily camera model (assuming the estimated compression ratios are somewhat consistent.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #5 on: 07 / February / 2008, 04:04:33 »
i will further investigate in this matter :)

Quote
RAW size to resolution ratio
the raw size is always the same, even when you choose a different resolution.

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #6 on: 07 / February / 2008, 05:31:23 »

What if you take a 1000 of your pictures, get the average size and use that in your function?

I don't think Canon's formula is more accuarate than that.

May be it is even more accurate if every one of us gets our own estimate, given the different "style" of photography we use to do. I mean, if yoy are into architecture, you will get a different average size than if you like landscape. You can code it as a user input the same way as the battery indicator.

By the way, thanks for trying to solve this problem. I remember the first time I got a RAW with CHDK I thought: "Woow!!!, but now the counter of remaining photos is going to lie to me".

I just have never compile CHDK, but your idea and your code will make me try. Please keep working on this and I hope we can see it in the next build.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #7 on: 07 / February / 2008, 05:55:42 »
In my private build for A710 I use this calculation:

jpeg_size=free_space/camera_jpeg_count   (if camera_jpeg_count is non-zero, otherwise jpeg_size=0)
raw_and_jpeg_count=free_space/(raw_size+jpeg_size)

and camera_jpeg_count is number which camera displays on the screen. I cannot read this number, but can read corresponding string.

camera_jpeg_count=atoi((char*)JPEG_COUNT_STRING_ADDR);

for A620, JPEG_COUNT_STRING_ADDR is 0x7F6F8, for other cameras it can be easily found:


LDR     R6, =0x7F6F8 ; this is  JPEG_COUNT_STRING_ADDR for a620
LDR     R1, =a9999   ; "9999"
MOV     R0, R6
BL      sprintf


Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #8 on: 07 / February / 2008, 08:54:50 »
i will further investigate in this matter :)

Quote
RAW size to resolution ratio
the raw size is always the same, even when you choose a different resolution.

So you mean that the camera always take the same size/resolution of RAW no matter what resolution is chosen, and then resizes for the JPG?  If this is the case, then it may not be quite as trivial, as the fixed RAW size may be different from model to model, unless there is a way to identify what the RAW size is automatically.


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled)
« Reply #9 on: 07 / February / 2008, 09:56:36 »
well, one could scan the directory for the existance of a *.crw file and take its size.
but it should suffice that people just edit their raw size in the osd menu (which i could not achieve yet :D)
HOWEVER, thanks to ewavr i wrote a new function which calculates remaining RAW files perfectly.

Once again i only touched gui_batt.c (replaced the gui_batt_draw_icon function), so everybody can do the same:
Code: [Select]
static void gui_batt_draw_icon () {
    int camera_jpeg_count,jpeg_size,raw_and_jpeg_count,raw_size,m;
    raw_size = 9004;
    camera_jpeg_count=atoi((char*)0x7F6F8);
    m = mode_get();
    if (camera_jpeg_count>0){
    jpeg_size=GetFreeCardSpaceKb()/camera_jpeg_count;
    raw_and_jpeg_count=GetFreeCardSpaceKb()/(raw_size+jpeg_size);
    }
    else
    {
    raw_and_jpeg_count=0;
    }
   
    if ((m&MODE_MASK) == MODE_REC){
    if (raw_and_jpeg_count>0){
    sprintf(osd_buf, "%3d%", raw_and_jpeg_count);
    osd_buf[5]=0;
    draw_string(conf.batt_icon_pos.x, conf.batt_icon_pos.y, osd_buf, conf.osd_color);
  }
  else
  {
    sprintf(osd_buf, "NONE!");
    osd_buf[5]=0;
    draw_string(conf.batt_icon_pos.x, conf.batt_icon_pos.y, osd_buf, 0x24);
    }
    }
    else{
  sprintf(osd_buf, "%3d%M",GetFreeCardSpaceKb()/1024 );
    osd_buf[5]=0;
    draw_string(conf.batt_icon_pos.x, conf.batt_icon_pos.y, osd_buf, conf.osd_color);
  }
   
}
you can compile this directly for the a620.

the function works like this:
when in playback mode, in OSD you will see the free space on the card appended by an M (example: 128M)
when in record Mode, in OSD you will see how much RAW+JPGs you can shoot (quiete precisely). If the counter goes to ZERO, there will be written "NONE!" in red letters in OSD. when you see that, it's time to switch SDcard. mind that for example the a620 still has space for 3 to 5 jpegs (in high quality) but NOT for raw (or at least it is NOT save to assume that!).
the script does NOT react on what RAW mode you set, so if you havent RAW enabled, the script will still tell you how much raw is left.

todo:
- find out a way to get the jpegstring address automatically (or collect them off of the forum)
- find a way to determine raw size for each model
- find a better color than red (when in low diskspace mode)
- comment the ugly code (yes, it's really ugly and probably not fast :D)
- do NOT replace the battery icon, instead make a new one (maybe one for filespace, one for remainingraw)
- create a submenu entry so that people can enter the adress and/or the rawsize
- maybe show a warning in playback mode too when low diskspace
- get it in trunk :D

if you have your rawsize AND the JPEG_COUNT_STRING_ADDR (see ewavrs post, by the way, i failed in understanding how one would find out the address!?) you can just change the code and see that it works.

by the way i noticed one thing, don't know if it's a bug:
when you delete files via the filemanager in recordmode, the canon_remaining_jpegs value does NOT update. you have to go to playbackmode and back to record in order to update that.

edit: attached compiled version for A620.
« Last Edit: 19 / February / 2008, 17:33:31 by PhyrePhoX »

 

Related Topics