Changeset 580


Ignore:
Timestamp:
11/19/08 00:15:12 (5 years ago)
Author:
phyrephox
Message:

tadaa! major pimping of an already cool feature!
you can now SAVE and LOAD edge overlays! this was written by PlasmaHH (shy guy, only in irc :D)
Yes, you read it right:

  • save an edge overlay: create an overlay (enable overlay and press half-press) -> go to overlay menu and press save
  • load an overlay (go to menu and choose an *.edg file)
  • create overlays from jpgs in playmode! (only works on cameras that have a "hardware" switch of play/recmode for now, because on for example s3is halfpressing the shutter activates rec mode!
  • free memory by using the item in the edge menu (also you should disable edge-overlay)

changes / enhancements to the mod by me:

  • together with the edge overlay the zoom setting is saved, so when you load the file after one year it zooms to the position your camera had when you shot it!
  • added the option so that an edge overlay is "locked", meaning the edgeoverlay you loaded or just created is not overwritten in the osd at half-press (this checkbox is overwritten on each camera startup... no big deal, but i dont like it like that right now)

This is a really great feature (for example for LONG-TERM TIMELAPSES, or stop-motion movies, or vertigo-effect, or stereography... the list is endless :D)

  • restructured the root menu (put imo the most often used items to the top, moved edge overlay from OSD menu to the root menu, moved remote params menu to the misc menu)

because of this new feature and all the new cams i upped the version to 0.8.0 already...
P.S: had to rewrite some of PlasmaHHs stuff (e.g. write -> fwrite), i hope i did everything correctly (it's working flawlessly on s3is and a620)

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/CHDK/LANG/english.lng

    r551 r580  
    556556415 "add raw suffix" 
    557557416 "  in Fahrenheit" 
    558  
     558417 "Load Edge Overlay" 
     559418 "Save Edge Overlay" 
     560419 "Enable in Play" 
     561420 "Free internal Memory" 
     562421 "Load+Set Zoom" 
     563422 "Lock Edge Overlay" 
  • trunk/CHDK/LANG/german.lng

    r551 r580  
    586586415 "Raw Suffix" 
    587587416 "  in Fahrenheit" 
     588417 "Lade Edge Overlay" 
     589418 "Speicher Edge Overlay" 
     590419 "Auch im Playmode" 
     591420 "Gib Speicher frei" 
     592421 "Lade+Setze Zoom" 
     593422 "Sperre Odge Overlay" 
  • trunk/core/conf.c

    r551 r580  
    133133         shooting_video_bitrate_change(conf.video_bitrate); 
    134134        } 
     135        conf.edge_overlay_lock = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this! 
    135136} 
    136137 
     
    370371    CONF_INFO(219, conf.bracketing_add_raw_suffix,         CONF_DEF_VALUE, i:0, NULL),                   
    371372    CONF_INFO(220, conf.temperature_unit,              CONF_DEF_VALUE, i:0, NULL), 
     373    CONF_INFO(221, conf.clear_zoom_override,         CONF_DEF_VALUE, i:1, NULL),                         
     374    CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
     375    CONF_INFO(223, conf.edge_overlay_lock,              CONF_DEF_VALUE, i:0, NULL), 
     376    CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
    372377    }; 
    373378#define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0])) 
  • trunk/core/edgeoverlay.c

    r515 r580  
    66#include "gui_draw.h" 
    77 
    8 // until the edge thresh is put into conf structure I have hardcoded the threshold  see "thresh" below 
     8// This edge overlay code has major changes to the "old" one. One major change 
     9// is, that it doesn cause my cam (ixus 950) to crash anymore by mistaking the 
     10// boundaries of the viewport buffer it can read from and write pixels to. 
     11// Unfortunately it still has the bug (that is also present in the original 
     12// version) that when you move the overlay too much you again overwrite data. 
     13// One might not necessarily notice it at once, or at all, but for me 
     14// unfortunately it overwrote vital data for the chdk menu structure. 
     15//  
     16// Also the old version was flickering for me and wasn't playing well with the 
     17// chdk osd. I tried to change a bit about that, which makes it also a bit 
     18// faster updating, at least on my cam. 
     19// 
     20// And then of course, this can load the viewport to a seperate file  
     21 
     22// the way we save edge overlays on their own... 
     23#define EDGE_FILE_PREFIX "edge_" 
     24#define EDGE_FILE_FORMAT EDGE_FILE_PREFIX "%04d.edg" 
     25 
    926static char * imgbuf = 0; 
    10   
    11  
     27static char * imgbuf_end = 0; 
     28static int inmem=0; 
     29// whole viewport size in bytes ?? 
     30static int viewport_size = 0; 
     31// width in bytes of one viewport line ?? 
     32static int viewport_width;// screenwidth * 3 
     33// flag to remember if current buffer is already saved, so hitting save won't 
     34// save it again 
     35static int is_saved = 0; 
     36// set this to 1 when things need to be moved, so that a redraw clears "old" 
     37// pixels... Otherwise it just will write pixels that need edge overlay data. 
     38// This sometimes leaves trails when the pixel alignment isn't nice but it is 
     39// better than writing "transparent" to everwhere, essentially overwriting 
     40// important things that will cause flickering. 
     41static int need_redraw = 0; 
     42 
     43// debug output that waits 
     44void out_wait( const char* buf ); 
     45 
     46void get_viewport_size( ) { 
     47        static int viewport_height; 
     48 
     49        // since screen_height is used in the drawing downwards, we should use it 
     50        // here too to calculate the buffer we need... 
     51        viewport_height = screen_height;//vid_get_viewport_height(); 
     52        viewport_width = screen_width * 3; 
     53        viewport_size = viewport_height * screen_width * 3; 
     54} 
     55 
     56void ensure_allocate_imagebuffer( ) {  
     57        if(imgbuf == 0) 
     58        { 
     59                imgbuf = malloc( viewport_size ); 
     60                imgbuf_end = imgbuf + (viewport_size); 
     61        } 
     62} 
     63 
     64// scans a filename for the number of the edge detection file it contains 
     65int get_edge_file_num( const char* fn ) 
     66{ 
     67        int num = 0; 
     68        if( strncmp(fn,EDGE_FILE_PREFIX,sizeof(EDGE_FILE_PREFIX)-1) == 0 ) 
     69        { // has the correct beginning at least, now try to read as a number... 
     70                fn += sizeof(EDGE_FILE_PREFIX); 
     71                while( *fn == '0' ) // skip leading 0s 
     72                { 
     73                        ++fn; 
     74                } 
     75                while( isdigit(*fn) ) 
     76                { 
     77                        num *= 10; 
     78                        num += *fn - '0'; 
     79                        ++fn; 
     80                } 
     81                // ignore anything else after it, that is like the ending etc. 
     82        } 
     83        return num; 
     84} 
     85 
     86// we eat up to 300k of memory, for people needing it we have a menu point 
     87// where they can manually free it. makes of course only sense when the edge 
     88// overlay is not active. 
     89void free_memory_edge_overlay(void){ 
     90        char buf[64]; 
     91        free(imgbuf); 
     92        imgbuf = 0; 
     93        sprintf(buf,"Freed %u bytes",viewport_size); 
     94        draw_string(30, 10, buf, conf.osd_color); 
     95        viewport_size = 0; 
     96} 
     97 
     98// saves the actual active overlay data to a file... Well, actually the 
     99// viewport is saved... 
     100void save_edge_overlay(void){ 
     101 
     102        char fn[64]; 
     103        char msg[64]; 
     104        FILE *fd; 
     105        DIR* d; 
     106        int fnum = 0; 
     107        int fr = 0; 
     108        int zoom = shooting_get_zoom(); 
     109        struct dirent* de; 
     110 
     111        // nothing to save? then dont save 
     112        if( !imgbuf ) return; 
     113 
     114        // first figure out the most appropriate filename to use 
     115        d = opendir(EDGE_SAVE_DIR); 
     116        if( ! d ) 
     117        { 
     118                return; 
     119        } 
     120 
     121        while( (de = readdir(d)) ) 
     122        { 
     123                fr = get_edge_file_num(de->name); 
     124                if( fr > fnum ) 
     125                { 
     126                        fnum = fr; 
     127                } 
     128        } 
     129        ++fnum; // the highest is set, we use the next one 
     130        get_viewport_size(); 
     131        // open the right file 
     132        sprintf(fn, EDGE_SAVE_DIR "/" EDGE_FILE_FORMAT, fnum ); 
     133        fd = fopen(fn, "wb"); 
     134        if(fd !=NULL) 
     135        { 
     136                // write the data 
     137                fwrite(imgbuf,viewport_size,1,fd); 
     138                fwrite(&zoom,4,1,fd); 
     139                is_saved = 1; 
     140                fclose(fd); 
     141                sprintf(msg, "Saved as %s",fn); 
     142                draw_string(30, 10, msg, conf.osd_color); 
     143        } 
     144        closedir(d); 
     145} 
     146 
     147// load the viewport copy thats being used for edge detection (and from that 
     148// displaying) from a file 
     149void load_edge_overlay( const char* fn ) { 
     150        FILE *fd; 
     151        int ret,ret2=0; 
     152        int zoom; 
     153 
     154        is_saved = 1; // won't want to save it again, its already there 
     155        get_viewport_size(); 
     156        ensure_allocate_imagebuffer( ); 
     157        fd = fopen(fn,"rb"); 
     158        if( fd != NULL ) 
     159        { 
     160                ret = fread(imgbuf,viewport_size,1,fd); 
     161                ret2 = fread (&zoom,4,1,fd); 
     162                fclose(fd); 
     163                if( (ret == 1) && (ret2 == 1) ) 
     164                { 
     165                        inmem = 1; // fake having loaded stuff 
     166                        if (conf.edge_overlay_zoom)     shooting_set_zoom(zoom); 
     167                } 
     168        } 
     169} 
     170 
     171// paint the edge overlay 
    12172void edge_overlay(){ 
    13173 
    14         //if(!(conf.edge_overlay_thresh) || !(conf.edge_overlay_enable)) return; 
    15  
    16         static int inmem=0; 
    17         static int viewport_height; 
    18         static int viewport_width;// screenwidth * 3 
    19         static int viewport_size; 
    20174        static int shotTaken = 0; 
    21175        static int imgmem = 0; 
    22176        static int ymin = 0; 
    23177        static int thresh; 
    24     thresh = conf.edge_overlay_thresh; //40 
     178        thresh = conf.edge_overlay_thresh; //40 
    25179        static int xoffset = 0; 
    26180        static int yoffset = 0; 
    27181        static int full_press = 0;//cure for flaky behavior. due to multiple  returns to the scrip during one full press 
    28182        static char strbuf[7] = "Frozen"; 
    29         static unsigned char *img; 
     183        static unsigned char *img; 
    30184        int i, hi, c; 
    31185        int x, y, h, v, ymax, y1, x1, y2; 
    32         char * ptrh1; 
    33         char * ptrh2; 
    34         char * ptrv1; 
    35         char * ptrv2; 
     186        const char * ptrh1; 
     187        const char * ptrh2; 
     188        const char * ptrv1; 
     189        const char * ptrv2; 
     190        char xbuf[64]; 
    36191        char * optr; 
    37192 
    38  
    39         img = vid_get_viewport_fb(); 
    40     viewport_height = vid_get_viewport_height(); 
    41         viewport_width = screen_width * 3; 
    42     viewport_size = viewport_height * screen_width; 
    43         if(imgbuf == 0) imgbuf = malloc(viewport_size * 3); 
    44   
    45         if((mode_get()&MODE_MASK) != MODE_PLAY) { 
     193        is_saved = 0; // a new one, we could potentially save it 
     194        if((mode_get()&MODE_MASK) != MODE_PLAY) 
     195        { 
     196                img = vid_get_viewport_fb(); 
     197        } 
     198        else 
     199        { 
     200                img = vid_get_viewport_fb_d(); 
     201        } 
     202        get_viewport_size(); 
     203        ensure_allocate_imagebuffer( ); 
     204        if(imgbuf == 0) return; // ensure failed, make the best we can out of it 
     205 
     206        if(conf.edge_overlay_play || ((mode_get()&MODE_MASK) != MODE_PLAY) ) { 
     207                // setup offsets for moving the edge overlay around. Always set 
     208                // need_redraw so that we actually do a complete redraw, overwriting 
     209                // also old pixels 
    46210                if (kbd_is_key_pressed(KEY_RIGHT)) { 
    47211                        xoffset -=XINC; 
     212                        ++need_redraw; 
    48213                } 
    49214                if (kbd_is_key_pressed(KEY_LEFT)) { 
    50215                        xoffset +=XINC; 
     216                        ++need_redraw; 
    51217                } 
    52218                if (kbd_is_key_pressed(KEY_DOWN)) { 
    53219                        yoffset -=YINC; 
     220                        ++need_redraw; 
    54221                } 
    55222                if (kbd_is_key_pressed(KEY_UP)) { 
    56223                        yoffset +=YINC; 
    57                 } 
    58   
    59                 if (kbd_is_key_pressed(KEY_SHOOT_HALF)||kbd_is_key_pressed(KEY_SHOOT_FULL)) { 
     224                        ++need_redraw; 
     225                } 
     226 
     227                if ((kbd_is_key_pressed(KEY_SHOOT_HALF)||kbd_is_key_pressed(KEY_SHOOT_FULL)) && (conf.edge_overlay_lock!=1)) { 
    60228                        if (kbd_is_key_pressed(KEY_SHOOT_FULL) && !full_press) { 
    61229                                shotTaken = 1 - shotTaken; 
    62                                 memcpy(imgbuf,img,viewport_size * 3); 
     230                                memcpy(imgbuf,img,viewport_size); 
    63231                                ymin = CALCYMARGIN; 
    64232                                inmem = 1; 
     
    71239                                return; 
    72240                        } 
    73                         memcpy(imgbuf,img,viewport_size * 3); 
     241                        memcpy(imgbuf,img,viewport_size); 
    74242                        ymin = CALCYMARGIN; 
    75243                        inmem = 1; 
     
    79247                } 
    80248                else full_press = 0; 
     249 
     250 
     251 
    81252                if (inmem && (ymin < screen_height-CALCYMARGIN)) { 
    82253                        ymax = ymin + (screen_height - 2 * CALCYMARGIN) / NSTAGES; 
     
    104275                        return; 
    105276                } 
     277 
    106278                if(inmem &&(ymin >= screen_height-CALCYMARGIN) &&  
    107279                        ((gui_get_mode() == GUI_MODE_NONE) || (gui_get_mode() == GUI_MODE_ALT))){ 
    108                                 //thresh = (conf.edge_overlay_thresh - 1) * 12; 
     280 
    109281                                for (y=MARGIN; y<screen_height-MARGIN; y++) { 
    110282                                        y1 = y + yoffset; 
    111283                                        if((y1 < CALCYMARGIN) || (y1 >= screen_height - CALCYMARGIN)) { 
     284                                                /* 
    112285                                                for (x=MARGIN; x < screen_width - MARGIN; x+=2) { 
    113286                                                        draw_pixel(x, y, 0); 
    114287                                                        draw_pixel(x+1, y, 0); 
    115288                                                } 
     289                                                */ 
    116290                                        } 
    117291                                        else { 
    118292                                                for (x=MARGIN; x < screen_width - MARGIN; x+=2) { 
    119293                                                        x1 = x + xoffset; 
     294                                                        // leave a margin normally, only write to it when a 
     295                                                        // full redraw is requested 
    120296                                                        if((x1 < 12) || (x1 >= screen_width-13)) { 
    121                                                                 draw_pixel(x, y, 0); 
    122                                                                 draw_pixel(x+1, y, 0); 
     297                                                                if( need_redraw ) 
     298                                                                { 
     299                                                                        draw_pixel(x, y, 0); 
     300                                                                        draw_pixel(x+1, y, 0); 
     301                                                                } 
    123302                                                        } 
    124303                                                        else { 
    125                                                                 c = 0; 
     304                                                                // draw a pixel if the threshold is reached. If 
     305                                                                // not, draw it transparent only if we want a 
     306                                                                // complete redraw to overwrite spurious pixels 
     307                                                                // or if the color of the existing pixel is the 
     308                                                                // same as the overlay color 
    126309                                                                if(imgbuf[y1 * viewport_width + x1 * 3 + 3]  > thresh) 
    127                                                                         c = conf.edge_overlay_color; 
    128                                                                 draw_pixel(x, y, c); 
    129                                                                 c = 0; 
     310                                                                { 
     311                                                                        draw_pixel(x, y, conf.edge_overlay_color ); 
     312                                                                } 
     313                                                                else if( need_redraw || (draw_get_pixel(x,y) == conf.edge_overlay_color) ) 
     314                                                                { 
     315                                                                        draw_pixel(x, y, 0); 
     316                                                                } 
     317 
    130318                                                                if(imgbuf[y1 * viewport_width + x1 * 3 + 5]  > thresh) 
    131                                                                         c = conf.edge_overlay_color; 
    132                                                                 draw_pixel(x+1, y, c); 
     319                                                                { 
     320                                                                        draw_pixel(x+1, y, conf.edge_overlay_color ); 
     321                                                                } 
     322                                                                else if( need_redraw || (draw_get_pixel(x,y) == conf.edge_overlay_color) ) 
     323                                                                { 
     324                                                                        draw_pixel(x+1, y, 0); 
     325                                                                } 
    133326                                                        } 
    134327                                                } 
    135328                                } 
    136                                 for (y2=MARGIN; y2<screen_height-MARGIN; y2++) { 
    137                                         draw_pixel(XGRID1,y2,0xff); 
    138                                         draw_pixel(XGRID2,y2,0xff); 
    139                                         if(y2 == YGRID1) for (x=MARGIN; x < screen_width - MARGIN; x++) draw_pixel(x,y2,0xff); 
    140                                         if(y2 == YGRID2) for (x=MARGIN; x < screen_width - MARGIN; x++) draw_pixel(x,y2,0xff); 
    141                                 } 
     329                                // disabled drawing the grid, the new way of drawing the 
     330                                // overlay should leave the standard grid intact, allowing the 
     331                                // custom grid to remain intact too. 
    142332                                if(shotTaken) draw_string(30, 10, strbuf, conf.osd_color); 
     333                        } 
     334                        // If a complete redraw was requested, decrement the request. That 
     335                        // way we do it as much as it was requested, also in one run. Will 
     336                        // cause some flickering, but better than nothing. 
     337                        if( need_redraw ) 
     338                        { 
     339                                --need_redraw; 
    143340                        } 
    144341                        return; 
     
    155352        return; 
    156353} 
     354 
     355// there used to be some commented out version here. it was confusing, so I 
     356// removed it. Its still in the svn anyways. 
    157357  
    158  
    159 /*// Code to test the idea of an edge overlay 
    160 // Put                  edge_overlay();                 after the line histogram_process();  
    161   
    162   
    163 // Put the following after  the line #include "motion_detector.h" in main.c 
    164 #include "gui_draw.h" 
    165   
    166 // until the edge thresh is put into conf structure I have hardcoded the threshold  see "thresh" below 
    167 static char * imgbuf = 0; 
    168   
    169 #define MARGIN 30 
    170 #define CALCYMARGIN 3 
    171 #define EDGECOLOR 0x66 
    172 #define NSTAGES 4 
    173 #define XINC 6 
    174 #define YINC 2 
    175 #define XGRID1 120 
    176 #define XGRID2 240 
    177 #define YGRID1 80 
    178 #define YGRID2 160 
    179   
    180 void edge_overlay(){ 
    181         static int inmem=0; 
    182         static int viewport_height; 
    183         static int viewport_width;// screenwidth * 3 
    184         static int viewport_size; 
    185         static int shotTaken = 0; 
    186         static int imgmem = 0; 
    187         static int ymin = 0; 
    188         static  int thresh = 40; 
    189         static int xoffset = 0; 
    190         static int yoffset = 0; 
    191         static int full_press = 0;//cure for flaky behavior. due to multiple  returns to the scrip during one full press 
    192         static char strbuf[7] = "Frozen"; 
    193         static unsigned char *img; 
    194         int i, hi, c; 
    195         int x, y, h, v, ymax, y1, x1, y2; 
    196         char * ptrh1; 
    197         char * ptrh2; 
    198         char * ptrv1; 
    199         char * ptrv2; 
    200         char * optr; 
    201   
    202 //      if(!conf.edge_thresh) return; 
    203   
    204         img = vid_get_viewport_fb(); 
    205     viewport_height = vid_get_viewport_height(); 
    206         viewport_width = screen_width * 3; 
    207     viewport_size = viewport_height * screen_width; 
    208         if(imgbuf == 0) imgbuf = malloc(viewport_size * 3); 
    209   
    210         if((mode_get()&MODE_MASK) != MODE_PLAY) { 
    211                 if (kbd_is_key_pressed(KEY_RIGHT)) { 
    212                         xoffset -=XINC; 
    213                 } 
    214                 if (kbd_is_key_pressed(KEY_LEFT)) { 
    215                         xoffset +=XINC; 
    216                 } 
    217                 if (kbd_is_key_pressed(KEY_DOWN)) { 
    218                         yoffset -=YINC; 
    219                 } 
    220                 if (kbd_is_key_pressed(KEY_UP)) { 
    221                         yoffset +=YINC; 
    222                 } 
    223   
    224                 if (kbd_is_key_pressed(KEY_SHOOT_HALF)||kbd_is_key_pressed(KEY_SHOOT_FULL)) { 
    225                         if (kbd_is_key_pressed(KEY_SHOOT_FULL) && !full_press) { 
    226                                 shotTaken = 1 - shotTaken; 
    227                                 memcpy(imgbuf,img,viewport_size * 3); 
    228                                 ymin = CALCYMARGIN; 
    229                                 inmem = 1; 
    230                                 full_press = 1; 
    231                                 xoffset = 0; 
    232                                 yoffset = 0; 
    233                                 return; 
    234                         } 
    235                         if(shotTaken) { 
    236                                 return; 
    237                         } 
    238                         memcpy(imgbuf,img,viewport_size * 3); 
    239                         ymin = CALCYMARGIN; 
    240                         inmem = 1; 
    241                         xoffset = 0; 
    242                         yoffset = 0; 
    243                         return; 
    244                 } 
    245                 else full_press = 0; 
    246                 if (inmem && (ymin < screen_height-CALCYMARGIN)) { 
    247                         ymax = ymin + (screen_height - 2 * CALCYMARGIN) / NSTAGES; 
    248                         if(ymax > screen_height - CALCYMARGIN) ymax = screen_height - CALCYMARGIN; 
    249                         for (y=ymin; y<ymax; y++) { 
    250                                 ptrh1 = imgbuf + y * viewport_width + 7; 
    251                                 ptrh2 = imgbuf + y * viewport_width - 5; 
    252                                 ptrv1 = imgbuf + (y + 1) * viewport_width + 1; 
    253                                 ptrv2 = imgbuf + (y - 1) * viewport_width + 1; 
    254                                 optr = imgbuf + y * viewport_width + 3; 
    255                                 for (x=12; x<(screen_width- 4) * 3; x+=6) { 
    256                                         h = ptrh1[x] - ptrh2[x]; 
    257                                         if(h  < 0) h = -h; 
    258                                         v = ptrv1[x] - ptrv2[x]; 
    259                                         if(v  < 0) v = -v; 
    260                                         optr[x] = h + v; 
    261                                         h = ptrh1[x + 3] - ptrh2[x + 3]; 
    262                                         if(h  < 0) h = -h; 
    263                                         v = ptrv1[x + 3] - ptrv2[x + 3]; 
    264                                         if(v  < 0) v = -v; 
    265                                         optr[x + 2] = h + v; 
    266                                 } 
    267                         } 
    268                         ymin += (screen_height - 2 * CALCYMARGIN) / NSTAGES; 
    269                         return; 
    270                 } 
    271                 if(inmem &&(ymin >= screen_height-CALCYMARGIN) &&  
    272                         ((gui_get_mode() == GUI_MODE_NONE) || (gui_get_mode() == GUI_MODE_ALT))){ 
    273 //                              thresh = (conf.edge_thresh - 1) * 12; 
    274                                 for (y=MARGIN; y<screen_height-MARGIN; y++) { 
    275                                         y1 = y + yoffset; 
    276                                         if((y1 < CALCYMARGIN) || (y1 >= screen_height - CALCYMARGIN)) { 
    277                                                 for (x=MARGIN; x < screen_width - MARGIN; x+=2) { 
    278                                                         draw_pixel(x, y, 0); 
    279                                                         draw_pixel(x+1, y, 0); 
    280                                                 } 
    281                                         } 
    282                                         else { 
    283                                                 for (x=MARGIN; x < screen_width - MARGIN; x+=2) { 
    284                                                         x1 = x + xoffset; 
    285                                                         if((x1 < 12) || (x1 >= screen_width-13)) { 
    286                                                                 draw_pixel(x, y, 0); 
    287                                                                 draw_pixel(x+1, y, 0); 
    288                                                         } 
    289                                                         else { 
    290                                                                 c = 0; 
    291                                                                 if(imgbuf[y1 * viewport_width + x1 * 3 + 3]  > thresh) 
    292                                                                         c = EDGECOLOR; 
    293                                                                 draw_pixel(x, y, c); 
    294                                                                 c = 0; 
    295                                                                 if(imgbuf[y1 * viewport_width + x1 * 3 + 5]  > thresh) 
    296                                                                         c = EDGECOLOR; 
    297                                                                 draw_pixel(x+1, y, c); 
    298                                                         } 
    299                                                 } 
    300                                 } 
    301                                 for (y2=MARGIN; y2<screen_height-MARGIN; y2++) { 
    302                                         draw_pixel(XGRID1,y2,0xff); 
    303                                         draw_pixel(XGRID2,y2,0xff); 
    304                                         if(y2 == YGRID1) for (x=MARGIN; x < screen_width - MARGIN; x++) draw_pixel(x,y2,0xff); 
    305                                         if(y2 == YGRID2) for (x=MARGIN; x < screen_width - MARGIN; x++) draw_pixel(x,y2,0xff); 
    306                                 } 
    307                                 if(shotTaken) draw_string(30, 10, strbuf, conf.osd_color); 
    308                         } 
    309                         return; 
    310                 } 
    311         } 
    312         else { 
    313                 full_press = 0; 
    314                 inmem = 0; 
    315                 shotTaken = 0; 
    316                 ymin = 0; 
    317                 xoffset = 0; 
    318                 yoffset = 0; 
    319         } 
    320         return; 
    321 } 
    322   
    323 //End of edge detector code.  next put                  edge_overlay();                 after the line histogram_process();  
    324 */ 
     358// vim: tabstop=4 shiftwidth=4 
  • trunk/core/edgeoverlay.h

    r515 r580  
    22#define EDGE_OVERLAY_H 
    33 
     4// margin in which around the center nothing is displayed. Good for not 
     5// interfering too much with the OSD 
    46#define MARGIN 30 
     7// stuff influencing the algorithm 
    58#define CALCYMARGIN 3 
    6 //#define EDGECOLOR 0x66 
    79#define NSTAGES 4 
     10// steps for up/down/left/right moving the overlay in ALT mode 
    811#define XINC 6 
    912#define YINC 2 
    10 #define XGRID1 120 
    11 #define XGRID2 240 
    12 #define YGRID1 80 
    13 #define YGRID2 160 
     13 
     14// if you change this, remember to change the mkdir in main too 
     15#define EDGE_SAVE_DIR "A/CHDK/EDGE" 
    1416 
    1517void edge_overlay(); 
     18void save_edge_overlay(void); 
     19void load_edge_overlay( const char* ); 
     20void free_memory_edge_overlay(void); 
    1621 
    1722#endif 
  • trunk/core/gui.c

    r577 r580  
    4444        #include "gui_logo.h" 
    4545#endif 
     46#include "edgeoverlay.h" 
    4647//------------------------------------------------------------------- 
    4748 
     
    152153static void gui_draw_load_lang(int arg); 
    153154static void gui_menuproc_mkbootdisk(int arg); 
     155static void gui_menuproc_edge_save(int arg); 
     156static void gui_menuproc_edge_load(int arg); 
     157static void gui_menuproc_edge_free(int arg); 
     158 
    154159#ifndef OPTIONS_AUTOSAVE 
    155160static void gui_menuproc_save(int arg); 
     
    394399    {0x33,LANG_MENU_DEBUG_SWAP_PART,         MENUITEM_PROC,             (int*)gui_menuproc_swap_patitons }, 
    395400#endif 
     401    {0x2b,LANG_MENU_MAIN_RESET_OPTIONS,      MENUITEM_PROC,      (int*)gui_menuproc_reset }, 
    396402#ifdef OPT_DEBUGGING 
    397403    {0x2a,LANG_MENU_MAIN_DEBUG,              MENUITEM_SUBMENU,   (int*)&debug_submenu }, 
    398404#endif 
    399     {0x2b,LANG_MENU_MAIN_RESET_OPTIONS,      MENUITEM_PROC,      (int*)gui_menuproc_reset }, 
     405    {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu }, 
    400406    {0x51,LANG_MENU_BACK,                    MENUITEM_UP }, 
    401407    {0}, 
     
    576582#ifdef OPT_EDGEOVERLAY 
    577583static CMenuItem edge_overlay_submenu_items[] = { 
    578     {0x7f,LANG_MENU_EDGE_OVERLAY_ENABLE,     MENUITEM_BOOL,          &conf.edge_overlay_enable }, 
     584    {0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,     MENUITEM_BOOL,          &conf.edge_overlay_enable }, 
     585    {0x33,LANG_MENU_EDGE_SAVE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_save }, 
     586    {0x5c,LANG_MENU_EDGE_ZOOM,     MENUITEM_BOOL,          &conf.edge_overlay_zoom }, 
     587    {0x5c,LANG_MENU_EDGE_LOCK,     MENUITEM_BOOL,          &conf.edge_overlay_lock }, 
    579588    {0x7f,LANG_MENU_EDGE_OVERLAY_TRESH,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255)}, 
    580589    {0x65,LANG_MENU_EDGE_OVERLAY_COLOR,      MENUITEM_COLOR_FG,      (int*)&conf.edge_overlay_color }, 
    581  
     590    {0x5c,LANG_MENU_EDGE_PLAY,                  MENUITEM_BOOL,          &conf.edge_overlay_play }, //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button 
     591    {0x33,LANG_MENU_EDGE_FREE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_free }, 
     592    {0x33,LANG_MENU_EDGE_LOAD,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_load }, 
    582593    {0x51,LANG_MENU_BACK,                    MENUITEM_UP }, 
    583594    {0} 
     
    683694    {0x59,LANG_MENU_OSD_TEMP_FAHRENHEIT,      MENUITEM_BOOL,      &conf.temperature_unit}, 
    684695    {0x72,LANG_MENU_OSD_LAYOUT_EDITOR,       MENUITEM_PROC,      (int*)gui_draw_osd_le }, 
    685 #ifdef OPT_EDGEOVERLAY 
    686     {0x7f,LANG_MENU_EDGE_OVERLAY,         MENUITEM_SUBMENU,   (int*)&edge_overlay_submenu }, 
    687 #endif 
    688696    {0x2f,LANG_MENU_OSD_GRID_PARAMS,         MENUITEM_SUBMENU,   (int*)&grid_submenu }, 
    689697    {0x22,LANG_MENU_OSD_VALUES,                 MENUITEM_SUBMENU,   (int*)&values_submenu }, 
     
    786794#endif 
    787795    {0x24,LANG_MENU_MAIN_RAW_PARAM,          MENUITEM_SUBMENU,   (int*)&raw_submenu }, 
     796#ifdef OPT_EDGEOVERLAY 
     797    {0x7f,LANG_MENU_EDGE_OVERLAY,         MENUITEM_SUBMENU,   (int*)&edge_overlay_submenu }, 
     798#endif 
     799#ifdef OPT_CURVES 
     800    {0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU,   (int*)&curve_submenu }, 
     801#endif 
     802    {0x25,LANG_MENU_MAIN_HISTO_PARAM,        MENUITEM_SUBMENU,   (int*)&histo_submenu }, 
     803    {0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU,   (int*)&zebra_submenu }, 
    788804    {0x22,LANG_MENU_MAIN_OSD_PARAM,          MENUITEM_SUBMENU,   (int*)&osd_submenu }, 
    789805    {0x28,LANG_MENU_MAIN_VISUAL_PARAM,       MENUITEM_SUBMENU,   (int*)&visual_submenu }, 
    790     {0x25,LANG_MENU_MAIN_HISTO_PARAM,        MENUITEM_SUBMENU,   (int*)&histo_submenu }, 
    791     {0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU,   (int*)&zebra_submenu }, 
    792806    {0x27,LANG_MENU_MAIN_SCRIPT_PARAM,       MENUITEM_SUBMENU,   (int*)&script_submenu }, 
    793 #ifdef OPT_CURVES 
    794     {0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU,   (int*)&curve_submenu }, 
    795 #endif 
    796     {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu }, 
    797807    {0x29,LANG_MENU_MAIN_MISC,               MENUITEM_SUBMENU,   (int*)&misc_submenu }, 
    798808#ifndef OPTIONS_AUTOSAVE 
     
    18691879//              if (conf.zoom_override) shooting_set_zoom(conf.zoom_override_value); 
    18701880#endif 
     1881} 
     1882 
     1883static void gui_load_edge_selected( const char* fn ) { 
     1884    if( fn ) 
     1885        load_edge_overlay(fn); 
    18711886} 
    18721887 
     
    29032918} 
    29042919 
     2920void gui_menuproc_edge_free(int arg) { 
     2921    free_memory_edge_overlay(); 
     2922} 
     2923 
     2924void gui_menuproc_edge_save(int arg) { 
     2925    save_edge_overlay(); 
     2926} 
     2927 
     2928void gui_menuproc_edge_load(int arg) { 
     2929    DIR   *d; 
     2930    char  *path = EDGE_SAVE_DIR; 
     2931    const char* fn; 
     2932 
     2933    // if exists, go into 
     2934    d=opendir(path); 
     2935    if (d) { 
     2936        closedir(d); 
     2937    } else { 
     2938        path="A"; 
     2939    } 
     2940 
     2941    gui_fselect_init(LANG_MENU_EDGE_LOAD, path, gui_load_edge_selected); 
     2942} 
     2943 
    29052944//------------------------------------------------------------------- 
    29062945#ifdef OPT_CALENDAR 
     
    30373076        } 
    30383077} 
     3078 
     3079 
  • trunk/core/gui_lang.c

    r551 r580  
    536536"415 \"Add raw-suffix\"\n" 
    537537"416 \"  in Fahrenheit\"\n" 
     538"417 \"Load Edge Overlay\"\n" 
     539"418 \"Save Edge Overlay\"\n" 
     540"419 \"Enable in Play\"\n" 
     541"420 \"Free internal Memory\"\n" 
     542"421 \"Load+Set Zoom\"\n" 
     543"422 \"Lock Edge Overlay\"\n" 
    538544 
    539545; 
  • trunk/core/gui_lang.h

    r551 r580  
    520520#define LANG_MENU_SCRIPT_PARAM_SAVE 410 
    521521#define LANG_OSD_LAYOUT_EDITOR_EV_VIDEO 411 
    522  
    523522#define LANG_MENU_OVERRIDE_ZOOM_VALUE          412 
    524523#define LANG_MENU_OVERRIDE_ZOOM           413 
     
    526525#define LANG_MENU_BRACKETING_ADD_RAW_SUFFIX 415 
    527526#define LANG_MENU_OSD_TEMP_FAHRENHEIT 416 
     527#define LANG_MENU_EDGE_LOAD             417 
     528#define LANG_MENU_EDGE_SAVE             418 
     529#define LANG_MENU_EDGE_PLAY             419 
     530#define LANG_MENU_EDGE_FREE             420 
     531#define LANG_MENU_EDGE_ZOOM             421 
     532#define LANG_MENU_EDGE_LOCK             422 
    528533//------------------------------------------------------------------- 
    529534 
    530 #define GUI_LANG_ITEMS                  416 
     535#define GUI_LANG_ITEMS                  422 
    531536 
    532537//------------------------------------------------------------------- 
  • trunk/core/gui_osd.c

    r566 r580  
     1#include "camera.h" 
    12#include "stdlib.h" 
    23#include "keyboard.h" 
     
    282283    if (buf) { 
    283284        ++timer; 
    284         img_buf=((mode_get()&MODE_MASK) == MODE_PLAY)?vid_get_viewport_fb_d():vid_get_viewport_fb(); 
     285        // Try to get the best viewport buffer. In playmode its the _d one, in 
     286        // record mode we try to get the fast live one first 
     287        if( (mode_get() & MODE_MASK) == MODE_PLAY ) { 
     288            img_buf = vid_get_viewport_fb_d(); 
     289        } 
     290        else { 
     291            img_buf = vid_get_viewport_live_fb(); 
     292            if( !img_buf ) { 
     293                img_buf = vid_get_viewport_fb(); 
     294            } 
     295        } 
    285296        viewport_height = vid_get_viewport_height(); 
    286297        switch (conf.zebra_mode) { 
  • trunk/core/main.c

    r556 r580  
    104104    mkdir("A/CHDK/DATA"); 
    105105    mkdir("A/CHDK/LOGS"); 
     106#ifdef EDGEOVERLAY 
     107    mkdir("A/CHDK/EDGE"); 
     108#endif 
    106109    auto_started = 0; 
    107110 
  • trunk/doc/version.txt

    r577 r580  
    22 
    33version / revision / author 
     4 
     50.8.0 / #780 / PhyrePhoX 
     6 
     7tadaa! major pimping of an already cool feature! 
     8you can now SAVE and LOAD edge overlays! this was written by PlasmaHH (shy guy, only in irc :D) 
     9Yes, you read it right: 
     10- save an edge overlay: create an overlay (enable overlay and press half-press) -> go to overlay menu and press save 
     11- load an overlay (go to menu and choose an *.edg file) 
     12- create overlays from jpgs in playmode! (only works on cameras that have a "hardware" switch of play/recmode for now, because on for example s3is halfpressing the shutter activates rec mode! 
     13- free memory by using the item in the edge menu (also you should disable edge-overlay) 
     14changes / enhancements to the mod by me:  
     15- together with the edge overlay the zoom setting is saved, so when you load the file after one year it zooms to the position your camera had when you shot it! 
     16- added the option so that an edge overlay is "locked", meaning the edgeoverlay you loaded or just created is not overwritten in the osd at half-press (this checkbox is overwritten on each camera startup... no big deal, but i dont like it like that right now) 
     17This is a really great feature (for example for LONG-TERM TIMELAPSES, or stop-motion movies, or vertigo-effect, or stereography... the list is endless :D) 
     18 
     19* restructured the root menu (put imo the most often used items to the top, moved edge overlay from OSD menu to the root menu, moved remote params menu to the misc menu) 
     20 
     21because of this new feature and all the new cams i upped the version to 0.8.0 already... 
     22P.S: had to rewrite some of PlasmaHHs stuff (e.g. write -> fwrite), i hope i did everything correctly (it's working flawlessly on s3is and a620) 
     23 
     240.7.7 / #578-579 / php 
     25 
     26* small fixes 
    427 
    5280.7.7 / #577 / php 
  • trunk/include/conf.h

    r551 r580  
    245245    int edge_overlay_enable; 
    246246    int edge_overlay_thresh; 
     247    int edge_overlay_zoom; // shall zoom be set when *edg file is loaded? 
     248    int edge_overlay_lock; // whether edge overlay should be overwritten on each half-press or not 
     249    int edge_overlay_play; // whether edge overlay is switched on also for play mode 
    247250    color edge_overlay_color; 
    248251 
     
    259262     
    260263    long mem_view_addr_init; 
     264 
    261265} Conf; 
    262266 
  • trunk/version.inc

    r576 r580  
    1 BUILD_NUMBER := 0.7.7 
     1BUILD_NUMBER := 0.8.0 
Note: See TracChangeset for help on using the changeset viewer.