Luminance triggered full-res silent pictures

Started by dmilligan, August 02, 2014, 10:36:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dmilligan

Building upon the full-res silent pictures capability recently discovered by a1ex, I've made a luminance triggered mode. It works by continuously taking full-res silent pics and then saving one when a change in scene luminance above a certain threshold is detected. My primary motivation is capturing lightning, but there are other applications (such as more generic motion trigger, or a trap focus mode could also be implemented). I could use some help testing this code, a lot of getting this to work is going to be finding settings and thresholds that work the best.

Code here:
https://bitbucket.org/hudson/magic-lantern/pull-request/570/luminance-triggered-fullres-silent-pics

Enable the trigger in the silent pictures menu and then go to LV and press half shutter. A sort of slow, B&W live view from full-res silent picture data will be displayed. Each time a change in luminance above a certain threshold is detected, the image that was just captured will be saved to the card. Press half shutter again to stop.

I'm not going to post any builds, this is code that I would consider quite unstable. If you're going to test this, you need to know what you're doing, at least for now

Here it is running on 1100D:


I imagine that this will work pretty well at night or in dark scenes where you can have longer exposures and greater change in luminance from the lightning, but during the day it may have more trouble triggering, and the shorter your exposures, the greater the chance of missing a bolt.

It's probably a good idea to turn global draw off (unless you want preview, then you need it on, but you should turn all the individual overlays off).

If somebody has some 60p footage of a lightning strike it could be helpful for testing. Feel free to PM me.

Please note the limitations of full-res silent picture mode:
Quote from: a1ex on July 01, 2014, 05:11:15 PM
Limitations

- The fastest shutter speed I've got is around 1/10 seconds (very rough estimation by comparing brightness from a regular picture). With regular pictures, faster speeds are done via mechanical shutter actuation.
- Long exposures are fine up to 15 seconds (longer exposures will crash the camera).
- Fastest capture speed: 220ms on 5D3, 320ms on 5D2. This includes a dummy readout, which is probably a bias frame.
- So, at least for now, the usefulness is limited to timelapse and medium-long exposures (no moving subjects).
- If you use the intervalometer, I recommend taking a picture every 10 or 15 seconds (not faster). Saving DNGs from the camera is slow.
- In photo mode, aperture will be most likely wide open, regardless of the setting, because of exposure simulation (enable Expo Override to fix it).

dubarry

Nice feature addition dmilligan.  I could see this getting a lot of use. I and many others I'm sure will be looking forward to this.

mk11174

With my 2 years of experience using the current bolt trigger gg3g0 created, I am pretty confident it will do just fine in the day sky after seeing how it was reading with the stormy sky, the default settings worked well too. Just need to get a bolt to strike in front of the darn clouds, bad luck today, maybe another cell later.

My only concern is the full view of the detection process, since you have to keep it sensitive in the day, it picks up on white birds and brighter cars on the road, that is the one cool thing about the bolt_rec module since it only scanned 1 pixel across the screen, when a bolts struck, it broke through the line and saved, that was perfect, just a shame this won't work with this full res version. I tried, but would not update the reading while full res was capturing, but maybe I just did it wrong, not sure?

But so far so good, I wouldn't change a thing yet, add yes, but your current set up looks fine and detects a single camera flash and saves it just fine, so will do good if it sees the bolt for sure.

But for day you def need an ND8 filter and try to use a shutter slower then 1/4, but will be hard unless storm is a nice dark gray one, anything brighter anyway, the bolts don't even look good to the naked eye anyway so it don't matter.
500D/T1i  550D/T2i  600D/T3i  700D/T5i

mk11174

Quote from: dmilligan on August 02, 2014, 10:36:38 PM
If somebody has some 60p footage of a lightning strike it could be helpful for testing. Feel free to PM me.
This is one I used while testing this and bolt_rec back then, it hgelped give an idea on what it would do, its dv interlaced though, but still does the job, its full dv format, not compressed to something else and was shot with sony vx2000 back then. I now have much better video camera, but past 2 years most of my stuff has been with ML and bolt_raw.
http://www.mediafire.com/watch/50oql9o987qqair/VideoByTerry_Cropped_Fix.avi

It pauses at the end after the bolt so the trigger does not freak out and has a chance to settle after the bolt.
500D/T1i  550D/T2i  600D/T3i  700D/T5i

mk11174

Well, not the best storm, but it was enough to test for night, default settings worked fine, when these bolts struck, the delta jumped to 120 to 200, and it stayed at 0 till a flicker came and it jumped to 5 to 10 then back to 0 till the big flashes with a bolt. I set for a 3 second shutter because it was mostly crawlers out there and these far away cgs which I got plenty of those junky shots tonight. But the trigger was fine for night and was using preview, it did just great, saved allot of empty shots  I normal come away with when doing 10 to 15 second exposures, can't go much longer around here with the light pollution. I really need a day storm though to really test it out!


500D/T1i  550D/T2i  600D/T3i  700D/T5i

dmilligan


milank

during the large daytime storm event today, I played around the newest silent module build. Despite trying both default and some other settings, no success. Frequent false positive triggers causing file saving in sequence kept the functionality out of business. After shutdown/module reloading, I usualy experienced the same. Only uniform skies sometimes resulted in expected evaluation loop but the false positive trigger started soon again. Tried both M and Av mode, with and w/o exposure override. I personally doubth the current algorithm can deal with structured sky luminance, and even adapt the threshold after daytime sky changes. But I might be wrong.

mk11174

Yeah same here, but I had trees and cars causing saves, if was hard to get a stable detection going,  only when sky was a solid gray and was in an open area with no cars and trees was it stable until a flash.  Which is where that single pixel line on bolt rec was perfect for.  But maybe with more adjusting, maybe it would work.  I am sure it will get a bolt,  just so many issues with sky changing levels.  In the end I resorted to an external trigger with the full res code, but no more bolts at that time,  was a bad luck day.
500D/T1i  550D/T2i  600D/T3i  700D/T5i

milank

I should have mentioned - no B/W preview shown after halfshutter is pressed. Only the overlay showing delta etc on the black background. I can see the same function is used for e.g. playing the MLV RAW video. There, it does not go to from color to B/W, it stops playing the video only. Is this a bug with 60D? Or I miss something essential.

dmilligan

check the settings, there's an option to have no preview at all

milank

yes, this has been my 1st choice, no impact on preview.

mk11174

Quote from: milank on August 05, 2014, 11:52:35 AM
I should have mentioned - no B/W preview shown after halfshutter is pressed. Only the overlay showing delta etc on the black background. I can see the same function is used for e.g. playing the MLV RAW video. There, it does not go to from color to B/W, it stops playing the video only. Is this a bug with 60D? Or I miss something essential.
Do you have global draw off, make sure it is on in ml menu, at least have to have it on for Quick Review so it can show the preview when you turn it on in the trigger.
500D/T1i  550D/T2i  600D/T3i  700D/T5i

milank

Finally some success, only Quick review helped. However, preview is heavily overexposed, shutter and apperture seems to have no effect on that in all modes. Current stays at 13583, delta=0. Still daylight here now, will update when I get night sky whether I get some other values too.

dmilligan

Quote from: a1ex on July 01, 2014, 05:11:15 PM
Limitations

- The fastest shutter speed I've got is around 1/10 seconds (very rough estimation by comparing brightness from a regular picture). With regular pictures, faster speeds are done via mechanical shutter actuation.
- Long exposures are fine up to 15 seconds (longer exposures will crash the camera).
- Fastest capture speed: 220ms on 5D3, 320ms on 5D2. This includes a dummy readout, which is probably a bias frame.
- So, at least for now, the usefulness is limited to timelapse and medium-long exposures (no moving subjects).
- If you use the intervalometer, I recommend taking a picture every 10 or 15 seconds (not faster). Saving DNGs from the camera is slow.
- In photo mode, aperture will be most likely wide open, regardless of the setting, because of exposure simulation (enable Expo Override to fix it).

mk11174

I was fooling around with the bolt_rec detection code cause I really think it is a must for your trigger with only getting detection from a single pixel line across the screen. And found if you do it like this, it actually works!

Maybe you can do something with it?

    TASK_LOOP
    {
        /* capture a raw image */
        struct JobClass * job = (void*) call("FA_CreateTestImage");
        call("FA_CaptureTestImage", job);

        if(boltfull_luminance_trigger_halt)
        {
            call("FA_DeleteTestImage", job);
            break;
        }
           
        /* preview the raw image */
        raw_set_dirty();
        if (raw_update_params())
        {
            if(preview_on)
            {
               raw_preview_fast();
               //raw_preview_fast_ex((void*)-1, (void*)-1, -1, -1, RAW_PREVIEW_GRAY_ULTRA_FAST);
            }

            int bolt_raw_y_step = raw_info.height / 2;

            int bolt_raw_x_start = raw_info.active_area.x1;

            int bolt_raw_x_end = raw_info.active_area.x2;

            int peak = 0;


            for(int scanLine = 0; scanLine < 1; scanLine++)

            {

                for(int pos = 0; pos < (bolt_raw_x_end-bolt_raw_x_start); pos++)

                {
                    short value = raw_get_pixel_ex((void*)raw_info.buffer, bolt_raw_x_start + pos, (scanLine + 1) * bolt_raw_y_step);

                    peak = MAX(value, peak);

                }

            }

            bmp_printf(FONT_MED, 0, 200, "Peak %d", peak);

            if(peak > 5000)
            {
               /* prepare to save the file */
               struct raw_info local_raw_info = raw_info;
               boltfull_save_file(&local_raw_info, 0);
               bmp_printf(FONT_LARGE, 0, 60, "Saved %d x %d.   ", local_raw_info.jpeg.width, local_raw_info.jpeg.height);

               /*
               * This deallocates the job object (DeleteSkeltonJob),
               * and after the last job is deallocated, it gets out of factory mode
               * (SRM_ChangeMemoryManagementForImage)
               */
               call("FA_DeleteTestImage", job);
               continue;
            }
        }
500D/T1i  550D/T2i  600D/T3i  700D/T5i

maxchen

How to use the module ?
I compile the module from source and use it with the latest nightly build.After load the module and set it to fullres and trigger, go to lv mode and press half shutter.All I got is only a black screen, nothing more.I use a 5D2 and the side lcd will say the camera is busy.

dmilligan

Quote from: maxchen on August 06, 2014, 03:25:38 AM
I compile the module from source and use it with the latest nightly build
You need to compile and use the entire build, there are a lot of changes to the raw backend in that branch. It won't be usable with nightly builds until the branch is merged.

maxchen

Quote from: dmilligan on August 06, 2014, 03:42:08 AM
You need to compile and use the entire build, there are a lot of changes to the raw backend in that branch. It won't be usable with nightly builds until the branch is merged.

Thank you. I will try it later.

milank

Quote from: dmilligan on August 05, 2014, 08:11:01 PM
LIMITATIONS
yes, I am aware of this, realizing this is not EOS LV, but fullres silent raw preview. While instantly using ND8 and exposure override, I obviously have no other possibilities how to avoid overexposure during daytime.

maxchen

Quote from: dmilligan on August 06, 2014, 03:42:08 AM
You need to compile and use the entire build, there are a lot of changes to the raw backend in that branch. It won't be usable with nightly builds until the branch is merged.

Still have problem.

I do all this with the following step:
1. hg clone -b fullres-silent-pics https://bitbucket.org/dmilligan/magic-lantern
2. compile autoexec.bin for 5D2, copy autoexec.bin to root of cf card and copy 5D2_212.sym to ML/MODULES
3. compile modules and copy silent.mo, raw_rec.mo, mlv_rec.mo, pic_view.mo to ML/MODULES
4.turn on camera and load all module and reboot
5.set camera to M mode and shutter to 1 sec
6.set silent pic to fullres and turn triger on
7.turn lv on and press half shutter
still a black screen , nothing more. press shutter will say busy, turn off lv and on again, still black screen , I have to reboot the camera
If if set shutter to > 15s, it will say expo is too long

dmilligan

are you able to take a regular full-res silent picture?

maxchen

Quote from: dmilligan on August 06, 2014, 12:58:29 PM
are you able to take a regular full-res silent picture?

fullres --> no
simple --> yes

milank

Quote from: maxchen on August 06, 2014, 01:19:04 PM
fullres --> no
simple --> yes
Also make sure the picture Quality in Canon menu is set to RAW

dmilligan


maxchen

picture quality is RAW and iso is 100
some time I got "raw error" on the screen but no black screen