Hotte
5th February 2020, 06:39
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 ?
StainlessS
5th February 2020, 07:08
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.
Hotte
5th February 2020, 07:39
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
StainlessS
5th February 2020, 07:49
Had a qwik look, unfortunately, the Jmac thing was for QueryBorderCrop() [a scrip forerunner to RoboCrop], looks like I did not implement the 'way-off-center' fix in RoboCrop,
RoboCrop
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]
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:
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
Hotte
6th February 2020, 15:29
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!
StainlessS
6th February 2020, 18:42
Below Untested.
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)
BlankClip(width=240,height=180)
S=" ABC "
S2=TrimAll(S)
Subtitle("'"+S2+"'")
return last
https://i.postimg.cc/nrzVDy4K/Tas-00.jpg (https://postimages.org/)
About to up new version RoboCrop, see Usage.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.