Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
4th May 2021, 17:33 | #21 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Making auto two pass thing is not so difficult, but will be added at the end.
I'm a bit busy doing other stuff, and slotting bits of this in between. Might be a day or two before I complete. EDIT: I'll continue until I'm happy with the tint.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
5th May 2021, 08:11 | #23 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Auto 2 Pass. [made simpler/bit faster, using YPlaneMax only, single script]
BLUELED_SingleInstance.avs Code:
# BLUELED_SingleInstance.avs ############ # Requires Avs+, RT_Stats, Grunt(), FrameSel, plugins. ############ FN = "MBGV0403.MXF" # Video FileName ##### Freq Changed Config ##### OP = 1 # 0,1,2,3 ONLY. ::: 0=Tweak Test Area, 1=Create Frames file, 2=Extract Frames, 3=Auto Two pass, pass1 then pass2. SHOW = True # True, shows metrics on OP==1 [False is quicker] # Less Often changed TEST_X = 374 # Test AREA COORDS (Best Even only) TEST_Y = 210 # Ditto TEST_W = 372 # Ditto TEST_H = 700 # Ditto BITS8 = True # (True) Metrics and DetTh are as 8 bit range [If change BITS8 then MUST also CHANGE DETTH, ie DETTH*4] DETTH = 50 # (50) Detection Threshold [ 50 is 8 bit thresh, for 10 bit use eg (50*4) ] YMAXTH = 0.4 # (0.4) YPlaneMax Threshold (100.0/256.0) about 0.4 % [Percentage of extreme (noise) pixels to ignore]. VFLIP = True # Vertical Flip if upside down REJECT = False # Arg to Pass 2 Extract Frames. [Extract BLUE LED frames instead of good frames if TRUE] ############ Assert(0 <= OP <= 3,"BlueLED: 1 <= OP <= 3") # Check Valid FN = FN.RT_GetFullPathName # Ensure full path if not already got one Frames = FN.RT_FilenameSplit(7) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" LWLibavVideoSource(FN) # Video Source ############ (VFLIP) ? FlipVertical : NOP SHOW = (OP==3) ? False : SHOW # Auto Switch OFF SHOW for pass 1 if two pass if(OP==0) { BlueLED_Tweak(TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,YMaxTh) } # Tweak Coords else if(OP==1) { BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,DetTh,YMaxTh,Show=SHOW) } # Detect else if(OP==2) { BlueLED_FrameSel(Frames,REJECT) } # Extract Frames else { # Auto 2 Pass BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,DetTh,YMaxTh,Show=SHOW).RT_ForceProcess() BlueLED_FrameSel(Frames,REJECT) } Return Last ############ # OP=0 Function BlueLED_Tweak(clip c,int x,int y,int w,int h,Bool "Bits8",Float "YMaxTh") { # Shows YPlaneMax(YMaxTh) of Test Area (x,y,w,h, marked in yellow) # If Bits8, then Test Area is converted to 8 bit Y8, and metrics shown in range 0->255 Bits8 = Default(Bits8,False) # If True, then metrics are for 8 bit YMaxTh = Default(YMaxTh,0.4) # YPlaneMax Threshold (%) tc = c.Crop(x,y,w,h) # Test Area tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc # 8 Bit if requested SSS=""" Subtitle(String(current_frame) + "] YMax=" + String(tc.YPlaneMax(threshold=YMaxTh)) , Size=48) """ c.ScriptClip(SSS, Args="tc,YMaxTh",Local = true) OverLay(c.BlankClip(Length=1,Width=w,Height=h,Color=$FFFF00),x=x,y=y,Opacity=0.1) # Mark Test Area in yellow Return Last } # OP=1 Function BlueLED_Detect(clip c,String Fn, int x,int y,int w,int h,Bool "Bits8",int "DetTh",Float "YMaxTh", Bool "Show") { bpc = c.BitsPerComponent() # Bit Depth of c clip Bits8 = Default(Bits8,False) # If True, then DetTh and metrics are for 8 bit DetTh = Default(DetTh,Bits8?50:50*BitLShift(1,bpc-8)) # Detect Threshold. Compliant with Bits8 arg. YMaxTh = Default(YMaxTh,0.4) # YPlaneMax Threshold (%) Show = Default(Show,False) Assert(fn!="","BlueLED_Detect: Fn Cannot be ''") Fn = Fn.RT_GetFullPathName RT_FileDelete(Fn) tc = c.Crop(x,y,w,h) tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc SSS=""" YMaxCur = tc.YPlaneMax(YMAXTH) # YMax for current frame YMaxPrv = tc.YPlaneMax(YMAXTH,offset=-1) # YMax for previous frame T = (YMaxCur < DetTh && (YMaxPrv >= DetTh || current_frame==0)) (T) ? RT_WriteFile(Fn,"%d # %d",current_frame,YMaxCur,Append=current_frame>0) : NOP if(Show) { s = RT_String("%d] %s\\nYMaxCur=%d\\nYMaxPrv=%d\\n(DetTh=%d)",current_frame,T?"Bingo":"",YMaxCur,YMaxPrv,DetTh) Subtitle(s,Size=48,lsp=0) } Return Last """ c.ScriptClip(SSS, Args="tc,DetTh,YMaxTh,Fn,Show",Local = true) Return Last } # OP=2 Function BlueLED_FrameSel(clip c,String Frames,Bool "Reject") { # Extract Frames from clip c Reject = Default(Reject,False) Assert(Frames!="","BlueLED_FrameSel: Frames Cannot be ''") Frames = Frames.RT_GetFullPathName # Add full path if not already got one Return FrameSel(c,Cmd=Frames,Ordered=True,reject=Reject) }
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th May 2021 at 01:36. Reason: Updated |
5th May 2021, 17:40 | #25 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
Oh yes,
-automatic bitdepth -detection zone always at the same place, relatively to the resolution. But this is just to be maniac. We can also very easily comment/uncomment prepared lines. The 403 sample file is 10 bit. Did you try the script while set on 8bit as it appears above? Seems to work too. Cheers, Edit: I'd like to share the LED system, present the capture setup and so on, if it might interest someone. But where? "Avs usage", as it wouldn't work without AVS or "hardware players"? A super8 projector is a hardware player isn't it? Last edited by chmars; 5th May 2021 at 17:54. Reason: forgot question |
5th May 2021, 18:19 | #26 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
I'm gonna go feed ducks now, but before I do,
If you would like to be able to group select a bunch of your video files and auto batch create scripts with names already inserted [using a template]. See here [Avisynthesizer_Mod]:- https://forum.doom9.org/showthread.php?t=166820 Install it, and run the "Install_SendTo.Cmd" command. Then, Config your working script as desired [probably auto mode], then on very top of script change to [ony the "#ASYNTHER" line required first, and ,also the FN = "___FILE___" required somewhere] Code:
#ASYNTHER BLUELED_MAGIC_STUFF # Requires Avs+, RT_Stats, Grunt(), FrameSel, plugins. ############ FN = "___FILE___" BLUELED_MAGIC_STUFF can be any valid name [no spaces, as for an avs variable name] As above, the BLUELED_MAGIC_STUFF name will be presented in a dialog box as a script selection option, where multiple script templates are in the template directory. [you get to pick which script template is wanted]
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 5th May 2021 at 18:27. |
6th May 2021, 22:07 | #27 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
Ok, thank you, instructions saved for later.
At the moment, too exited using your script which is the key to Fred's + variants (John's, MT...). Finally trying them after days of reading about them! AND: Your script confirmed the LED system is absolutely worth it: no frames loss, fast, no blended/duplicated frames, 100% frame accurate. This is huge. Thanks again. |
11th May 2021, 20:53 | #28 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
Changed from
Code:
Frames = FN.RT_FilenameSplit(14) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" Code:
Frames = FN.RT_FilenameSplit(15) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" Can't say how much I 'm happy with this script! |
11th May 2021, 21:37 | #29 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Oh Shit!, it should have been
Code:
Frames = FN.RT_FilenameSplit(7) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" Code:
RT_FilenameSplit(string filename,int "get"=15) Splits the un-named filename string into component parts selected by 'get' bit flags arg and returns the parts joined together. 'Get' (default 15, 1 -> 15), If set, Bit 0=DRIVE, 1=Dir, 2=Name, 4=Extension. Add 1 for Drive (bit 0), add 2 for Dir (bit 1), add 4 for Name (bit 2), add 8 for Extension (bit 3). Some combinations do not make sense, eg Drive + Extension (1+8=9). Below sensible options. 1 = Drive (includes trailing ':') 2 = Dir (includes trailing '\') 3 = Drive + Dir 4 = Name 6 = Dir + Name 7 = Drive + Dir + Name 8 = Extension (includes leading '.') 12 = Name + Extension 14 = Dir + Name + Extension 15 = Drive + Dir + Name + Extension Assuming a current working directory of eg "D:\avs\avi\", 'filename'="test.avi" and 'get'=15, returns "D:\avs\avi\test.avi", so given a relative filename and default 'get'=15, is equivalent to RT_GetFullPathName(filename). But 15 OK if you dont mind the ".MXF_Frames.txt"" part.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 11th May 2021 at 21:42. |
11th May 2021, 21:47 | #30 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
Nono, you're right, I read too fast.
Now using with AVSPLUS370_x64: I don't know if it is correct but I also added in the beginning: Code:
SetMemoryMax(6000) threads = 5 SetFilterMTMode("DEFAULT_MT_MODE", 2) Code:
Prefetch(threads) |
11th May 2021, 22:09 | #31 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
It probably dont matter a damn with that script, assuming that you're writing result to disk.
EDIT: Pass1, does little more than pull in frames from source (which needs to be sequential) filter, only samples YMax for each frame via Scriptclip. Pass2, does nothing but read frames flagged in frames file from the source filter. SetMemoryMax(6000), just reserves loads of RAM that will not be needed, and reduces RAM available to other processes. Suggest skip all of that pre-script and post-script. EDIT: OK, it also resizes and colorspace converts detect clip [which I forgot about] but maybe still not a great deal of difference, you could test and see if any advantage at all.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 11th May 2021 at 22:23. |
12th May 2021, 23:25 | #33 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
Made some tests to tax the LED system with StainleSSS script.
6 takes, same footage, same fstop, same focus, same everything except obturation speeds: from 1/100 to 1/6000. Shot at 50 fps while projected at 19.2fps 6 H-Stacked together to compare. Text in the middle to offer a stable reference when looking at the video frame by frame. Autolevels, autowhite (no satisfaction/better than nothing), slight sharpening. Low res screenshot: Video here The system works with all these speeds. At 1/50th of second, the led becomes to be present on too many pictures, of course, as shot at 50fps. Two interesting phenomena: .Disapointing: lot of gate-wave. The image is dancing more than I thought. -Sharpness difference not so big. IIRC, Johnmeyer said, he is shooting his footages at 1/1000, I thought slower speeds would be more unsharp because of vibrations or film instability. There is a difference however (frame 106). Concerning the gate-wave, there might be a vibration maybe introduced by the truncated blade disk. I saw the LED moving too on the full images, not only the film and the gate. There is a part of the disk left to trigger the speed calculation by the microcontroler into the projector. Disk is complicated to remove on this model but a must do. Last edited by chmars; 22nd May 2021 at 14:39. |
13th May 2021, 21:13 | #34 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Here is another version of the original DBase script, converted to act like the Auto 2 Pass script.
DB_BLUELED_SingleInstance.avs Code:
# DB_BLUELED_SingleInstance.avs /* Requires, AVS+, RT_Stats, Grunt(), FrameSel, CallCmd, plugins [CallCmd Optional, will auto delete DBase on clip closure if installed] Detects Blue LED's, selects mid frame of those frames between blue LEDs, when SEL2ND==True and frame count between Blue LEDs are even, then selects the later middle frame rather than default earlier middle frame. Writes only single middle frame between BLUE frames. Intent, with greater number of RAW I/P frames captured [greater than necessary], selects middle frame from all the good frames, so that more chance of selected frame being stationary [un-wobbly]. May need to adjust AREA Coords where BLUE expected DBase Single Instance Version. */ ############ FN = "MBGV0403.MXF" # Video FileName ##### Freq Changed Config ##### OP = 3 # 0,1,2,3 ONLY. ::: 0=Tweak Test Area, 1=Create Frames file, 2=Extract Frames, 3=Auto Two pass, OP=1 then OP=2. SHOW = True # True, shows metrics on OP==1 [False is quicker, Will auto switch OFF SHOW when OP==3] # Less Often changed TEST_X = 374 # Test AREA COORDS (Best Even only) TEST_Y = 210 # Ditto TEST_W = 372 # Ditto TEST_H = 700 # Ditto BITS8 = True # (True) Metrics and DetTh are as 8 bit range [If change BITS8 then MUST also CHANGE DETTH, ie DETTH*4] DETTH = 50 # (50) Detection Threshold [ 50 is 8 bit thresh, for 10 bit use eg (50*4) ] YMAXTH = 0.4 # (0.4) YPlaneMax Threshold (100.0/256.0) about 0.4 % [Percentage of extreme (noise) pixels to ignore]. VFLIP = True # Vertical Flip if upside down REJECT = False # Arg to Pass 2, Extract Frames. [Extract BLUE LED frames instead of good frames if TRUE] ### SEL2ND = False # When NonBlue count is EVEN, false selects earlier middle frame, True select later middle frame. ############ Assert(0 <= OP <= 3,"DB_BLUELED_SingleInstance: 1 <= OP <= 3") # Check Valid FN = FN.RT_GetFullPathName # Ensure full path if not already got one Frames = FN.RT_FilenameSplit(7) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" LWLibavVideoSource(FN) # Video Source ############ (VFLIP) ? FlipVertical : NOP SHOW = (OP==3) ? False : SHOW # Auto Switch OFF SHOW for pass 1 if two pass if(OP==0) { BlueLED_Tweak(TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,YMaxTh) } # Tweak Coords else if(OP==1) { DB_BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,DetTh,YMaxTh,SEL2ND,Show=SHOW) } # Detect else if(OP==2) { BlueLED_FrameSel(Frames,REJECT) } # Extract Frames else { # Auto 2 Pass DB_BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,DetTh,YMaxTh,SEL2ND,Show=SHOW).RT_ForceProcess() BlueLED_FrameSel(Frames,REJECT) } Return Last ############ # OP=0 Function BlueLED_Tweak(clip c,int x,int y,int w,int h,Bool "Bits8",Float "YMaxTh") { # Shows YPlaneMax(YMaxTh) of Test Area (x,y,w,h, marked in yellow) # If Bits8, then Test Area is converted to 8 bit Y8, and metrics shown in range 0->255 Bits8 = Default(Bits8,False) # If True, then metrics are for 8 bit YMaxTh = Default(YMaxTh,0.4) # YPlaneMax Threshold (%) tc = c.Crop(x,y,w,h) # Test Area tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc # 8 Bit if requested SSS=""" Subtitle(String(current_frame) + "] YMax=" + String(tc.YPlaneMax(threshold=YMaxTh)) , Size=48) """ c.ScriptClip(SSS, Args="tc,YMaxTh",Local = true) OverLay(c.BlankClip(Length=1,Width=w,Height=h,Color=$FFFF00),x=x,y=y,Opacity=0.1) # Mark Test Area in yellow Return Last } # OP=1 Function DB_BlueLED_Detect(clip c,String Fn, int x,int y,int w,int h,Bool "Bits8",int "DetTh",Float "YMaxTh",Bool "SEL2ND", Bool "Show") { # Fn = Frames file. bpc = c.BitsPerComponent() # Bit Depth of c clip Bits8 = Default(Bits8,False) # If True, then DetTh and metrics are for 8 bit DetTh = Default(DetTh,Bits8?50:50*BitLShift(1,bpc-8)) # Detect Threshold. Compliant with Bits8 arg. YMaxTh = Default(YMaxTh,0.4) # YPlaneMax Threshold (%) SEL2ND = Default(SEL2ND,False) Show = Default(Show,False) Assert(fn!="","DB_BlueLED_Detect: Fn Cannot be ''") Fn = Fn.RT_GetFullPathName fn.RT_FileDelete tc = c.Crop(x,y,w,h) tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc DB = FN.RT_FilenameSplit(7) + ".DB" # If eg FN="...\MBGV0403.MXF" then DB = "...\MBGV0403.DB" TypeStr = "iiiii" RT_DBaseAlloc(DB,c.FrameCount,TypeStr) HasCallCmd =RT_FunctionExist("CallCmd") ############ DBase Field Index's, Use Glbal Vars rather than numeric constants, easier during Development. Global STAT_FLD = 0 # 0=Unknown, 1=BLUE, 2=Non Blue Frame(Not chosen), 3=Non Blue chosen Frame. Global YMAX_FLD = 1 # YMax for current frame # Below, Valid only When STAT==2 OR STAT==3 (NOT BLUE_LED Stat==1) Global FRM_S_FLD = 2 # Ditto, 1st frame of current non BLUE sequence Global FRM_M_FLD = 3 # Ditto Chosen frame from current Non Blue sequence (writen to Frames file) Global FRM_E_FLD = 4 # Ditto Last frame of current non BLUE sequence SSS=""" n=current_frame Stat = RT_DBaseGetField(DB,n,STAT_FLD) if(Stat == 0) { # Unknown YMaxCurr = tc.YPlaneMax(YMAXTH) if(YMaxCurr >= DetTh) { # BLUE Stat=1 RT_DBaseSet(DB,n,Stat,YMaxCurr, -1,-1,-1) # set BLUE, + invalid fields } Else { # NOT BLUE RT_DBaseSetField(DB,n,YMAX_FLD,YMaxCurr) # set non-BLUE YMax [set only single field] Frame_S = n For(i=n-1,0,-1) { # Step Backwards looking for previous BLUE # i is Always either KNOWN BLUE or Unknown Stat = RT_DBaseGetField(DB,i,STAT_FLD) if(Stat == 0) { # Unknown current_frame = i # The Frame we will test for YMax YMaxI = tc.YPlaneMax(YMAXTH) if(YMaxI >= DetTh) { # Is BLUE RT_DBaseSet(DB,i,1,YMaxI, -1,-1,-1) # set BLUE, YMax, + invalid fields Frame_S = i + 1 # Start frame = BLUE + 1 i = 0 # Break } Else { # Non BLUE RT_DBaseSetField(DB,i,YMAX_FLD,YMaxI) # set non-BLUE YMax [set only single field] Frame_S = i } } else { # KNOWN BLUE Assert(Stat==1,"Internal Error #1 Stat="+String(Stat)) Frame_S = i + 1 # Start frame = BLUE + 1 i = 0 # Break } } Frame_E = n For(i=n+1,FrameCount-1) { # Step Forwards looking for next BLUE # i is Always either KNOWN BLUE or Unknown Stat = RT_DBaseGetField(DB,i,STAT_FLD) if(Stat == 0) { # Unknown current_frame = i # The Frame we will test for YMax YMaxI = tc.YPlaneMax(YMAXTH) if(YMaxI >= DetTh) { RT_DBaseSet(DB,i,1,YMaxI, -1,-1,-1) # set BLUE, YMax, + invalid fields Frame_E = i - 1 # End frame = BLUE - 1 i = FrameCount-1 # Break } Else { # Non BLUE RT_DBaseSetField(DB,i,YMAX_FLD,YMaxI) # set non-BLUE YMax [set only single field] Frame_E = i } } else { # KNOWN BLUE Assert(Stat==1,"Internal Error #2 Stat="+String(Stat)) Frame_E = i - 1 # End frame = BLUE - 1 i = FrameCount-1 # Break } } SelIx = (Frame_E - Frame_S) / 2 Frame_M = (SEL2ND) ? Frame_E-SelIx : Frame_S + SelIx # Earlier OR Later middle frame to pick for(i=Frame_S,Frame_E) { # Scan and set, all NON-BLUE sequence, using DB pre-written YMax YMaxI = RT_DBaseGetField(DB,i,YMAX_FLD) # Get pre-stored YMax for i frame Stat = (i==Frame_M)?3:2 # Chosen frame mid frame ? RT_DBaseSet(DB,i,Stat,YMaxI, Frame_S,Frame_M,Frame_E) # Set all data for frame i, in current NON-BLUE sequence. } current_frame = n # Restore current_frame Stat = (n==Frame_M)?3:2 # Status of current frame [Non Blue, 2=not chosen or 3=chosen] } } # End, if(Stat == 0) # Here, Stat=1=BLUE, =2=non-blue Frame - not chosen, =3=Chosen Frame if(Stat==1) { # BLUE if(SHOW) { YMax = RT_DBaseGetField(DB,n,YMAX_FLD) Subtitle(RT_String("%d] %d",n,YMax),Size=48) } } else if(Stat==3 || SHOW) { YMax = RT_DBaseGetField(DB,n,YMAX_FLD) Frame_S = RT_DBaseGetField(DB,n,FRM_S_FLD) Frame_E = RT_DBaseGetField(DB,n,FRM_E_FLD) if(Stat == 2) { # SHOW=true Subtitle(RT_String("%d] %d : S=%d : E=%d : Len=%d",n,YMax,Frame_S,Frame_E,Frame_E-Frame_S+1),Size=48,lsp=0) } else { # Stat=3, # Write To Frames File if(SEL2ND && n != Frame_S + ((Frame_E - Frame_S) / 2)) { RT_WriteFile(fn,"%d # %d : S=%d : E=%d : Len=%d # 2nd of middle pair",n,YMax,Frame_S,Frame_E,Frame_E-Frame_S+1,Append=n!=0) if(SHOW) { Subtitle(RT_String("%d] %d : S=%d : E=%d : Len=%d\\nWriting, 2nd of middle pair", \ n,YMax,Frame_S,Frame_E,Frame_E-Frame_S+1),Size=48,lsp=0) } } else { RT_WriteFile(fn,"%d # %d : S=%d : E=%d : Len=%d",n,YMax,Frame_S,Frame_E,Frame_E-Frame_S+1,Append=n!=0) if(SHOW) { Subtitle(RT_String("%d] %d : S=%d : E=%d : Len=%d\\nWriting", \ n,YMax,Frame_S,Frame_E,Frame_E-Frame_S+1),Size=48,lsp=0) } } } } Return Last """ c.ScriptClip(SSS, Args="tc,DetTh,YMaxTh,Fn,Show,DB,SEL2ND",Local = true) HasCallCmd?CallCmd(close=RT_String("""CMD /C chcp 1252 && del "%s" """,DB), hide=true, Synchronous=7):NOP # Auto Delete DBase if CallCmd available Return Last } # OP=2 Function BlueLED_FrameSel(clip c,String Frames,Bool "Reject") { # Extract Frames from clip c Reject = Default(Reject,False) Assert(Frames!="","BlueLED_FrameSel: Frames Cannot be ''") Frames = Frames.RT_GetFullPathName # Add full path if not already got one Return FrameSel(c,Cmd=Frames,Ordered=True,reject=Reject) } ie Quote:
Also, the SEL2ND arg (when true) shows that when 2 frames between BLUE LED frames, the earlier one is probably always the better one. [ie set SEL2ND=true, shows bluish tinge on some frames, where LED not fully extinguished, whereas SEL2ND=False, ALL GOOD Black LED section of frame.] EDIT: Fragment of Frames file, [Selected_Frame # In-Comments: YMax, then NonBLUE sequence info] Code:
0 # 32 : S=0 : E=0 : Len=1 2 # 32 : S=2 : E=3 : Len=2 5 # 32 : S=5 : E=6 : Len=2 8 # 32 : S=8 : E=8 : Len=1 11 # 32 : S=11 : E=11 : Len=1 13 # 32 : S=13 : E=14 : Len=2 16 # 32 : S=16 : E=17 : Len=2 19 # 32 : S=19 : E=19 : Len=1 22 # 31 : S=22 : E=22 : Len=1 24 # 31 : S=24 : E=25 : Len=2 27 # 31 : S=27 : E=28 : Len=2 30 # 31 : S=30 : E=30 : Len=1 32 # 32 : S=32 : E=33 : Len=2 35 # 32 : S=35 : E=36 : Len=2 38 # 32 : S=38 : E=39 : Len=2 41 # 32 : S=41 : E=41 : Len=1 44 # 31 : S=44 : E=44 : Len=1 46 # 31 : S=46 : E=47 : Len=2 49 # 31 : S=49 : E=49 : Len=1
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 13th May 2021 at 21:43. |
|
13th May 2021, 21:40 | #35 | Link |
Registered User
Join Date: Apr 2021
Posts: 128
|
I think you understood correctly how it works. (At least your script did perfectly )
The footage moves normally, as in any projector. Only the blades are removed (in exception of a small part of one). Excuse my question: What is the advantage of the DB version over the other one? |
13th May 2021, 21:51 | #36 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
If each frame exposed [ie BLUE LED NOT Lit up] for longer time, and so more nonBLUE frames between BLUE's, then pick middle of the
nonBLUE's, more chance of selected frame being still, maybe. Maybe could arrage it so that you got eg 4 or 5 NonBLUE frames between BLUE frames, it picks the middle nonBLUE. Where 4 NonBLUE [ie even number], SEL2ND=FALSE would pick 2nd frame, and TRUE would pick 3rd. If eg 5 [Odd number of] NonBLUE frames, then would pick the middle 3RD one. [SEL2ND ignored, only used where EVEN] EDIT: 4 or 5, are just numbers picked out of hat. EDIT: Number of consecutive BLUE's dont matter. Frames file fragment when SEL2ND=True [where YMAX > 32 then LED is a bit blueish] Code:
0 # 32 : S=0 : E=0 : Len=1 3 # 32 : S=2 : E=3 : Len=2 # 2nd of middle pair 6 # 46 : S=5 : E=6 : Len=2 # 2nd of middle pair ### A Bit Blu-ish 8 # 32 : S=8 : E=8 : Len=1 11 # 32 : S=11 : E=11 : Len=1 14 # 32 : S=13 : E=14 : Len=2 # 2nd of middle pair 17 # 37 : S=16 : E=17 : Len=2 # 2nd of middle pair ### A Bit Blu-ish 19 # 32 : S=19 : E=19 : Len=1 22 # 31 : S=22 : E=22 : Len=1 25 # 35 : S=24 : E=25 : Len=2 # 2nd of middle pair ### A Bit Blu-ish 28 # 38 : S=27 : E=28 : Len=2 # 2nd of middle pair ### A Bit Blu-ish 30 # 31 : S=30 : E=30 : Len=1 33 # 31 : S=32 : E=33 : Len=2 # 2nd of middle pair 36 # 32 : S=35 : E=36 : Len=2 # 2nd of middle pair 39 # 44 : S=38 : E=39 : Len=2 # 2nd of middle pair ### A Bit Blu-ish 41 # 32 : S=41 : E=41 : Len=1 44 # 31 : S=44 : E=44 : Len=1 47 # 31 : S=46 : E=47 : Len=2 # 2nd of middle pair 49 # 31 : S=49 : E=49 : Len=1 EDIT: Above and comparison with SEL2ND=False in earleir post shows that where there are 2 detected NonBLUE frames, the earlier one is the better choice. [SEL2ND=False] It also looks like anything above 32 is probably BLUE LED, although a bit of a margin is probably a good idea. (Based only on those first few frames)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 13th May 2021 at 22:41. |
13th May 2021, 22:32 | #37 | Link | |
Registered User
Join Date: Apr 2021
Posts: 128
|
I don't want you to loose your time. Perfect as it is!
Quote:
But time consuming if projecting slower. In this case, I'd more reconsider a solution like Fred's (frame by frame, machine vision cam) but would have to abandon my idea. First, I'll try to stabilize the projector better. But... about the DB/noDB versions of your script, what is the advantage of using a DB? EDIT: Oh, I see. The DB contains more precise informations to know what happens, debug or adjust better. Last edited by chmars; 13th May 2021 at 22:36. Reason: didn't see last edit |
|
13th May 2021, 22:53 | #38 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Quote:
You could use the DB ver$ if cap contraption changed, to see numbers, and if you still always want first NONBLUE frame after any BLUE frame, then use the other script.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
14th May 2021, 01:38 | #39 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Post #23, BLUELED_SingleInstance.avs [Non-DB] updated. Added YMax in comments to frames file.
Code:
0 # 32 2 # 32 5 # 32 8 # 32 11 # 32 13 # 32 16 # 32 19 # 32 22 # 31 24 # 31 27 # 31 30 # 31 32 # 32 35 # 32 38 # 32 41 # 32 44 # 31 46 # 31 49 # 31 LED is quicker at switching OFF, than it is at switching ON [LED brightness change speed]. (or maybe it just happens to be the timing of mechanical switching as implemented your LED cap contraption). Ie, the 1st nonBLUE YMAX is pretty consistant about 31 or 32, whereas when SEL2ND=True and nonBLUE length==2, 2nd nonBLUE is sometimes a bit Blue-ish, somewhat greater than 32 [46 on frame 6, and 44 on frame 39, in post #36]. EDIT: You can see the blue-ish stuff [DB VER$, OP=3], by setting SEL2ND=False and viewing[not blue-ish], then set SEL2ND=true, and view again[blue-ish].
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th May 2021 at 02:27. |
14th May 2021, 16:17 | #40 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,042
|
Mod non DB version, not so much for chmars BLUE_LED gizmo, but flexible detector for maybe some other cap contraption.
DB mod version will follow at some point. Code:
# BLUELED_SingleInstance_Mod.avs # https://forum.doom9.org/showthread.php?p=1942862#post1942862 ############ # Requires Avs+, RT_Stats, Grunt(), FrameSel, plugins. # Mod version: # Can use YMODE:= 0=YPlaneMin, 1=YPlaneMax, 2=YPlaneMinMaxDifference, 3=YPlaneMedian, 4=AverageLuma, detection modes on YPlane, result in YDet. # Also, DETMODE:= 0="YDet<DetTh", 1="YDet>DetTh", 2="YDet<=DetTh", 3="YDet>=DetTh", 4="YDet==DetTh", 5="YDet!=DetTh", detect logic comparitor. # Whether above mods are of any other use, depends upon how your cap contraption indicates "A Moving Frame", or a "Still Frame". # Where YMODE=1 [YPlaneMax], and DETMODE=0 [YDet < DetTh], is same as original script version. # (eg, where White LED flags Good frame rather than bad moving frame, then could use YMODE=0 [YPlaneMin] and DEETMODE=1 [YDet > DetTh]) # Intent, that the script can be of use with other cap contraption devices other than chmars BLUE_LED gizmo. ############ FN = "MBGV0403.MXF" # Video FileName ##### Freq Changed Config ##### OP = 0 # 0,1,2,3 ONLY. ::: 0=Tweak Test Area, 1=Create Frames file, 2=Extract Frames, 3=Auto Two pass, pass1 then pass2. SHOW = True # True, shows metrics on OP==1 [False is quicker] # Less Often changed TEST_X = 374 # Test AREA COORDS (Best Even only) TEST_Y = 210 # Ditto TEST_W = 372 # Ditto TEST_H = 700 # Ditto BITS8 = True # (True) Metrics and DetTh are as 8 bit range [If change BITS8 then MUST also CHANGE DETTH, ie DETTH*4] YMODE = 1 # (1) 0=YPlaneMin, 1=YPlaneMax, 2=YPlaneMinMaxDifference, 3=YPlaneMedian, 4=AverageLuma. # For BLUELED we use YMODE=1 ie YDet=YPlaneMax on Area TEXT_X,TEST_Y,TEST_W,TEST_H. # YTh only used for YPlaneMin, YPlaneMax, YPlaneMinMaxDifference, others dont have a threshold arg. YTH = 0.4 # (0.4) YPlaneMax Threshold (100.0/256.0) about 0.4 % [Percentage of extreme (noise) pixels to ignore]. DETMODE = 0 # (0) Comparison mode for Detect of BLACK(non BLueLED) frames. Is BlueLED where NOT BLACK. # 0="YDet<DetTh", 1="YDet>DetTh", 2="YDet<=DetTh", 3="YDet>=DetTh", 4="YDet==DetTh", 5="YDet!=DetTh" DETTH = 50 # (50) Detection Threshold [ 50 is 8 bit thresh, for 10 bit use eg (50*4) ] # VFLIP = True # Vertical Flip if upside down REJECT = False # Arg to Pass 2 Extract Frames. [Extract BLUE LED frames instead of good frames if TRUE] ############ Assert(0 <= OP <= 3,"BlueLED: 1 <= OP <= 3") # Check Valid Assert(0 <= YMODE <= 4,"BlueLED: 0 <= YMODE <= 4") # Check Valid Assert(0 <= DETMODE <= 5,"BlueLED: 0 <= DETMODE <= 5") # Check Valid FN = FN.RT_GetFullPathName # Ensure full path if not already got one Frames = FN.RT_FilenameSplit(7) + "_Frames.txt" # If eg FN="...\MBGV0403.MXF" then Frames = "...\MBGV0403_Frames.txt" LWLibavVideoSource(FN) # Video Source ############ (VFLIP) ? FlipVertical : NOP SHOW = (OP==3) ? False : SHOW # Auto Switch OFF SHOW for pass 1 if two pass if(OP==0) { BlueLED_Tweak(TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,YMODE,YTH) } # Tweak Coords else if(OP==1) { BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,YMODE,YTH,DETMODE,DetTh,Show=SHOW) } # Detect else if(OP==2) { BlueLED_FrameSel(Frames,REJECT) } # Extract Frames else { # Auto 2 Pass BlueLED_Detect(Frames,TEST_X,TEST_Y,TEST_W,TEST_H,BITS8,YMODE,YTH,DETMODE,DetTh,Show=SHOW).RT_ForceProcess() BlueLED_FrameSel(Frames,REJECT) } Return Last ############ # OP=0 Function BlueLED_Tweak(clip c,int x,int y,int w,int h,Bool "Bits8",Int "YMODE",Float "YTh") { # Shows YPlane value (YPlane Mode selected by YMODE) of Test Area (x,y,w,h, marked in yellow) # If Bits8, then Test Area is converted to 8 bit Y8, and metrics shown in range 0->255 Bits8 = Default(Bits8,False) # If True, then metrics are for 8 bit YMODE = Default(YMODE,1) # Default 1=YPLaneMax YTh = Default(YTh,0.4) # YPlaneMax Threshold (%) Assert(0 <= YMODE <= 4,"BlueLED_Tweak: 0 <= YMODE <= 4") tc = c.Crop(x,y,w,h) # Test Area tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc # 8 Bit if requested SSS=""" YDet= \ (YMODE==0) ? tc.YPlaneMin(YTh) : \ (YMODE==1) ? tc.YPlaneMax(YTh) : \ (YMODE==2) ? tc.YPlaneMinMaxDifference(YTh) : \ (YMODE==3) ? tc.YPlaneMedian : \ tc.AverageLuma.Round Subtitle(String(current_frame) + "] YDet=" + String(YDet) , Size=48) """ c.ScriptClip(SSS, Args="tc,YMODE,YTh",Local = true) OverLay(c.BlankClip(Length=1,Width=w,Height=h,Color=$FFFF00),x=x,y=y,Opacity=0.15) # Mark Test Area in yellow Return Last } # OP=1 Function BlueLED_Detect(clip c,String Fn, int x,int y,int w,int h,Bool "Bits8",Int "YMODE",Float "YTh",Int "DETMODE",int "DetTh", Bool "Show") { bpc = c.BitsPerComponent() # Bit Depth of c clip Bits8 = Default(Bits8,False) # If True, then DetTh and metrics are for 8 bit YMODE = Default(YMODE,1) # Default 1=YPLaneMax YTh = Default(YTh,0.4) # YPlane Threshold (%) for YMODE=0,1,2, YPlaneMin, YPlaneMax, and YPLaneMinMaxDifference. DETMODE= Default(DETMODE,0) # Default 0="YDet<DetTh" for detect NOT BlueLED DetTh = Default(DetTh,Bits8?50:50*BitLShift(1,bpc-8)) # Detect Threshold. Compliant with Bits8 arg. Show = Default(Show,False) Assert(fn!="","BlueLED_Detect: Frames file Fn Cannot be ''") Fn = Fn.RT_GetFullPathName RT_FileDelete(Fn) tc = c.Crop(x,y,w,h) tc = Bits8 ? tc.ConvertBits(8).ConvertToY8 : tc SSS=""" YDetCur= \ (YMODE==0) ? tc.YPlaneMin(YTh) : \ (YMODE==1) ? tc.YPlaneMax(YTh) : \ (YMODE==2) ? tc.YPlaneMinMaxDifference(YTh) : \ (YMODE==3) ? tc.YPlaneMedian : \ tc.AverageLuma.Round YDetPrv= \ (YMODE==0) ? tc.YPlaneMin(YTh,-1) : \ (YMODE==1) ? tc.YPlaneMax(YTh,-1) : \ (YMODE==2) ? tc.YPlaneMinMaxDifference(YTh,-1) : \ (YMODE==3) ? tc.YPlaneMedian(-1) : \ tc.AverageLuma(-1).Round T1 = \ (DETMODE==0) ? (YDetCur <DetTh) : \ (DETMODE==1) ? (YDetCur >DetTh) : \ (DETMODE==2) ? (YDetCur<=DetTh) : \ (DETMODE==3) ? (YDetCur>=DetTh) : \ (DETMODE==4) ? (YDetCur==DetTh) : \ (YDetCur!=DetTh) T2 = \ (DETMODE==0) ? (YDetPrv <DetTh) : \ (DETMODE==1) ? (YDetPrv >DetTh) : \ (DETMODE==2) ? (YDetPrv<=DetTh) : \ (DETMODE==3) ? (YDetPrv>=DetTh) : \ (DETMODE==4) ? (YDetPrv==DetTh) : \ (YDetPrv!=DetTh) T = (T1 && (!T2 || current_frame==0)) # True if current frame is detected non moving,and previous detected as moving. (T) ? RT_WriteFile(Fn,"%d # %d",current_frame,YDetCur,Append=current_frame>0) : NOP if(Show) { s = RT_String("%d] %s\\nYDetCur=%d\\nYDetPrv=%d\\n(DetTh=%d)",current_frame,T?"Bingo":"",YDetCur,YDetPrv,DetTh) Subtitle(s,Size=48,lsp=0) } Return Last """ c.ScriptClip(SSS, Args="tc,YMODE,YTh,DETMODE,DetTh,Fn,Show",Local=true) Return Last } # OP=2 Function BlueLED_FrameSel(clip c,String Frames,Bool "Reject") { # Extract Frames from clip c Reject = Default(Reject,False) Assert(Frames!="","BlueLED_FrameSel: Frames Cannot be ''") Frames = Frames.RT_GetFullPathName # Add full path if not already got one Return FrameSel(c,Cmd=Frames,Ordered=True,reject=Reject) } another used arifical pure black to indicate frames to delete. The DB version similar to this could achieve both those goals.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th May 2021 at 16:33. |
Tags |
image analysis decimation |
Thread Tools | Search this Thread |
Display Modes | |
|
|