Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: dmilligan on August 02, 2014, 10:36:38 PM

Title: Luminance triggered full-res silent pictures
Post by: dmilligan on August 02, 2014, 10:36:38 PM
Building upon the full-res silent pictures (http://www.magiclantern.fm/forum/index.php?topic=12523.0) 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:
(https://bitbucket.org/dmilligan/magic-lantern/downloads/1100D_fullres_trigger.png)

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).
Title: Re: Luminance triggered full-res silent pictures
Post by: dubarry on August 02, 2014, 11:38:07 PM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 03, 2014, 01:26:50 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 03, 2014, 02:02:35 AM
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 (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.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 03, 2014, 04:34:13 AM
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!
(http://s22.postimg.org/a8btbszgh/51230051.jpg)

(http://s1.postimg.org/elvbz925r/51230070.jpg)
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 03, 2014, 07:14:53 PM
awesome!
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 03, 2014, 11:13:02 PM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 04, 2014, 01:17:23 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: 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.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 05, 2014, 12:46:17 PM
check the settings, there's an option to have no preview at all
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 05, 2014, 01:15:42 PM
yes, this has been my 1st choice, no impact on preview.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 05, 2014, 04:24:12 PM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 05, 2014, 06:04:12 PM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 05, 2014, 08:11:01 PM
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).
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 06, 2014, 01:26:02 AM
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;
            }
        }
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 03:25:38 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 06, 2014, 03:42:08 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 03:49:36 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 06, 2014, 09:07:17 AM
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.
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 12:52:46 PM
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
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 06, 2014, 12:58:29 PM
are you able to take a regular full-res silent picture?
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 01:19:04 PM
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
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 06, 2014, 03:36:21 PM
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
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 06, 2014, 03:47:01 PM
also make sure you're not using auto ISO
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 03:54:22 PM
picture quality is RAW and iso is 100
some time I got "raw error" on the screen but no black screen
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 06, 2014, 05:06:11 PM
Try the full-res silent pictures branch from the main repo, if it doesn't work, then report it here: http://www.magiclantern.fm/forum/index.php?topic=12523.0

If it does work, perhaps I did a merge wrong and can look at it to reconcile any differences.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 06, 2014, 06:13:47 PM
Quote from: maxchen on August 06, 2014, 03:54:22 PM
picture quality is RAW and iso is 100
some time I got "raw error" on the screen but no black screen
Try this one and see if you get the same results. This one also has the tweaked code thats adds the bolt_rec scanline type detection, better for bolts because it doesn't calculate the whole view just a single pixel line that goes from left to right. I only gave it a max of 3 lines cause 3 is plenty, 1 will be in the middle, 2 and 3 will be evenly spread from top to bottom. For now, I only added the visible line for 1 line, but the detection is still there and working for 2 and 3, just can't visibly see the lines.

Also added off, color and grayscale option for preview.

Oh, and one reason another user got black screen was simply because global draw was off, so make sure global draw is on in ML.

https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/magiclantern-Nightly.2014Aug06.5D2212.zip (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/magiclantern-Nightly.2014Aug06.5D2212.zip)
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 06, 2014, 07:44:27 PM
Thank you dmilligan and mk11174
But the full-res silent pictures branch from the main repo and the one mk11174 provide did not work neither.
still got blash screen or "raw error" on lcd, global draw is already on.

maybe I should report to the fullres thread
Title: Re: Luminance triggered full-res silent pictures
Post by: a1ex on August 06, 2014, 07:52:47 PM
The zip from mk11174 works fine here.

I get "raw error" and blank screen only if picture quality is not RAW in Canon menu.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 07, 2014, 02:52:45 AM
By the way, anyone else that has a build compiled from fullres-silent-pics branch you can use this silent.mo https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo) module with the fullres luminance trigger made from dmilligans build just with the addons of the scanline type detection like in bolt_raw and bolt_rec live view bolt trigger. And I added the visibilty of all scanlines. You can choose to turn on and off the plot, the raw data and the preview as well.

No autoexposure feature like with bolt_raw because fullres works totally differ, but with dmilligans last_measurement idea, you really don't need to worry about keeping your exposure under a trigger line to keep from false detections, you just have to go back to live view when you think you need to tweak your exposure if the sky looks like it gets really lighter or darker.

For day stuff try to use 1 second exposure with ND8 filter of course, you will have more time processing the sky and not the code, if not, dont bother any faster then 1/10 because fullres does not really have any affect any faster.

At evening and night you can use 3 seconds for crawlers, just try to guess count how long a crawler will last and set your exposure for that, it will easily crab those, no reason for longer exposure because this auto saves when one happens.

If you only have cloud to ground, that 1 second is fine but you can easily go longer, just dont go longer than 15 seconds cause fullres wont work longer than that. But since it auto detects theres no reason to  set longer then a single strike.

I use Photo Mode, I set my quality to RAW of course, turn on live view, goto silent pictures module and select Full Res then go into the sub and turn on the Luminance trigger and adjust whatever settings I want, then back to Live view I just press half shutter to turn on the trigger and press again will turn it off.

I do notice 1 bug from the begining of the luminance trigger and any build I messed with myself, if you start and stop the code more then a few times, eventually it will stop running the code until you restart cam and then all works fine again. Thats is the only bug I noticed with this way of doing fullress pictures. Maybe the gui code bugs out eventually going back and forth this way, not sure, but you can run the code on and off a few times before a restart is needed so that is good.
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 07, 2014, 03:17:01 AM
Quote from: a1ex on August 06, 2014, 07:52:47 PM
The zip from mk11174 works fine here.

I get "raw error" and blank screen only if picture quality is not RAW in Canon menu.

I had double check the picture quality, is RAW.
And some time the ML crash.

ASSERT: GetMemoryAddressOfMemoryChunk( GetFirstMemChunk( pMem1AllocateListItem->hMemSuite ) ) == pMessage->pAddress
at SrmActionMemory.c:984, task RscMgr
lv:1 mode:3


Magic Lantern version : Nightly.2014Aug06.5D2212
Mercurial changeset   : 81a2fd653497+ (fullres-silent-pics) tip
Built on 2014-08-06 16:03:21 UTC by mathew@mathewubuntu64.
Free Memory  : 121K + 3936K
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 07, 2014, 06:05:30 AM
Interesting find! When I was using halfshutter press to turn trigger code on and off, to where it goes to preview mode then back to live view then back to preview, etc... at first cam start I only get like 5 times then it stays at live view and wont run code in preview mode again until a restart I once thought.

But for the heck of it, I just hit play instead of restart to see if it would go into review mode and it did, then the trigger code once again worked without a restart and I did it 20 times this time and still no stuck at live view state?

So maybe there is a fix for it so it never gets stuck at live view since loading normal preview once seems to fix it without a restart?????

Update: after doing a search in the forum I see gui_uilock(UILOCK_EVERYTHING); helped, so I moved that and gui_uilock(UILOCK_NONE); around and no issues yet, hopefully that solves that issue.

This luminance trigger is in a different order then the fullres silent code cause of the previewing part, but if I put gui_uilock(UILOCK_EVERYTHING); right after     prop_request_change_wait(PROP_GUI_STATE, &new_gui, 4, 1000); and gui_uilock(UILOCK_EVERYTHING); after call("FA_DeleteTestImage", job); inside the loop, all is fine so far. I guess pretty much just how the regular code is in fullres silent picture. Alex knows his stuff and clearly has reasons these fixes are there.
Title: Re: Luminance triggered full-res silent pictures
Post by: a1ex on August 07, 2014, 08:08:51 AM
@maxchen: can you enable debug info in raw.c? (define RAW_DEBUG there)

This will show exactly why you get "raw error". Remember to turn off the overlays, otherwise you'll get a flood of success messages from there :P
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 07, 2014, 02:36:56 PM
Updated silent.mo for fullres builds with dmilligans Positive, Negative, Both detection idea.
https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo)
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 07, 2014, 06:48:33 PM
Quote from: a1ex on August 07, 2014, 08:08:51 AM
@maxchen: can you enable debug info in raw.c? (define RAW_DEBUG there)

This will show exactly why you get "raw error". Remember to turn off the overlays, otherwise you'll get a flood of success messages from there :P

Is this one ? "LV raw disable"
And how to enable it ?
Title: Re: Luminance triggered full-res silent pictures
Post by: a1ex on August 07, 2014, 06:57:03 PM
Full-res silent pictures are stopping LiveView, so it shouldn't be that...

Have a video of the issue?
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 08, 2014, 02:22:51 AM
I added the scanline stuff from bolt_rec. Didn't really have time to test it much.


Quote from: mk11174 on August 07, 2014, 02:52:45 AM
I do notice 1 bug from the begining of the luminance trigger and any build I messed with myself, if you start and stop the code more then a few times, eventually it will stop running the code until you restart cam and then all works fine again. Thats is the only bug I noticed with this way of doing fullress pictures. Maybe the gui code bugs out eventually going back and forth this way, not sure, but you can run the code on and off a few times before a restart is needed so that is good.

For me it happens if you go back into the ML menu after running the luminance trigger. Doesn't work again until you reboot (just get a black screen). I will investigate when I get some more time.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 08, 2014, 03:35:58 AM
Quote from: dmilligan on August 08, 2014, 02:22:51 AM
For me it happens if you go back into the ML menu after running the luminance trigger. Doesn't work again until you reboot (just get a black screen). I will investigate when I get some more time.
It will work if you press play to go to canon review then half shutter back and it will work fine, but you have to at least have a cr2 on it to review.

And the bolt_rec code works in it good, I have it in the module I posted. All added to the source you started. Big thanks to you by the way!

I checked your commit, LOL, you code so more PRO then me, nice!!!! the way I added it works fine, but yours obviously looks all pro when looking at the source. Mine is always so basic, but it is doing the job, I will def test yours tonight see how it works too.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 08, 2014, 10:34:01 AM
Quote from: dmilligan on August 08, 2014, 02:22:51 AM
I added the scanline stuff from bolt_rec. Didn't really have time to test it much.
I like the idea of the color preview at capture. All works and all, but for the fullres version the Absolute method is really no good because we can't adjust exposure on the fly like in live view, it will take to many trips back and forth most likely causing raw error. This is why after I added the scanline I added back in your last measured method back in, that is a must for sure it gives you some room for exposure error too.

Next option to do for it is to add the visible lines like how I did if you test my module, you would probably write the code much cleaner then me. It is only needed to be able to move the position of the scanline when using 1 and while you move it from the menu its really important to use transparent menu so you can see where your moving it. As for 2 - 5, those can be more like the preset ones, no need to move them, but seeing where they are is vital just in case you have a hard sky to deal with in luminance range and 1 line falls on a dark base while the other falls on a bright grey sky. This is why I added custom position to it so I can aim the camera how it look best for the view and then moved my scanline to the middle of the sky under the dark base but above houses or trees.

Oh, and I used a double line, offset 1 pixel, a black one and a white one which looks like 1 line, but makes it look like the line changes from what to dark depending on the sky level, very hard to see a white line on a brighter gray sky.
Title: Re: Luminance triggered full-res silent pictures
Post by: maxchen on August 08, 2014, 02:37:36 PM
I finally make it work by clear all my camera setting.
compile the code from dmilligan's repository, and set scanline to 1 , turn off preview, my 5D2 only took 38-39 ms to process. Great !
Thank you all.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 08, 2014, 02:54:54 PM
Quote from: mk11174 on August 08, 2014, 10:34:01 AM
This is why after I added the scanline I added back in your last measured method back in, that is a must for sure it gives you some room for exposure error too.
The scanline stuff I added from bolt_rec actually keeps track of the last measured value for every pixel in the scanline and computes the deltas for each individual pixel. In bolt_rec it was just keeping track of |delta|, but I changed it to keep track of positive or negative, so the positive/negative/both setting also applies here (or at least it should, I haven't tested it).

Quote from: mk11174 on August 08, 2014, 10:34:01 AM
Next option to do for it is to add the visible lines like how I did if you test my module, you would probably write the code much cleaner then me. It is only needed to be able to move the position of the scanline...
Perhaps we can have it where you can simply move them with the arrow keys while running. Also should be possible to make the trigger threshold adjustable while running (this is all assuming we can detect button presses while running without any issues).
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 08, 2014, 04:19:23 PM
Quote from: dmilligan on August 08, 2014, 02:54:54 PM
The scanline stuff I added from bolt_rec actually keeps track of the last measured value for every pixel in the scanline and computes the deltas for each individual pixel. In bolt_rec it was just keeping track of |delta|, but I changed it to keep track of positive or negative, so the positive/negative/both setting also applies here (or at least it should, I haven't tested it).
Yes, the delta is working fine for Neg, Pos and Both, but the Absolute option is just like bolt trigger, and just uses a trigger amount. That was the only one I was referring to, the other 3 are fine, they works just as they do when scanlines are at 0 and it uses Histogram method.
Quote
Perhaps we can have it where you can simply move them with the arrow keys while running. Also should be possible to make the trigger threshold adjustable while running (this is all assuming we can detect button presses while running without any issues).
Now that would be really nice to move while using the code. But if you can use button codes, then using the arrows for adjusting the aperture would be most useful so you can adjust the aperture as storm gets brighter and darker without exiting code.

While using bolt_rec, I always found a trigger method of 5500 was perfect for every storm as long as your exposure was normal and not overexposed, so in bolt_raw, I coded it so the aperture would adjust only if raw data got close to the trigger amount to keep it under it which left it perfectly exposed as long as the trigger amount was at 5500. This has to be adjusted only if it goes above the amount for a couple seconds or else a bolt will also cause an aperture change.

But in this full res, since its a preview, I dont expect it will work, but would be a huge advantage not having to stop code to readjust and let the cam do all the work. The clouds change fast in many storms so adjusting the aperture allot was a big issue. This last measure idea you put in helps so you dont have to watch your camera like a hawk to keep it under a trigger line, but the aperture will still need to be adjusted so the bolts are not washed out with the sky or just in case you get a dark sky you can open the aperture to bring out those cool branches.

The scanline really only needs to be changed if you change your view, then you would normally be exiting code anyway. Seeing them while running is good option like I have them in bolt_raw, the custom version I put together of bolt_rec.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 09, 2014, 05:12:56 AM
Oh yeah you may want to move     bmp_printf(FONT_MED, 0, 35, "%s    ", image_file_name); so it don't show over the capture/process ms or have to choice to hide debug stuff like the capture ms, I'm sure you might already know that and are focusing on the working parts of it, but just in case, that is one tweak that others may prefer, cause all that data gets in the way. the important one I like are the delta info at top and under it when its done saving and the filename of course.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 11, 2014, 05:07:50 PM
Did another update for the luminance trigger in silent.mo module, found a solution for the freeze up that happens going in and out of the trigger, I added code to do the play sequence for you, it reviews and goes right back to code which keeps it running clean. Just make sure you have at least 1 still to review on camera. Fine solution for now, it goes fast enough you don't really notice it much.

Also added raw battery info so when your in the trigger and all your overlays go away, you can still keep track of your battery. For rebel users we only have 3 modes, 100, 30, and 5. 100 would be when the batter icon is white in ML, 30 is when it is yellow and 5 is when it is red. So alls you will see is Batt: 100  or Batt: 30 or Batt: 5  better than nothing cause I know it was bugging me not know while I was running the trigger waiting for lightning.

And added the visibility of all scanlines, not sure if that was in last update.

https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo)

Thanks again to dmilligan. This code is based off his original with just tweaks I felt were needed while using it in the field for lightning.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 11, 2014, 05:40:25 PM
Care to share you source? (the GPL actually obligates you to share it). I can incorporate it into the pull request, do any necessary cleanup.

Quote from: mk11174 on August 11, 2014, 05:07:50 PM
found a solution for the freeze up that happens going in and out of the trigger
I would call that a workaround, not a solution. We really need to figure out WHY it happens and prevent it in the first place (there could be more serious consequences or errors that we haven't seen yet).
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 11, 2014, 06:02:54 PM
Quote from: dmilligan on August 11, 2014, 05:40:25 PM
Care to share you source? (the GPL actually obligates you to share it). I can incorporate it into the pull request, do any necessary cleanup.
I would call that a workaround, not a solution. We really need to figure out WHY it happens and prevent it in the first place (there could be more serious consequences or errors that we haven't seen yet).
Yes, you are so right, I meant to say temp solution but forgot to add temp. But yes, def just a workaround for sure, always better to have a perfect fix.

And sure, I just am not great with committing stuff to the online repo yet so I work and share this manual way, LOL!

Here is the source, try not to laugh at my basic coding skills,  :-[

https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.zip (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.zip)
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 14, 2014, 03:09:14 PM
Trigger working good with the new ResumeLiveView patch and Set button add on!

One other feature might be useful that I added locally was the option to adjust threshold first while not saving to card, good for first time setup for your current view, this way you can get a good idea what you need to set it for before it goes crazy saving to card. For now, I have the option to save to card in the menu, but maybe with button features we can use a button to turn that on or off with a symbol showing its on or font print letting you know its on to save?

Also would be cool to toggle preview on and off, I see INFO can be used, but it only will turn preview on if its off, wont turn back off, it will change the value because if you press SET to leave trigger and come back to it, it will be off again.

I wound up using Q button to turn save on and off and added it to the print at top plus at lower screen Red font saying Recording and Yellow for Stand-By, works good!
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 14, 2014, 11:00:49 PM
Updated the silent.mo with dmilligans nice fix to the gui freeze up so we don't have to enter play mode and then come out of it. Also updated the plot revamped by him as well. And now you use the SET button to come out of the Luminance trigger, and to start it you still use the HALFSHUTTER_PRESS.

It is working great now!

I added the feature to press Q to toggle save to card, this way it will say Stand-By at first so you can set your threshold up before it starts saving, once your all setup, just press Q and it will save to card on detection.

To turn on plot, go into the trigger menu to toggle it on or off by choice, also the raw data can be toggled as well.

https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo (https://bitbucket.org/mk11174/magic-lantern-fullres/downloads/silent.mo)
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 15, 2014, 08:46:37 AM
@mk11174: looks great! I however noticed strange behaviour like working arrow buttons outside trigger code until restart. Also I am still missing how to run sticky HS along with full-res trigger code, would you mind sharing the code as suggested? Udating your repo would be fine.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 15, 2014, 10:23:58 AM
Quote from: milank on August 15, 2014, 08:46:37 AM
@mk11174: looks great! I however noticed strange behaviour like working arrow buttons outside trigger code until restart. Also I am still missing how to run sticky HS along with full-res trigger code, would you mind sharing the code as suggested? Udating your repo would be fine.
Can you explain more about the working arrow buttons outside the code? Up and Down Buttons should only control the scalines position while code is running and color or grayscale preview is on and Left and Right will control your threshold in all 3 preview modes. Are you saying the arrow buttons operate something else when you exit Full Res trigger, if so, explain so I can try to reproduce it.

There is no code for sticky HS with fullres trigger code, what are your uses for stick half shutter and the trigger, the full res trigger works all by itself?
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 15, 2014, 11:47:32 AM
The buttons - yes - it worked as you wrote, I also try to find the way how to reproduce it - so far it was random.
The sticky HS: is there a way to run the trigger for more than 30' ?
My primarily reason why I am interested in this is to understand the code and to be able to make my own modifications.
Thefore standalone binaries are not much exciting :)
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 15, 2014, 02:21:42 PM
Got a early morning bolt with Full res trigger, I could of shot regular CR2 images but I was only able to do 3 second exposures and sun was coming up  anyway so I figured just test out the trigger.

It did well detecting, I used it with preview and plot off, just showing Raw Data and threshold was good at 1000 to keep from getting just the cloud flashes detected.

It worked perfect, but the limitation of doing full res is the cut offs like in this image, it only happens every so often, it is just a timing issue, nothing to do with the trigger itself, just how the slowness of using fullres, sometimes the bolt just happens at that bad time while its scanning.

I tried exposures from 3 seconds to 1/10 seconds, and it was happening for every setting, but only randomly.

(http://www.mediafire.com/convkey/5510/lvynlxykksvl4ur7g.jpg) (http://www.mediafire.com/view/?lvynlxykksvl4ur)
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 15, 2014, 02:28:31 PM
Here is a day bolt I just got an hour ago with same same cut off issue. I went with a threshold of 500 seemed good, all worked fine, I was at a shutter of 0.5" on this one and aperture was F22 all the way closed with no ND8 filter, I was just about to put it on since my aperture was maxed out at this point.

Same deal, only Raw Data showing on screen, I only preview to set my scanline position then I turn preview off and just watch the raw data to keep an eye on my threshold.

Oh, the stop of that middle bolt was cut off because it was a triple bolter, 0.5" was not slow enough to capture all 3.

(https://www.mediafire.com/convkey/fe3a/carmtvft5k1v07f7g.jpg) (https://www.mediafire.com/view/?carmtvft5k1v07f)
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 15, 2014, 02:39:20 PM
nice bolts :) just ordered B&W ND64 filter for daytime fullres-silent shooting, can't wait :)
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 15, 2014, 09:12:12 PM
Interesting since the whole bolt is there and its just an exposure difference, the bolts can be fixed with a little work.

(https://www.mediafire.com/convkey/6f47/gp363ymogqs0fak7g.jpg) (https://www.mediafire.com/view/?gp363ymogqs0fak)
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 15, 2014, 09:14:55 PM
Quote from: milank on August 15, 2014, 11:47:32 AM
The sticky HS: is there a way to run the trigger for more than 30' ?
Not that I know of, as far as I know from alex it can only do 15 longest, that is just how it works I guess.
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 15, 2014, 11:54:11 PM
Just tested with bolt_raw module, there is a timer set at 30', after that time, the trigger exits and LV is restored.
A key press resets the timer (I used right and left buttons).
This could mean if we can periodically emulate the key press within the trigger task loop, we can go over 30' limit in the silent-trigger module too.

Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 16, 2014, 01:33:34 AM
Quote from: milank on August 15, 2014, 11:54:11 PM
Just tested with bolt_raw module, there is a timer set at 30', after that time, the trigger exits and LV is restored.
A key press resets the timer (I used right and left buttons).
This could mean if we can periodically emulate the key press within the trigger task loop, we can go over 30' limit in the silent-trigger module too.
So on your camera the bolt trigger shuts off to live view after 30 seconds??? If so, what camera are you using again? MAll of my rebel cams there is no limit, it just runs till I cancel it on both bolt_raw and full res.
Title: Re: Luminance triggered full-res silent pictures
Post by: dmilligan on August 16, 2014, 03:02:46 AM
' = minutes
" = seconds

Quote from: milank on August 15, 2014, 11:54:11 PM
A key press resets the timer (I used right and left buttons).
This could mean if we can periodically emulate the key press within the trigger task loop, we can go over 30' limit in the silent-trigger module too.
A physical keypress resets the timer, but a software emulated key press likely doesn't. This has been an ongoing issue for other areas (mainly raw recoding). The main problem is that it's just so hard to test. Trying something in code requires 30 mintues to find out if it actually worked. That's very impractical from a development standpoint.
Title: Re: Luminance triggered full-res silent pictures
Post by: mk11174 on August 16, 2014, 03:26:36 AM
Quote from: dmilligan on August 16, 2014, 03:02:46 AM
' = minutes
" = seconds
Ah, ok, I think I have heard of that issue awhile back, and yes, be a pain to test that one, lol.
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 17, 2014, 01:48:57 PM
Quote
A physical keypress resets the timer, but a software emulated key press likely doesn't.
Correct, confirmed.
Fot those who want to try, function
module_send_keypress(MODULE_KEY_PRESS_RIGHT);
has no effect on the timer. Would be interesting anyway to have the trigger rather in fully unassisted mode, especially for bolt shooting.
Title: Re: Luminance triggered full-res silent pictures
Post by: a1ex on August 19, 2014, 07:05:25 AM
Pressing and unpressing the shutter by software (call SW1) will reset the timer, but it might have side effects, like triggering autofocus or getting out of the current GUI mode.

I'm not sure if the following sequnence has any effect:

call("DisablePowerSave")
call("EnablePowerSave")


but Canon code calls it whenever it receives an event from the MPU (including button codes).

Current approach in silent pictures is to simply get back in LiveView (but for that, it should detect when LiveView is no longer open). If you stay in the QR mode, it's hard to tell when the mirror went up (I had an attempt to fix it for a timelapse, it appeared to work, but the mirror went up after a few hours, and remained undetected - definitely not funny to test).
Title: Re: Luminance triggered full-res silent pictures
Post by: milank on August 19, 2014, 12:11:17 PM
Just tried with both silent-fullres-triger and bolt_raw with negative result.
So there must be something in addition inside native Canon button press code, which does the keepalive.
The only case of breaking the 30' limit I am aware of, has been the FPS override (non raw) video recording. However, with the raw (MLV) video recording, the limit came back again, for some reason.