Motion Detection - time for a second look ? - page 6 - General Discussion and Assistance - CHDK Forum

Motion Detection - time for a second look ?

  • 81 Replies
  • 36193 Views
Re: Motion Detection - time for a second look ?
« Reply #50 on: 06 / February / 2013, 09:11:46 »
Advertisements
I was thinking about this - one of the problems with current cameras is the relatively long delay after the full shutter press to the actual shutter activation.  To close the gap I wonder if we could put a hook in wait_until_remote_button_is_released to wait for the motion detector instead of the remote trigger?
Reading some of the old posts,  it looks like calling the MD detect code after a half-press, focus lock, exposure lock combination might have provided a significant speedup to that early code.

I recall experimenting with wait_until_remote_button_is_released () while working on the USB remote code to see how long it could be held before I needed to have it timeout.  Can't remember how long I was able to hold it but seem to recall there was a limit after which the camera just reset?   Easy enough to test that out.  However,  I do recall the hook is far enough down the shooting process that the LCD blanks while waiting - I assume that would be bad for MD detection?

Maybe a new hook a little farther back?


 
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Motion Detection - time for a second look ?
« Reply #51 on: 08 / February / 2013, 21:23:46 »
Updated patch and test script.

Same as before, enable the AF test mode in the build and do a full recompile. Make sure to copy the updated modules to the SD card.

This adds a new test mode that uses the AF led to try and help measure the time from the motion detection to the actual image capture.

To use this, first run the MD_Tune.bas script (with the AF test code compiled in) and set the 'Shoot enabled?' parameter to off. This will use the AF led to try and trigger MD detect 1second after it is enabled - this will display the last/min/max/avg detection times at the top of the screen. If the live viewport code is correct these values will be reasonably consistent and (hopefully) around 50ms or less.

Once the MD is triggering consistently on the AF led then turn on the 'Shoot enabled?' parameter.
This will now flash the AF led after the shutter is pressed - the 'AF on delay' determines how long after the shutter press to turn it on, and the 'AF on time' controls how long it is on.

Enable image review in the camera at about 3 - 5 seconds so you can see each image.

Run the script and see if the AF flash is captured. Adjust the 'AF on delay' and 'AF on time' to measure when the image is being captured after the MD detect. If you see the AF light in the image then you know the image capture was between 'AF on delay' and 'AF on delay + AF on time' milliseconds after the MD triggered.

On my G1X 'AF on time' of 1 (10ms) does not work so 20ms (value = 2) may be the lowest you can reliably capture the AF led in the image.

It helps to have a dark background in the image so the AF led is easily 'seen' by the camera for triggering (and review). Also make sure the shutter speed is not too slow - it should probably be < 1/100th second.

The MD_Tune.bas script is in the Scripts/Test folder.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Motion Detection - time for a second look ?
« Reply #52 on: 09 / February / 2013, 00:24:36 »
Updated patch and test script.
Late here in the Excited States of Merica.   Much as I hate to say I"m not going to try this now  .... I'll have fun playing with this tomorrow.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 4451
Re: Motion Detection - time for a second look ?
« Reply #53 on: 10 / February / 2013, 14:00:18 »
Some comments on the liveview framebuffers and MD:

On the Ixus110 I get frame order issues when the scene is dark enough for the camera to lower its live view frame rate. I think I'm using the correct addresses. Anyone with similar experience? I just use chdkptp's live view to judge.
This issue might be related, although I don't know the lighting conditions.

Although the "fastest" buffer is good for MD, it might not be that good for PTP live view streaming. I don't have proof (chdkptp's live view display seems not to be synch'd to my monitor refresh rate), but it feels like I get more tearing with the fastest buffer. Same experience earlier when I dumped the liveview buffer content to file on the A420.
How about having separate functions for different kinds of use?

Lightning detection (in dark) seems tricky on cameras without manual mode, the only mode that seems usable is the "fireworks" scene mode - it keeps the refresh rate of live view high. However, several exposition parameters may need an override for this to be usable.

@philmoz
I haven't yet tried your latest AF-LED MD patch, but the earlier one is really useful.

Re: Motion Detection - time for a second look ?
« Reply #54 on: 10 / February / 2013, 15:26:52 »
Run the script and see if the AF flash is captured. Adjust the 'AF on delay' and 'AF on time' to measure when the image is being captured after the MD detect. If you see the AF light in the image then you know the image capture was between 'AF on delay' and 'AF on delay + AF on time' milliseconds after the MD triggered.

On my G1X 'AF on time' of 1 (10ms) does not work so 20ms (value = 2) may be the lowest you can reliably capture the AF led in the image.

It helps to have a dark background in the image so the AF led is easily 'seen' by the camera for triggering (and review). Also make sure the shutter speed is not too slow - it should probably be < 1/100th second.
Finally got back to this - sorry for the delay.

With my A1200, I set Tv=0.01seconds and ISO to 4000.   Using an iterative approach, the lowest usable value I can get for AF on delay (x10ms) is 3  and AF on time (x10ms) is 5.  Going any lower than that means the AF image does not appear in the picture.

But what does this tell me?  Do I add the 30mSec to the 50 mSec I get with shooting turned off for an average response time of 80mSec ?



Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Motion Detection - time for a second look ?
« Reply #55 on: 10 / February / 2013, 16:45:00 »
Run the script and see if the AF flash is captured. Adjust the 'AF on delay' and 'AF on time' to measure when the image is being captured after the MD detect. If you see the AF light in the image then you know the image capture was between 'AF on delay' and 'AF on delay + AF on time' milliseconds after the MD triggered.

On my G1X 'AF on time' of 1 (10ms) does not work so 20ms (value = 2) may be the lowest you can reliably capture the AF led in the image.

It helps to have a dark background in the image so the AF led is easily 'seen' by the camera for triggering (and review). Also make sure the shutter speed is not too slow - it should probably be < 1/100th second.
Finally got back to this - sorry for the delay.

With my A1200, I set Tv=0.01seconds and ISO to 4000.   Using an iterative approach, the lowest usable value I can get for AF on delay (x10ms) is 3  and AF on time (x10ms) is 5.  Going any lower than that means the AF image does not appear in the picture.

But what does this tell me?  Do I add the 30mSec to the 50 mSec I get with shooting turned off for an average response time of 80mSec ?


Assuming my code is working this would mean the shutter is opening for 10ms somewhere between 30ms and 80ms after the MD code triggers. Adding the 50ms motion detect time means you are capturing the image between 80 and 130ms after the actual change occurs in the scene.

That seems like a large window and I would have thought the 'AF on time' value could be smaller.

One thing to try would be use a long shutter speed (e.g. 1/3 sec) in a dark room, set 'AF on delay' to 15 (150ms) so you know the shutter will be open, and then play with the 'AF on time' value to see what the shortest duration is for turning on the LED that is still captured.

You can then go back to a fast shutter speed and play with the 'AF on delay' value to try and narrow down the capture time window. You can use a faster shutter speed than 0.01 seconds - it doesn't matter if the rest of the image is underexposed, the AF led should be bright enough to show.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Motion Detection - time for a second look ?
« Reply #56 on: 10 / February / 2013, 17:25:34 »
One thing to try would be use a long shutter speed (e.g. 1/3 sec) in a dark room, set 'AF on delay' to 15 (150ms) so you know the shutter will be open, and then play with the 'AF on time' value to see what the shortest duration is for turning on the LED that is still captured.
Tried that - was able to get the 'AF on time' value down to 1.

Quote
You can then go back to a fast shutter speed and play with the 'AF on delay' value to try and narrow down the capture time window. You can use a faster shutter speed than 0.01 seconds - it doesn't matter if the rest of the image is underexposed, the AF led should be bright enough to show.
Looks like I wasn't patient enough with my previous test.  I now capture the AF flash with "AF on delay" set to either 10 or 11 (only) and the "AF on time" set at 1.

Meaning my fastest capture time will be about 150mSec for the A1200 ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Motion Detection - time for a second look ?
« Reply #57 on: 10 / February / 2013, 21:18:26 »
One thing to try would be use a long shutter speed (e.g. 1/3 sec) in a dark room, set 'AF on delay' to 15 (150ms) so you know the shutter will be open, and then play with the 'AF on time' value to see what the shortest duration is for turning on the LED that is still captured.
Tried that - was able to get the 'AF on time' value down to 1.

Quote
You can then go back to a fast shutter speed and play with the 'AF on delay' value to try and narrow down the capture time window. You can use a faster shutter speed than 0.01 seconds - it doesn't matter if the rest of the image is underexposed, the AF led should be bright enough to show.
Looks like I wasn't patient enough with my previous test.  I now capture the AF flash with "AF on delay" set to either 10 or 11 (only) and the "AF on time" set at 1.

Meaning my fastest capture time will be about 150mSec for the A1200 ?


Sounds about right - it's consistent with my G12.

The test script uses fudgeys method of half pressing the shutter before calling the MD call in the script and then doing the full shutter press as soon as the motion is detected in the C code. Unless there's a way of reducing the lag between the full shutter press and the image capture that's probably as good as it can get.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline reyalp

  • ******
  • 14126
Re: Motion Detection - time for a second look ?
« Reply #58 on: 10 / February / 2013, 23:46:08 »
Thanks for implementing this Phil :)

a540, no shoot, values range from 10-50 avg 27 over 100 tests.

With "AF on delay" = 7, "AF on time" = 1, the AF seems to be captured pretty reliably, but was very faint once. "on delay" = 6  was reliably not captured.

Other settings left at defaults,  shutter=1/100th

I noticed the code is using camera_set_led. On some cameras, this uses firmware LED drive functions, which may have additional latency or unpredictability compared to just poking the MMIO. I believe canon LED control goes through the LEDDrive task, so there might be context switches etc involved. On a540, set_led pokes the MMIOs.

edit:
D10 (which does _LEDDrive)
no shoot 20-60, avg 43

with shoot seems to be quite variable, delay 5 / on 1 is never captured, 6/1 rarely, 7/1 pretty regularly, but 6/4 isn't totally consistent.
« Last Edit: 11 / February / 2013, 00:32:43 by reyalp »
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Motion Detection - time for a second look ?
« Reply #59 on: 11 / February / 2013, 00:14:54 »
I noticed the code is using camera_set_led. On some cameras, this uses firmware LED drive functions, which may have additional latency or unpredictability compared to just poking the MMIO. I believe canon LED control goes through the LEDDrive task, so there might be context switches etc involved. On a540, set_led pokes the MMIOs.

I used camera_set_led since that's what's called from ubasic and Lua, and seemed to have the highest chance of working across all cameras. It did occur to me there might be delays using the firmware functions rather than going direct; but I didn't think they would be significant.

Figuring out the IO address of the AF led seems a lot harder; but if there's a simple way to turn it on and off directly then it would be easy to do timing tests and see if there's any noticeable difference.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal