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

Motion Detection too slow?

  • 253 Replies
  • 168738 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Motion Detection too slow?
« Reply #130 on: 08 / February / 2008, 18:02:15 »
Advertisements
I modified my LED blinker sequence, it's now similar to jonnythe's mdtest app (for this first test, 55 ms flash followed directly by 14 LEDs blinking for 10 ms one at a time, then a 10 second dead time). I can verify that there is significant variation in the motion detection response time, i.e. it's not (just) Windows displays acting up. I used M mode making the view rather dark apart from the very bright LEDs.

I don't have any of the recent optimizations, I used allbest build 16 on the a570is using the script essentially similar to the one posted at http://chdk.setepontos.com/index.php/topic,471.0.html.

I ran 3 sets or measurements with 32 "flash" sequences each, all 96 were detected and shot properly. I used slightly different cols/rows/threshold settings between the measurements, with no change in response. Out of the 96 shots, the fastest were 110 ms +- 5 ms, slowest 180 ms +- 5 ms, with 140 ms average and median, 21 ms standard deviation. That's a tolerance of +29% / -21 % from the average.

Btw, the shapes of the distributions from these three sets differ from each other quite a lot, I know 32 is not a huge statistical sample, but adding up these 3 sets evens the distribution out nicely, which makes me think any MD test program should have a random delay (preferably to sub-millisecond accuracy) between two test lightnings, just to weed out any "synchronizing" that might happen between the test app and the camera.


Also, since my "flash" length of 55 ms summed the fastest response (110 ms +- 5 ms) is less than the slowest responses,  I figured that the slowest responses could actually have been shots where the flash failed to trigger the MD, but the first LED did it instead (my "flash" is actually just two LEDs in one corner flashing, because there is not enough power to enable all LEDs simultaneously). Anyway, this was not the case, since I disabled the first 4 LEDs, let the test run for 15 shots and still got these slow responses.

Re: Motion Detection too slow?
« Reply #131 on: 09 / February / 2008, 02:50:59 »
Deleted
« Last Edit: 22 / April / 2008, 10:31:50 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

Re: Motion Detection too slow?
« Reply #132 on: 09 / February / 2008, 03:30:42 »
With that version of the program I don't think it really matters much about focus. I've always just eye-balled the focus, hand-held the camera and shot, even with half a second shutter :)

Sorry for taking so long with the next version. I've been busy with life things.

The problem is with the current idea, you can't get much more accuracy. For example, my CRT monitor is running at 75Hz. That means the screen refreshes about every 13.3ms. So that's the best accuracy possible. With LCD's it's a bit more complex. I've been working on an opengl version. By disabling vsync I think it's possible to get better timing, but making it easy to read off the times is hard. But I think it's possible to get less than 5ms accuracy by doing it this way. I have no idea if it would work with an LCD monitor though.

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Motion Detection too slow?
« Reply #133 on: 09 / February / 2008, 04:27:45 »
I've been working on an opengl version. By disabling vsync I think it's possible to get better timing, but making it easy to read off the times is hard. But I think it's possible to get less than 5ms accuracy by doing it this way.

With the OpenGL it's not a big deal to get 1ms accuracy.  Some days I wrote a program to check the monitor lag.

You can see Fraps counter in the top-right corner of window.
CHDK Developer.


Re: Motion Detection too slow?
« Reply #134 on: 09 / February / 2008, 04:42:27 »
Gee that looks familiar :)

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Motion Detection too slow?
« Reply #135 on: 09 / February / 2008, 04:53:17 »
If you are interested in sources...
CHDK Developer.

Re: Motion Detection too slow?
« Reply #136 on: 09 / February / 2008, 05:12:41 »
Yeah pretty much the same idea:
Code: [Select]
    BoxCount := Round( (GetTickCount - fStartTime) / fInterval );
    XPos := BoxCount div fRowCount;
    YPos := BoxCount mod fRowCount;

    sx := XPos * fBoxWidth;
    sy := YPos * fBoxHeight;

    glBegin(GL_POLYGON);

      glVertex2f( sx, sy );
      glVertex2f( sx, sy+fBoxHeight );
      glVertex2f( sx+fBoxWidth, sy+fBoxHeight );
      glVertex2f( sx+fBoxWidth, sy );

    glEnd();

     glFlush();
//     glFinish();

     SwapBuffers( fWinHandle );
Though not optimized to use performance counter etc yet.
But how do you tell the position (time) with your code when the camera shutter is open for a certain amount of time?

Oh, and are they LCD monitors?
« Last Edit: 09 / February / 2008, 05:15:47 by jonnythe »

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Motion Detection too slow?
« Reply #137 on: 09 / February / 2008, 05:36:19 »
But how do you tell the position (time) with your code when the camera shutter is open for a certain amount of time?
Oh, and are they LCD monitors?

For my task it was unnecessary to sync the program with a camera. I just connected two LCD monitors to a single video card, put them side-by-side, set up "Clone" mode for my desktop and took a picture (in any time).

In each pair: left - NEC 1860NX; right - Samsung 244T.
The NEC is 15-30ms faster than Samsung.


The NEC already draws a next frame whereas Samsung is still in a previous.
« Last Edit: 09 / February / 2008, 05:38:24 by GrAnd »
CHDK Developer.


Re: Motion Detection too slow?
« Reply #138 on: 09 / February / 2008, 05:40:56 »
Hmmm, I don't really understand your program. Each "grid" of blocks is made of 100 squares. On my computer it takes approx. 1 second to draw each block. That gives 10ms accuracy.

The point is though yes it's easy to get fast response with opengl. But to use it in a way the camera timing can be worked out is something different. My idea is to draw the blocks downwards. If vsync is disabled then it should be possible to stay ahead of the scanline.

Edit: sorry you posted just before me. Do you have any thoughts on my idea and how to implement it?
« Last Edit: 09 / February / 2008, 05:42:34 by jonnythe »

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Motion Detection too slow?
« Reply #139 on: 09 / February / 2008, 05:46:16 »
Hmmm, I don't really understand your program. Each "grid" of blocks is made of 100 squares. On my computer it takes approx. 1 second to draw each block. That gives 10ms accuracy.
Did you maximize the window? For the large window it will be slower.
On my PC with original window size in continuous drawing the 1.exe can achieve 4100fps, the 2.exe - 6500fps.
For the maximized window (1920x1200): 1.exe - 340fps, 2.exe - 480fps.

You can use Fraps to measure FPS.
« Last Edit: 09 / February / 2008, 05:54:32 by GrAnd »
CHDK Developer.

 

Related Topics