Which MD scripts are the best for lightning? - page 2 - Script Writing - CHDK Forum

Which MD scripts are the best for lightning?

  • 26 Replies
  • 16004 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Which MD scripts are the best for lightning?
« Reply #10 on: 19 / August / 2008, 13:20:12 »
Advertisements
Sorry for being a newbie, but I don't know much at all about writing and tweaking scripts.  How might I go about "masking out the top and bottom?"  This is not an option on the in-camera scripting parameters.  All I can do is change the numbers of rows/columns and exclude rows (this does the exact same thing as changing the number of rows).  More specific instructions will be greatly appreciated :)

My script in http://chdk.setepontos.com/index.php/topic,471.msg17797.html#msg17797 certainly has masking parameters in the menu by default (unless you use a build with an obsolete ubasic that doesn't allow enough parameters and includes the documentation to help you use them.

*

Offline Anaglyphic

  • ***
  • 129
  • Anaglyphic lives!
Re: Which MD scripts are the best for lightning?
« Reply #11 on: 19 / August / 2008, 14:59:52 »
You don't have to edit the script, just yet anyway. As you get used to CHDK and the way the scripts you use operate, you'll start editing them, it's just the nature of the beast.

Hey, I don't want to sound like a jerk - but please RTFM. fudgey went to the trouble to type it up, and it answers everything you've asked. Quite useful.

I would add that you should also disable OSD, especially when you have lots of the Miscellaneous Values active. (Main Menu --> OSD Parameters --> Show OSD) The grid scan/redraw is noticeably faster with OSD disabled.

Quote
How might I go about "masking out the top and bottom?"  This is not an option on the in-camera scripting parameters.  All I can do is change the numbers of rows/columns and exclude rows (this does the exact same thing as changing the number of rows).  More specific instructions will be greatly appreciated

Yep, spot on. The less viewfinder data that has to be compared, the faster it can trigger. Regarding the masking... it has 3 settings, off, mask, and inverse mask. For instance, say you setup a grid to be 6 columns and 3 rows. You could then turn the masking to 1, and set both row top and row bottom to 1, leaving a single row, centered, 1/3rd the height of the camera view. (with a pixel skip of 4-6). Set the trigger delay to zero and compare interval to as low as it will go without putting your camera into endless firing loop. (try ~4ms). I know you went and read the documentation, and you know why setting compare interval to less than 10ms is both useful AND useless. But with respect to lightning photos, you want the viewfinder data to be sitting there waiting, when the md_detect_motion call returns.

I haven't done any benchmarking with respect to pixel skip vs grid ratios... that is, does a really coarse grid with a low pixel skip work faster or slower than a finer grid with a higher pixel skip? Just don't do anything that you know will result in really slow viewfinder data scanning. (eg. pixel skip 0 & a 32x28 grid) You'll have to experiment to figure out what works for your lightning situation; it's not a set-it-and-forget-it type of thing... and low pixel skip really chews up batteries and processing cycles, you wouldn't think it affects runtime but it clearly does.

Set threshold as low as possible without getting spurious triggering. I mean, it's a million volt flash. It's not that hard to detect. If there are car headlights or jet traffic or kids walking by talking on cell phones in your monitored zones, setting the threshold up a bit will stop them from triggering shots continuously. (another example to watch out for: water puddles reflecting light; as the rain hits the puddle, it changes the reflection, and as far as the script is concerned that's "new" light - even without a single lightning flash - and it'll trigger endlessly until the camera fills up or the batteries die.)

Again, everything you need is in fudgey's document... even discussion of daytime lightning parameters.

Aim somewhere between the ground and the clouds. Press the shutter. And don't let the camera get wet. (And dream of a CHDK-enabled lightning MD script capturing from a field tripod left out in the storm, inside an underwater housing.)
:)

On a side note, the S3 has some very noticeable chromatic aberration when zoomed all the way out and wide open, so if you can, zoom in a little and stop it down. But that shouldn't be a problem with lightning photography. Or just correct it in software.


Aug 14, 2008 at 7:40:36pm, Canon PowerShot SX100 IS, Manual, focus ?, IS off, daylight WB, 6mm, ISO 80, f/8.0, 1/5 sec.


(c) 2008 Anaglyphic. Some rights reserved. Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

I grabbed this one, along with about 50 others, last week. My lightning collection has about 200 excellent shots like this, and about 4000 total, where there's a bolt somewhere in the frame (just not so stunning image-wise as the rest) - just from the last 6 weeks!

(PS: Yes I know it's pixel sTEp not sKIp... it just makes more sense to me.)
Since we cannot know all that there is to be known about anything,
 we ought to know a little about everything.
-- Blaise Pascal

*

Offline nkri

  • *
  • 10
  • S3 IS
Re: Which MD scripts are the best for lightning?
« Reply #12 on: 19 / August / 2008, 16:46:25 »
Ah, TFM (by the way, you're not a jerk at all for saying that...it's exactly what I needed  :)).  In my stupidity, I got Fudgey's script from the original post in his thread and didn't think to look at the new version (I guess this is why I didn't have the masking options).  His manual explained everything; thanks for all your help...good karma coming yours and Fudgey's way!

-nkri

PS: great lightning shot :)  Where is it?
« Last Edit: 19 / August / 2008, 16:55:43 by nkri »
95% of people listen to rap.  If you are part of the other 5% that listens to real music, put this in your signature!

*

Offline Anaglyphic

  • ***
  • 129
  • Anaglyphic lives!
Re: Which MD scripts are the best for lightning?
« Reply #13 on: 19 / August / 2008, 17:29:41 »
PS: great lightning shot :)  Where is it?

Living room window. It's midtown NYC, looking south... I used that specific image for an example to highlight how thresholding and masking works; notice the traffic lights and headlights all pointing at the lens, so a very low threshold would have made it trigger non-stop not just when lightning flashes, but if you want it to be really sensitive threshold for those far-off background or reflected bolts, you could mask out that region from being scanned.

BTW, notice that shutter speed? 1/5th?! Try catching a lightning bolt that way without CHDK!
Have fun, and welcome to the CHDK madness.  :D
Since we cannot know all that there is to be known about anything,
 we ought to know a little about everything.
-- Blaise Pascal


Which grid- / mask settings are best for lghtning MD
« Reply #14 on: 20 / August / 2008, 14:59:59 »
Hello,

I used MD_Test2.exe to do some reaction testing with Fudgey's script and my SX100IS.

  • default grid 6x4 no masc; 7 exposures, average reaction 117msec
  • default grid 6x4 masc for a single field; 7 exposures, average reaction 149msec
  • grid 1x1 no masc; 7 exposures, average reaction 103msec

It seems, that mascing doesn't shorten any reaction time, but rows and columns longer them.

Would be nice if anyone could add his experiences  :)

regards
dieter

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Which MD scripts are the best for lightning?
« Reply #15 on: 20 / August / 2008, 16:35:12 »
I did a couple of quick tests and looks like I can get away with a 6x4 grid with pixel step 0 (yes, zero) if I only use two cells and mask everything else out (could be even >2 cells, but I only tried "no mask" and "mask all but two cells").

This might be a good time to document one of the less known features in mx3's motion detector code...: :D

Instructions for checking MD measurement time:

MD scripts have a bunch of parameters to control how the LCD image is calculated. The current MD code cannot run fast enough on our cameras to check for each and every pixel for changes during the 10 ms keyboard poll interval (note that both Canon code and CHDK code do things other than the motion detector during this period, so it's not really 10 ms that we can waste in MD).

MD works fine even if you exceed the keyboard poll interval (Canon calls them ticks) -- at least if you don't exceed it TOO much (pixel step 0 without a mask will make things look very sluggish). But when optimizing for minimum response time, it's essential to make sure we poll the display each and every tick.

That's why we usually want to skip most LCD pixels and only monitor every Nth pixel (the pixel step parameter). Also, the number of cells (horizontal and vertical) can be specified by the user and a too high value may slow MD down. A mask will limit the number of pixels that are evaluated, use it if you know where the movement will be happening.

How can you tell you're using just one tick? Well, mx3 included some debug/benchmark features in MD we can use for this.

MD logs the first 2048 comparison calls. With 10 ms keyboard poll this should mean 20.48 seconds of data (btw this debug storage occupies 4096 words of RAM and most of it is not really necessary IMO).

This debug data can be dumped to a file MD_INFO.TXT in camera root directory by setting the MD_MAKE_DEBUG_LOG_FILE bit in the "parameters" argument, i.e. by adding 2 to the parameters argument. For the default MDFB fast mode this parameters argument is 9, change it to 11 by editing the script.

This file is not updated during MD. Instead, it's written (only) when md_detect_motion timeouts. So, set the MD timeout
parameter to a short value. With timeout of >=21 seconds you get all the data MD will log. But 10 seconds is more than enough to check for speed, so in MDFB, set Timeout to 1 (1 seconds).

Then start the script and make sure there is no motion in front of the camera. Wait for MD to timeout and stop the script by
pressing the shutter after the file has been writte. How to tell when MD timeouts, you ask...? Well, MD prints something about writing to a file on the console...just interrupt the script after the camera refocuses.

Then, read the file MD_INFO.TXT (using CHDK built-in text file reader or your computer). It has some information about CHDK and script settings in the beginning, and after that a long list with two numbers on each line. The first number is the index of the md comparison call (0 to at most 2047, or about 1000 if you used 10 second timeout) and beside it the CHDK get_tick_count value for this particular call. This value is the camera's time from startup in milliseconds. It will increase in 10 ms steps. So, if the value increases by 10 every line, you're doing great.

If it increases by more than 10 between any two lines, you are comparing too many pixels or cells and you are not achieving optimal reaction time.

Of course you should set compare interval is 10 ms or less for all of this, otherwise you're deliberately asking the MD to slow down. Note that this debug md info does not take compare interval into account. So even if you set a compare interval of 50 ms, the file will still list comparisons with 10 ms intervals. Someone could consider this a bug, but then again it's just a debug feature.

I believe moving this bit in motion_detector.c:
Code: [Select]
if(motion_detector.comp_calls_cnt < MD_REC_CALLS_CNT) {

  motion_detector.comp_calls[motion_detector.comp_calls_cnt]=tick;

}

motion_detector.comp_calls_cnt++;



down after this:
Code: [Select]
if(motion_detector.last_measure_time + motion_detector.measure_interval > tick){

  // wait for the next time

return 1;

}


Would fix it.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Which MD scripts are the best for lightning?
« Reply #16 on: 20 / August / 2008, 18:54:05 »
Ok well couldn't resist doing some benchmarking. I used an MDFB script in fast mode with md_detect_motion params argument modified to 11 and ran it on Juciphox 488. I had histogram and zebra enabled and didn't try disabling them because they aren't on display while scripts run so I figured disabling them would probably not help.

- As we knew, pixel step is what affects the speed the most.
- Using masks speeds things up as well, but judging from the monitored pixel counts, not as much as pixel step.
- Number of cols and rows doesn't seem to affect speed (again, I didn't notice any effect at a quick glance at the results, doesn't mean it isn't there). That this doesn't mean you should go all berserk with the number of cells now... a large pixel step combined with a large number of cells you results in lots of cells without a single active pixel (I think).
- I didn't notice any improvement from disabling CHDK OSD. (that doesn't mean it doesn't help, just that it isn't crucial).

Using the minimum pixel step (1 == measure all pixels), I got the optimal 10 ms effective compare interval when I reduced the screen using masks to 1/12 of display area. 1/8 wasn't small enough (these were 2 and 3 cells in the default 6x4 grid).

In this light (without digging deep into the MD code) it surprises me is that a pixel step of 4 (no masks) resulted in the optimal 10 ms compare interval. Doesn't that mean 1/4 of LCD area covered? Or even if it's only 1/5, this is much more than the area with no pixel stepping and masks (somewhere between 1/8 and 1/12).

I didn't perform any real life trigger speed tests, just the debug output analysis to check whether MD executes fully during one keyboard poll interval.

*

Offline vk2him

  • *
  • 22
  • Canon S5IS
Re: Which MD scripts are the best for lightning?
« Reply #17 on: 20 / August / 2008, 19:09:12 »
Well done Fudgey .. for sake of completeness for this thread and so others can find it easily, can you please post your script including the default parameters that give < reaction time?

It would also be interesting to compare my (slightly) modified script to yours
Cheers


Re: Which MD scripts are the best for lightning?
« Reply #18 on: 21 / August / 2008, 10:47:04 »
I grabbed this one, along with about 50 others, last week. My lightning collection has about 200 excellent shots like this, and about 4000 total ......
I see you are a great lightning hunter  :D

How many second shoots did you got with a single lightning?

Were they worth for shooting, or only the first were the best?

Dieter

 

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Which MD scripts are the best for lightning?
« Reply #19 on: 21 / August / 2008, 12:22:28 »
Well done Fudgey .. for sake of completeness for this thread and so others can find it easily, can you please post your script including the default parameters that give < reaction time?

It would also be interesting to compare my (slightly) modified script to yours

Well the actual version I used is no good for that purpose as other parts of it are very a570is specific. So just take the script that suits your model from http://chdk.setepontos.com/index.php/topic,471.msg17797.html#msg17797 and modify each md_detect_motion line params argument... that means changing each
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 9, h, e
to
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 11, h, e

and

    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 0, h, e
to
    md_detect_motion a, b, f, n, d, c, 1, t, i, j+1, l+1, a-k, b-m, 2, h, e

although just changing the first one suffices for fast mode still photo tests.

I used Timeout=1 or 2 and default settings otherwise (except for the trials with different masks, rows/cols and pixel step of course).


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal