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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th January 2019, 20:39   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
warp - geometry correction with control points (also includes new version of quad)


warp v0.1 <- click here, it's a link!

warp is a geometry correction filter which uses control points and a thin plate spline (as used in morphing) to correct or distort a video's geometry. I have no idea if anyone is going to find this useful.

Documentation (such as it is), examples, and source are included. The same DLL also provides a new version of quad which supports more colour spaces (all the "classic" ones, plus 8-bit planar RGB).

x86 and x64 DLLs, both static and dynamically linked, are provided. SSE2 is definitely required, possibly SSE3. Sorry, luddites!

It's so fancy it even has its own demo/tutorial video: https://www.youtube.com/watch?v=SG1eex7HmLM

Recommended companion software: Hugin

Code:
warp (v0.1)
===========
  A collection of geometry correction filters using control points, specified
  either as a list of numbers, a string, or with a Hugin project file
  (see http://hugin.sourceforge.net/)

  (c) David Horman, 2019

Description
===========
  warp takes a list of control points - pairs of image coordinates - and
  warps the input video using a thin plate spline (as used in morphing)
  such that the coordinates of the first point in a pair are moved to the
  position of the second point in the pair, with the rest of the image
  distorted as smoothly as possible.

  Control points are specified either directly as filter parameters, or as a
  whitespace- and/or comma-separated string, or by passing the filename of a
  Hugin project file (.pto). A separate guide to creating a warp-compatible
  Hugin project is included.

  quad is a reimplentation of my old quad filter. It remaps an image based on
  one or two specified quadrilaterals.

  warp_series takes map frames generated by warp and uses them as animation
  keyframes, blending them to provide smooth transitions between warps.

  warp_grid is a helper filter which draws a grid on a video clip.

  Please refer to the individual documentation files for usage and parameters.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 14th January 2019 at 23:35.
wonkey_monkey is offline   Reply With Quote
Old 14th January 2019, 21:10   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,297
Nice, thanks! I will test drive it

I was just going to ask about alignment options in avisynth; something similar to hugin or photoshop autoalign with perspective and warping corrections instead of just global frame translation/rotations
poisondeathray is offline   Reply With Quote
Old 14th January 2019, 22:40   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Lovely WonkyWilly,

Maybe point out availability [EDIT: Where to get the plug] via your sig (took me bout 40 -> 60 seconds to figure it out).
__________________
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 January 2019 at 23:10.
StainlessS is offline   Reply With Quote
Old 14th January 2019, 23:01   #4  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Quote:
Originally Posted by StainlessS View Post
Lovely WonkyWilly,

Maybe point out availability via your sig (took me bout 40 -> 60 seconds to figure it out).
Huh? Figure what out?

And my availability is none of your business, cheeky
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 14th January 2019, 23:10   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Aha, the link is the enourmous warp v0.1 below the top image, me is a dick
__________________
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 January 2019 at 23:14.
StainlessS is offline   Reply With Quote
Old 15th January 2019, 17:45   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,297
Works great. Nice video tutorial

When combined with gmic clut method , it's a power color matching technique . The benefit is you can use the BD chroma (or other src image) resolution . It's a bit colourlike on steroids. Results are better than some commercial color matching plugins and workflows. The negatives are the workflow is a bit clunky and requires per scene matching
https://forum.doom9.org/showthread.p...94#post1862294

The haldclut => cube conversion can be done with python script instead of the one suggested in that thread. It's faster/easier , batchable and the crc check is the same.
LUT-Convert-master
https://github.com/mikeboers/LUT-Convert
Since it's python based, it makes me wonder if it could be made adaptable to vapoursynth


Perhaps out of the scope of this plugin discussion -

While manual control point is great for accuracy and fine tuning - I'd like to see some way of auto matching possibilities - are you aware of any ? The hugin bundled ones aren't that great . eg. Are there any FOSS engines that hugin can use externally ? Even if it's a rough control point auto layout matching generation, it would reduce the amount of manual fine tweaking later

I'm wondering if this can somehow be used/incorporated into the autooverlay plugin . It "feels" like a powerful pairing in the making
https://forum.doom9.org/showthread.php?t=175247
poisondeathray is offline   Reply With Quote
Old 15th January 2019, 20:12   #7  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Yeah, I was disappointed with Hugin's automatic control point thing as well. Firstly, it works better if the videos are the same resolution - and it's probably not a terrible idea to NNEDI the DVD footage first, before trying to match it to Bluray footage. Secondly, I think all such control point finders (Autopano is another) are optimised for matching photos from the same set, rather than different quality/colour footage like this. And thirdly, I expect it's ultimately an intractable problem anyway, in that you can never guarantee you won't get bad control points.

Hugin also has a fine tune for control points, but I also had problems with that (I mention it at the same start of the video, but in the end I didn't bother expanding on it).

Maybe something can be done with mvtools, using large block sizes and filtering for good/consistent vectors.
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 15th January 2019 at 20:15.
wonkey_monkey is offline   Reply With Quote
Old 17th January 2019, 21:13   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Welcome to the forum Wonkey, I'm sure that you will find it a non stressful place where you can expend lots of decades.

EDIT: You got Wonkey Monkey . com, be quick else you got squatters to eradicate. [hitmen are expensive, or so I've been told]
__________________
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; 17th January 2019 at 21:34.
StainlessS is offline   Reply With Quote
Old 20th January 2019, 15:00   #9  |  Link
trondmm
Registered User
 
Join Date: Apr 2010
Posts: 9
Thank you. This is great.

The biggest problem I have at the moment, is that it sometimes fails silently. i.e. Nothing happens, there's no error message, and debug=WARP_DEBUG_ISOMAP returns a completely black image

This happens when the pto-file doesn't exist, but also when the file actually exists. I'm not sure if warp for some reason is unable to open the file, or if there's something in the file that causes warp() to croak.

If I copy the points from the file manually, warp() works as expected.
trondmm is offline   Reply With Quote
Old 20th January 2019, 15:20   #10  |  Link
trondmm
Registered User
 
Join Date: Apr 2010
Posts: 9
Ah. Found it!

If I change the control point lines from
Code:
c n1 N0 x1001 y747 X952 Y784 t0
to

Code:
c n0 N1 x1001 y747 X952 Y784 t0
it works.
trondmm is offline   Reply With Quote
Old 20th January 2019, 19:16   #11  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Hmm. I assumed Hugin would always put them in ascending order. For now, just make sure image #0 is in the left pane and image #1 is in the right pane.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 25th January 2020, 14:20   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Wonkey,
A few probs in docs for warp and quad.

from quad,.txt
Code:
warp(
  (clip)
  (floats)   (optional)
  (string)   string (optional)
  (bool)     swap              = false
  (bool)     relative          = false
  (bool)     pto_resize        = true
  (int)      resample          = WARP_BICUBIC = 2
  (int)      quality           = 6
  (float)    scale             = 1
  (float)    scalex            = 1
  (float)    scaley            = 1
  (float)    scale1            = 1
  (float)    scalex1           = 1
  (float)    scaley1           = 1
  (float)    scale2            = 1
  (float)    scalex2           = 1
  (float)    scaley2           = 1
  (clip)     overlay           = NULL
  (int)      overlay_threshold = 0
  (int)      threads           = 0 (automatic)
  (bool)     interleaved       = false
  (int)      debug             = 0
  (int)      map               = [undefined]
)
Should I think be as so
Code:
quad(                                                    # Wrong name, was warp
  (clip) 
  (floats)   (optional)
  (string)   string (optional)
  (float)    strength          = 1.0                     # Missing from description (also no documentation)
  (bool)     swap              = false
  (bool)     normal            = true                    # Missing from description (also no documentation)
  (bool)     relative          = false
  (bool)     pto_resize        = true
  (int)      resample          = WARP_BICUBIC = 2        # EDIT: Maybe should be QUAD_BICUBIC
  (int)      quality           = 6
  (float)    scale             = 1
  (float)    scalex            = 1
  (float)    scaley            = 1
  (float)    scale1            = 1
  (float)    scalex1           = 1
  (float)    scaley1           = 1
  (float)    scale2            = 1
  (float)    scalex2           = 1
  (float)    scaley2           = 1
  (clip)     overlay           = NULL
  (int)      overlay_threshold = 0
  (int)      threads           = 0 (automatic)
  (int)      map               = [undefined]             # Wrong order
  (bool)     interleaved       = false                   # Wrong order
  (int)      debug             = 0                       # Wrong order
)
Need same changes for warp.txt (except for the warp->quad name change).

Extracted prototypes
Code:
        warp_ORDERED_Function_List


There follows a list of all function names together with CPP style argument specifiers that inform
Avisynth the argument types and optional names. Optional arguments have square brackets surrounding
their name as in [name] and are followed by a type specifier character that gives the type.
Unnamed arguments are not optional. eg "cc[arg1]b[arg2]i" would be two compulsory unnamed clip args,
followed by optional 'arg1' of type bool and optional 'arg2' of type int.

# Argument type specifier strings.
 c - Video Clip
 i - Integer number
 f - Float number
 s - String
 b - boolean
 . - Any type (dot)
# Array Specifiers
 i* - Integer Array, zero or more
 i+ - Integer Array, one or more
 .* - Any type Array, zero or more
 .+ - Any type Array, one or more
#    Etc
###################################


BICUBIC            ""
BILINEAR           ""
DEBUG_GRID         ""
DEBUG_ISOMAP       ""
DEBUG_MARKERS      ""
DEBUG_OVERLAY      ""
DRAFT              ""
grid               "c[size]i[darken]f[colour]i"
LINEAR             ""
quad               "cf*[string]s[strength]f[swap]b[normal]b[relative]b[pto_resize]b[resample]i[quality]i[scale]f[scalex]f[scaley]f"
                     "[scale1]f[scalex1]f[scaley1]f[scale2]f[scalex2]f[scaley2]f [overlay]c[overlay_threshold]i[threads]i[map]i[interleaved]b[debug]i"
QUAD_BICUBIC       ""
QUAD_BILINEAR      ""
QUAD_DEBUG_GRID    ""
QUAD_DEBUG_ISOMAP  ""
QUAD_DEBUG_MARKERS ""
QUAD_DEBUG_OVERLAY ""
QUAD_DRAFT         ""
rekey              "ci"
series             "cc+i*[resample]i[quality]i[transition]i[overlay]c[overlay_threshold]i[threads]i[debug]i"
SINE               ""
warp               "cf*[string]s[strength]f[swap]b[normal]b[relative]b[pto_resize]b[resample]i[quality]i[scale]f[scalex]f[scaley]f"
                     "[scale1]f[scalex1]f[scaley1]f[scale2]f[scalex2]f[scaley2]f[overlay]c[overlay_threshold]i[threads]i[map]i[interleaved]b[debug]i"
WARP_BICUBIC       ""
WARP_BILINEAR      ""
WARP_DEBUG_GRID    ""
WARP_DEBUG_ISOMAP  ""
WARP_DEBUG_MARKERS ""
WARP_DEBUG_OVERLAY ""
WARP_DRAFT         ""
warp_grid          "c[size]i[darken]f[colour]i"
WARP_LINEAR        ""
warp_rekey         "ci"
warp_series        "cc+i*[resample]i[quality]i[transition]i[overlay]c[overlay_threshold]i[threads]i[debug]i"
WARP_SINE          ""
EDIT: This could stand some attention too
Code:
warp(
  (clip)
  (clips)
  (floats)   (optional)                    # Is Int (providing floats would produce error)
  (string)   string (optional)             # Dont exist
  (int)      resample          = WARP_BICUBIC = 2
  (int)      quality           = 6
  (int)      transition        = WARP_LINEAR = 0
  (clip)     overlay           = NULL
  (int)      overlay_threshold = 0
  (int)      threads           = 0 (automatic)
  (int)      debug             = 0
)


warp_series        "cc+i*[resample]i[quality]i[transition]i[overlay]c[overlay_threshold]i[threads]i[debug]i"
and this
Code:
warp(
  (clip),
  (int)
)

warp_rekey              "ci"
EDIT: No docs for Grid() and Warp_Grid(), Series(), or Rekey().
EDIT: Might want to note possible conflict with V.C Mohan Grid() plugin.
__________________
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; 25th January 2020 at 16:13.
StainlessS is offline   Reply With Quote
Old 25th January 2020, 18:08   #13  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
In my defence... I hate writing documentation.

Quote:
EDIT: No docs for Grid() and Warp_Grid(), Series(), or Rekey().
There is no Grid, Series, or Rekey, just warp_grid, warp_series, and warp_rekey.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 25th January 2020, 19:34   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Quote:
Originally Posted by wonkey_monkey View Post
In my defence... I hate writing documentation.



There is no Grid, Series, or Rekey, just warp_grid, warp_series, and warp_rekey.

I beg to differ, see the prototypes extracted from the dll. (2 posts previous)


Edit: doin' the docs is the best part of coding.
__________________
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; 25th January 2020 at 19:58.
StainlessS is offline   Reply With Quote
Old 25th January 2020, 20:27   #15  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Well that wasn't me. Does Avisynth automatically split names at underscores and create alternative filter names?
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 25th January 2020, 21:03   #16  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,321
This is a very interesting method of color matching (more like chroma swapping) that relies solely on the quality of the warping. In perfect warped results, this method can achieved 100% accuracy of color mapping. However, the amount of work is way too much right now. Do you have ideas how to turn this thing into a gui?
lansing is offline   Reply With Quote
Old 26th January 2020, 00:16   #17  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Ideas yes, plans no. Hugin gets you about 90% of the way there already, although it's rather awkward having to save and load pairs of frames. Copy/paste into Hugin would make it a lot easier, but I doubt it's something they'd implement. I was going to incorporate a control point GUI in something else I'm working on (which may or may not ever see the light of day), but I ended up steering from a two-pane GUI and it's a bit complicated to reimplement now.

StainlessS - I think it was him, he's usually the one with the crazy ideas - has previously posted scripts for using AutoHotKey to record clicks on a VirtualDub window, I believe. That could work with a stackhorizontal clip of the two videos, although I have no idea how you'd extract which frame you're on, nor would it give any visual feedback like Hugin does.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 26th January 2020, 13:15   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 8,283
Quote:
Does Avisynth automatically split names at underscores and create alternative filter names?
Arh, yes. Avs allows for using DllName_Filtername, something like DeBlock_DeBlock() to avoid using an alternative plugin (eg in DGDecode dll DeBlock),
It, (the prototype extractor) is probably getting a bit confused as dll is warp.dll and filters pre-pended with "warp_".
The Prototype extractor usually tries to avoid outputting the dll prepended name[it obviously is failing to do that here, and drops the 'warp' bit].

The crazy idea in question is SawBones, using AutoIt (AutoHotKey was once AutoIt, and broke away due to developer differences, and since has diverged quite a bit).
The AutoIt source is supplied in SawBones/FrameSurgeon zip.
[AutoIt, not that much different to Basic. Has a massive library of apps and source, initially developed to perform system admin tasks. Compiled to self contained native executable, no dll's required].

EDIT: Yep, below fails [there is no function named 'Grid'].
Code:
Colorbars
Grid()
__________________
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; 26th January 2020 at 13:49.
StainlessS is offline   Reply With Quote
Old 2nd February 2020, 14:40   #19  |  Link
redfordxx
Registered User
 
Join Date: Jan 2005
Location: Praha (not that one in Texas)
Posts: 863
Here I almost finished my script for camera rotation. I have question about quad:
Normally, in real life, when I rotate camera 180 degrees, there should be nothing. Using quad, there is again the same picture. See...
Code:
ColorBars().Trim(0,1000).Killaudio()
AddBorders(400,400,400,400)

quad(     720,520,720,1478,   1040,520,1549,1478,   1040,400,1144,1066,   720,400,720,1066,  
           \ interleaved=true, relative=false, debug=4)
Is there any option to remove the picture of the other side?
redfordxx is offline   Reply With Quote
Old 2nd February 2020, 15:12   #20  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,994
Quad is a 2D filter, and only knows where you've placed the corners in 2D space. You'll need to add an extra check to see if the corners are in the same order (clockwise or anti-clockwise) as before they were transformed - if not, move all the points to one side before calling Quad so you get a black video.

http://mathworld.wolfram.com/PolygonArea.html
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey 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 09:59.


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