Motion Detection too slow? - page 23 - Script Writing - CHDK Forum

Motion Detection too slow?

  • 247 Replies
  • 137194 Views
*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Motion Detection too slow?
« Reply #220 on: 19 / December / 2008, 04:39:57 »
Advertisements
uhm, i dont really know, tbh i dont really get what this does, perhaps someone with more experience can take a look at this. i might also just ask mx3 in irc next time i see him.

Re: Motion Detection too slow?
« Reply #221 on: 16 / May / 2009, 16:36:28 »
I'm a bit lazy so I don't use IDA to find out addresses

1) you have to make two RAM dumps (one dark (close lenses by hand), second bright)
2) change find_diffs.bat to use your files
3) run it
you will get file where will be 3 lines with "bytes: 3F480" string
such way you will determine addresses of frame buffers
4) nexzt step - find out array with these addresses
change zzz.bat and run it
you will get file with references to these frame buffers ( bellow file is for 1.00f)
[0x000052EC] : 105F1370
[0x000052F0] : 10670D50
[0x000052F4] : 106F0730
[0x000069A0] : 10670D50
[0x000069A4] : 10670D50
[0x00006A28] : 105F1370
[0x000AC600] : 10670D50
[0x00304008] : 106F0730
[0x003140E0] : 10670D50
[0x003140E4] : 10670D50

52EC and next 2 are nearby
this is array I mentioned
+0x10 - index variable - use it to get item from this array

mx3:

Your find_diffs.bat file seems to call find_diffs.exe 3 times on 3 different pairs of dump files, including one pair of "half press" dump files.  Do I just need to make the following call, with 10 and 6400 as parameters?

Code: [Select]
find_diffs dark.RAM bright.RAM 10 6400 > output.regions.txt
And then do I run the zzz.bat file on the dark or bright dump file?

Thanks!

*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #222 on: 24 / May / 2009, 07:21:10 »
mx3:
Your find_diffs.bat file seems to call find_diffs.exe 3 times on 3 different pairs of dump files, including one pair of "half press" dump files.  Do I just need to make the following call, with 10 and 6400 as parameters?
actually I do not quite remember preciciously this business with RAM comparing.
I think it is enough to compare dark and light files only.
I assume you have dump files with size of 32mb - 6400bytes = 33554432 - 6400 = 33548032
6400 stands for initial part of dump stripped by ram dumper so find_diffs will show you real addresses instead of offsets in file - it is just built-in calculator.
10 stands for 10quads of bytes (10*4) - it is threshold to filter out small memory fragments which where changed due working of OS. you can easily make it 100 or higher because we are looking for big areas.

And then do I run the zzz.bat file on the dark or bright dump file?
you can call find_u32s (zzz.bat) on any of thosu files - it should return identical results
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

Re: Motion Detection too slow?
« Reply #223 on: 25 / May / 2009, 05:28:54 »
And then do I run the zzz.bat file on the dark or bright dump file?
you can call find_u32s (zzz.bat) on any of thosu files - it should return identical results

My zzz.bat file contains:
Code: [Select]
find_u32s bright.JPG 1900 005F1370 00670D50 006F0730 105F1370 10670D50 106F0730 > bright.refsand it creates a zero-byte file.  Same for the dark dump file.  Am I supposed to change the parameters to the find_u32s command, or keep the ones you have there?


*

Offline mx3

  • ****
  • 372
Re: Motion Detection too slow?
« Reply #224 on: 25 / May / 2009, 05:47:04 »
My zzz.bat file contains:
Code: [Select]
find_u32s bright.JPG 1900 005F1370 00670D50 006F0730 105F1370 10670D50 106F0730 > bright.refsand it creates a zero-byte file.  Same for the dark dump file.  Am I supposed to change the parameters to the find_u32s command, or keep the ones you have there?
you have to change these numbers
first 1900 - it is same 6400 but in hexadecimal notation
can you provide output from find_diffs ?

PS: you can contact me via mail, skype or irc. I think it would accelerate solution of your problem
skype: max_dtc. ICQ: 125985663, email: win.drivers(at)gmail, eVB decompiler

Re: Motion Detection too slow?
« Reply #225 on: 25 / May / 2009, 16:28:44 »
mx3: sent you an email.

I also don't see any way to post an attachment here.

*

Offline na560

  • *
  • 11
Re: Motion Detection too slow?
« Reply #226 on: 07 / June / 2009, 06:54:47 »
I've run mx3's find_diffs and find_u32s on an a530 and an a560 and uncovered the addresses for speeding up motion detection.
The addresses for the a530 match with the a540 and the relevant code is:
Code: [Select]
void *vid_get_viewport_live_fb()
{
//    return (void*)0x0;
    void **fb=(void **)0x5288;
    unsigned char buff = *((unsigned char*)0x5298);
    if (buff == 0) {
        buff = 2;
    }
    else {
        buff--;
    }
    return fb[buff];
}

For the a560 vid_get_viewport_live_fb should be:
Code: [Select]
void *vid_get_viewport_live_fb()
{
//    return (void*)0x0;
    void **fb=(void **)0x64F0;
    unsigned char buff = *((unsigned char*)0x6500);
    if (buff == 0) {
        buff = 2;
    }
    else {
        buff--;
    }
    return fb[buff];
}

I tested these changes with fudgey's MDFB script and got a 40-50 ms speedup.
Could a developer please add these changes to a future Trunk revision? Thanks.

*

Offline reyalp

  • ******
  • 12437
Re: Motion Detection too slow?
« Reply #227 on: 07 / June / 2009, 20:21:52 »
Added svn 772
Don't forget what the H stands for.


Re: Motion Detection too slow?
« Reply #228 on: 09 / June / 2009, 16:13:45 »
For A700 firmware version 100b, the relevant locations (thanks, mx3!) are 0x5264 & 0x5274.

void *vid_get_viewport_live_fb()
{
//    return (void*)0x0;
    void **fb=(void **)0x5264;
    unsigned char buff = *((unsigned char*)0x5274);
    if (buff == 0) {
        buff = 2;
    }
    else {
        buff--;
    }
    return fb[buff];
}

gives a similar speedup (40-50ms) as above.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion Detection too slow?
« Reply #229 on: 09 / June / 2009, 17:43:34 »
a700 added in svn trunk revision 773, http://tools.assembla.com/chdk/changeset/773

 

Related Topics