Log in

View Full Version : CropRel as lines ? How to draw a line?


Selur
3rd July 2022, 15:18
Hi,
I'd like to have a small function wrapper for CropRel, with a 'show'-parameter which would simply show the lines of a rectangle instead of actually cropping,....

function ShowWrapCropRel(cllip: vs.VideoNode, left: int=0, top: int=0, right: int=0, bottom: int=0, show: bool:False) -> vs.VideoNode:
if show:
return core.std.CropRel(clip=clip, left=2, right=2, top=2, bottom=2)
else:
# no 'good' idea, how to do it #

Only think that pops to mind would be to create a line horizontal (bright green) Blankclip and another verical (bright green) Blankclip and then use havsfunc.Overlay to overlay the lines on the frame.
-> There must be an easier way to do this right?

Cu Selur

ChaosKing
3rd July 2022, 15:46
Your idea sounds easy enough...
Alternative, but very similar to your approach https://forum.doom9.org/showthread.php?t=175105

Selur
3rd July 2022, 16:13
Okay, thought there ought to be something easier / more straight forward. ;)

Selur
3rd July 2022, 16:25
https://github.com/kewenyu/VapourSynth-Draw that might work, if I can figure out an expression for this,...

Selur
3rd July 2022, 17:12
Okay, my idea with the BlankClip runs into a few hurdles. ;)
can't make a YUV420 BlankClip with width or height = 1
and
left = 0
top = 0
right = 0
bottom = 0
clipHline = core.std.BlankClip(clip=clip, width=2)
clipVline = core.std.BlankClip(clip=clip, height=2)
clip = havsfunc.Overlay(base=clip, overlay=clipHline, x=left)
clip = havsfunc.Overlay(base=clip, overlay=clipHline, x=clip.width-right)
clip = havsfunc.Overlay(base=clip, overlay=clipVline, y=top)
clip = havsfunc.Overlay(base=clip, overlay=clipVline, y=clip.height-bottom)
also fails with:
vapoursynth.Error: Crop: negative/zero cropping dimensions not allowed
since Overlay also uses Crop 'overlay = overlay.std.Crop(left=cl, right=cr, top=ct, bottom=cb)' ;)
-> not as easy as expected, so if anyone has a working idea please let me know.

Cu Selur

StainlessS
3rd July 2022, 18:02
I dont speak VS, nor Parsel Tongue,
but you are aware that YUV420 has chroma of 2x2,
You might be able to use instead YV24,and overlay that [just my 2 pence worth].

Julek
3rd July 2022, 18:45
We can do something like this with Expr: https://slow.pics/c/LqCioXbX

Code: https://gist.github.com/dnjulek/69902b0935dd8a43b96b411b9e778d9d

Selur
4th July 2022, 04:52
Nice! Thanks a lot!

Myrsloik
4th July 2022, 15:28
If speed isn't a big issue I'd do it with ModifyFrame and modify the pixels with python directly.