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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th February 2020, 05:39   #1  |  Link
Hotte
Registered User
 
Join Date: Oct 2014
Posts: 129
RoboCrop - unsymmetrical cropping ?

Hi,
I am trying to use RoboCrop to cut out a 648x480 clip which sits in the center of a 1920x1080 export file from an NLE. After applying RoboCrop() I am getting a 648x480 crop. Perfect.

However if (for effect reasons) I decenter the 648x480 clip e.g. 400 px to the left so that the left black frame is a lot thinner than the right frame, I am getting a crop where the left frame has been removed (perfect), but the right black frame is 1036 px wide. So no cropping of the right black frame and the clip is now 1684x480.

I had hoped to again get a 648x480 crop (to speed up subsequent filtering) and to reposition the clip at the end of the process.

Is this sth that cannot be done with RoboCrop or are there any parameters I have missed to find ?
Hotte is offline   Reply With Quote
Old 5th February 2020, 06:08   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,675
Hi Hotte,
Cant off hand remember but think there is some rule applied in Robocrop that disables it from cropping way out of center, (Jmac968 or whatever his name is)
had same kinda problem some time ago, we, I think did find a solution, but not sure at the moment what it was.
I'll try find it in the morrow, time for bed was well long ago.

You could have posted this in Usage, others that do not visit Devs forum will not see it.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 5th February 2020, 06:39   #3  |  Link
Hotte
Registered User
 
Join Date: Oct 2014
Posts: 129
Hi StainlessS,

Mr. RoboCrop himself - very nice to have you listening!

Indeed I used the wrong mailbox. I will stop the thread here and ask again in Avisynth Usage.

Looking very much forward to your findings. Good night...

Hotte
Hotte is offline   Reply With Quote
Old 5th February 2020, 06:49   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,675
Had a qwik look, unfortunately, the Jmac thing was for QueryBorderCrop() [a scrip forerunner to RoboCrop], looks like I did not implement to 'way-off-center' fix in RoboCrop,

RoboCrop
Code:
Function RoboCrop(clip c,int "Samples"=40,Float "Thresh"=-40.0,bool "Laced"=true,int "WMod",int "HMod",int "RLBT"=15,bool "Debug"=false, \
    float "Ignore"=0.4,int "Matrix"=(c.Width>1100||c.Height>600?3:2), int "Baffle"=4, bool "ScaleAutoThreshRGB"=true,
    bool "ScaleAutoThreshYUV"=false, int "CropMode"=2,bool "Blank"=false,bool "BlankPC"=false,bool "Align"=True,bool "Show"=false, \
    String "LogFn"="",bool "LogAppend"=false, Float "ATM"=4.0,int "Start"=Undefined,Int "End"=Undefined, \
    Int "LeftAdd"=0,Int "TopAdd"=0,Int "RightAdd"=0,Int "BotAdd"=0, \
    Int "LeftSkip"=0,Int "TopSkip"=0,Int "RightSkip"=0,Int "BotSkip"=0)
RT_QueryBorderCrop() [RT_stats version of the original script function]
Code:
Function RT_QueryBorderCrop(clip c,int "Samples"=40,Float "Thresh"=-40.0,bool "Laced"=true, \
    int "XMod",int "YMod",int "WMod"=max(XMod,4),int "HMod"=YMod, \
    bool "Relative"=false, String "Prefix"="QBCrop",int "RLBT"=15,bool "DEBUG"=false,float "Ignore"=0.4, \
    int "Matrix" = (c.Width>1100||c.Height>600?3:2), \
    Float "ScanPerc"=49.0,int "Baffle"=4, bool "ScaleAutoThreshRGB"=true,bool "ScaleAutoThreshYUV"=false,Float "ATM"=4.0, \
    int "Start"=Undefined,int "End"=Undefined,
    int "LeftAdd"=0,int "TopAdd"=0,int "RightAdd"=0,int "BotAdd"=0, \                                
    int "LeftSkip"=0,int "TopSkip"=0,int "RightSkip"=0,int "BotSkip"=0)

 Prescan function to get coords for eg cropping black borders by sampling Samples frames. Planar, YUY2, RGB.
 Borders are detected by sampling at Samples frames, at scanlines (h/v) using AverageLuma (RGB is converted to Luma Y at either TV or
 PC levels, See Matrix). This sampling is done on all 4 sides of the frame.
 If a scanline Average luma is below or equal to Thresh, then is considered possible black border, above considered possible image,
 if Baffle [default=4] adjacent scanlines above Thresh, then it IS image.

 Simultaneously returns 4 sets of strings holding crop coords, here is one set: "QBCropX=8 QBCropY=8 QBCropW=640 QBCropH=480".
 String sets are Chr(10) separated, the 'exact found' coords set as above, not rounded at all and possibly throwing an error if
 you try to crop, although could use in eg resize.
 Second set using eg "QBCropXL=8", which is CropLess("L" trailer), ie when rounding for Xmod,WMod etc may leave some black border.
 Third set using eg "QBCropXM=8", which is CropMore, ie when rounding for Xmod,WMod etc may crop some image.
 Forth set using eg "QBCropXP=8", which is CropPlus, moves border positions an extra 2 pixels inwards on each edge and then as CropMore.
 The non-exact coords try to center the coords when cropping for larger WMod/HMod's so as to evenly crop from eg both left and right instead of
 just one side. Also returned in the return string is the used Threshold, perhaps set by AutoThresh, as eg "QBCropThresh=40.0"
 You can use eg Eval(RT_QueryBorderCrop()) to set values into QBCropX, QBCropY,QBCropW,QBCropH etc variables.
It does nearly the same thing, maybe give it a try, returns results as strings.

EDIT: Make Float "ScanPerc"=49.0 something like 99.0. [49.0% scans 49% from left frame to crop left edge, and 49% from right frame to right edge].

EDIT: Maybe eg, you RHS of graphic, is left of center line, that breaks the sanity rule of RoboCrop.
Really time for bed.

EDIT: Bit more:
Code:
   ScanPerc:=49.0=Scan only 49 percent width and height (left, right, top bot) when detecting borders, special use only. Range 1.0 -> 99.0.
    ScanPerc implemented because of this post by Jmac698: http://forum.doom9.org/showthread.php?p=1604004#post1604004
__________________
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 February 2020 at 07:10.
StainlessS is offline   Reply With Quote
Old 6th February 2020, 14:29   #5  |  Link
Hotte
Registered User
 
Join Date: Oct 2014
Posts: 129
Hi StainlessS,

I am answering here because the thread was not yet moved to avs usage.

I tried Function RT_QueryBorderCrop() with ScanPerc=99.0 and it worked out the correct coordinates!

I am not experienced in programming avisynth. What I did was to pull out the first 4 parameters of the returned string using 4 FindStr() commands and to feed the results into crop,x,y,w,h.

Is it what you would have expected for me to do ?

Btw while doing this I wondered why avs refused to recognize TrimAll, TrimRight, TrimLeft and marked them as "Unknown functions ?!" although being documented. Strange.

Anyway it works. So thankx a lot and again!
Hotte is offline   Reply With Quote
Old 6th February 2020, 17:42   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,675
Below Untested.
Code:
AviSource("...")
Eval(RT_QueryBorderCrop())  # Sets default variable names

#Crop(QBCropX.QBCropY,QBCropW,QBCropH)         # Exact coords, probably an error as likely YV12 and Not Mod 2
#Crop(QBCropXL.QBCropYL,QBCropWL,QBCropHL)     # CropLess, May leave a little border
#Crop(QBCropXP.QBCropYP,QBCropWP,QBCropHP)         # CropPlus, Exact Coords + 2 inwards, then as CropMore

Crop(QBCropXM.QBCropYM,QBCropWM,QBCropHM)      # CropMore, Crop a bit more when not Mod 2 (YV12)
This works for me (avs+ 3.4)
Code:
BlankClip(width=240,height=180)
S="                ABC             "
S2=TrimAll(S)
Subtitle("'"+S2+"'")
return last

About to up new version RoboCrop, see Usage.
__________________
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; 6th February 2020 at 20:21.
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.