GithubHelp home page GithubHelp logo

homeofvapoursynthevolution / vapoursynth-tcanny Goto Github PK

View Code? Open in Web Editor NEW
26.0 10.0 4.0 763 KB

TCanny filter for VapourSynth

License: GNU General Public License v3.0

C++ 99.68% C 0.18% Meson 0.14%
vapoursynth tcanny

vapoursynth-tcanny's Introduction

TCanny

Builds an edge map using canny edge detection.

Ported from AviSynth plugin http://bengal.missouri.edu/~kes25c/

Usage

tcanny.TCanny(vnode clip[, float[] sigma=1.5, float[] sigma_v=sigma, float t_h=8.0, float t_l=1.0, int mode=0, int op=1, float scale=1.0, int opt=0, int[] planes=[0, 1, 2]])
  • clip: Clip to process. Any format with either integer sample type of 8-16 bit depth or float sample type of 32 bit depth is supported.

  • sigma: Standard deviation of horizontal gaussian blur. Setting to 0 disables gaussian blur. If a single sigma is specified, it will be used for all planes. If two sigma are given then the second value will be used for the third plane as well.

  • sigma_v: Standard deviation of vertical gaussian blur.

  • t_h: High gradient magnitude threshold for hysteresis.

  • t_l: Low gradient magnitude threshold for hysteresis.

  • mode: Sets output format.

    • -1 = gaussian blur only
    • 0 = thresholded edge map (MAX_PIXEL_VALUE for edge, 0 for non-edge)
    • 1 = gradient magnitude map
  • op: Sets the operator for edge detection.

    • 0 = the operator used in tritical's original filter
    • 1 = the Prewitt operator whose use is proposed by P. Zhou et al. [1]
    • 2 = the Sobel operator
    • 3 = the Scharr operator
    • 4 = the Kroon operator
    • 5 = the Kirsch operator
    • 6 = the FDoG operator
  • scale: Multiplies the gradient by scale. This can be used to increase or decrease the intensity of edges in the output.

  • opt: Sets which cpu optimizations to use.

    • 0 = auto detect
    • 1 = use c
    • 2 = use sse2
    • 3 = use avx2
    • 4 = use avx512
  • planes: Sets which planes will be processed. Any unprocessed planes will be simply copied.

[1]: Zhou, P., Ye, W., & Wang, Q. (2011). An Improved Canny Algorithm for Edge Detection. Journal of Computational Information Systems, 7(5), 1516-1523.

Compilation

meson build
ninja -C build
ninja -C build install

vapoursynth-tcanny's People

Contributors

akarinvs avatar djatom avatar holywu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vapoursynth-tcanny's Issues

tcanny not found when replace r9 dll with r10

vapoursynth r38 offcial build.
l-smash works r929
vsedit r16

the vscode for example:

dbmasklight = core.tcanny.TCanny(aaed,sigma=0.6,t_h=8.0,planes=0,op=2)
dbmaskdark = core.tcanny.TCanny(aaed,sigma=0.4,t_h=7.0,planes=0,op=2)

it reports:

Python exception: No attribute with the name tcanny exists. Did you mistype a plugin namespace?

Plugin it not loaded on non opencl machine (bis)

Hello, it's me again.

I tried again to compile with meson and checked with Dependency Walker since I've seen what you wrote in #4 (comment).
There seems to be a lot of missing dependencies and I don't know why.

Anyway could you provide a non-opencl dll like you did for EEDI3, please?

Thanks in advance!

Slower when core.num_threads > 6

+ exec meson setup --prefix /usr --libexecdir lib --sbindir bin --buildtype plain --auto-features enabled --wrap-mode nodownload -D b_lto=true -D b_pie=true ../tcanny --buildtype=release --libdir /usr/lib/vapoursynth
The Meson build system
Version: 0.61.1
Source dir: /home/nsqy/.cache/paru/clone/vapoursynth-plugin-tcanny-git/src/tcanny
Build dir: /home/nsqy/.cache/paru/clone/vapoursynth-plugin-tcanny-git/src/build
Build type: native build
Project name: TCanny
Project version: 14
C++ compiler for the host machine: clang++ (clang 13.0.0 "clang version 13.0.0")
C++ linker for the host machine: clang++ ld.bfd 2.36.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.8.0)
Run-time dependency vapoursynth found: YES 57
Build targets in project: 3

TCanny 14

  User defined options
    auto_features: enabled
    buildtype    : release
    libdir       : /usr/lib/vapoursynth
    libexecdir   : lib
    prefix       : /usr
    sbindir      : bin
    wrap_mode    : nodownload
    b_lto        : true
    b_pie        : true
>>> print(vs.core.version())
VapourSynth Video Processing Library
Copyright (c) 2012-2021 Fredrik Mellbin
Core R57
API R4.0
API R3.6
Options: -
import vapoursynth as vs
core = vs.core

clip = core.std.BlankClip(width=1920, height=1080, format=vs.YUV420P16, length=2000)
tcanny = core.tcanny.TCanny(clip, sigma=1, mode=-1, planes=[0, 1, 2])

tcanny.set_output(1)
 ❯ time vspipe -p test.vpy -o 1 -r 4
Script evaluation done in 0.07 seconds
Output 2000 frames in 2.41 seconds (830.04 fps)
vspipe -p test.vpy -o 1 -r 4 .   9.48s  user 0.25s system 378% cpu 2.571 total
avg shared (code):         0 KB
avg unshared (data/stack): 0 KB
total (sum):               0 KB
max memory:                574 MB
page faults from disk:     4
other page faults:         238040

❯ time vspipe -p test.vpy -o 1 -r 6
Script evaluation done in 0.07 seconds
Output 2000 frames in 2.08 seconds (961.81 fps)
vspipe -p test.vpy -o 1 -r 6 .   11.99s  user 0.48s system 550% cpu 2.264 total
avg shared (code):         0 KB
avg unshared (data/stack): 0 KB
total (sum):               0 KB
max memory:                785 MB
page faults from disk:     8
other page faults:         401291

 ❯ time vspipe -p test.vpy -o 1 -r 12
Script evaluation done in 0.07 seconds
Output 2000 frames in 2.35 seconds (851.71 fps)
vspipe -p test.vpy -o 1 -r 12 .   25.40s  user 1.47s system 1053% cpu 2.550 total
avg shared (code):         0 KB
avg unshared (data/stack): 0 KB
total (sum):               0 KB
max memory:                1079 MB
page faults from disk:     12
other page faults:         626469


 ❯ time vspipe -p test.vpy -o 1 -r 24
Script evaluation done in 0.07 seconds
Output 2000 frames in 2.47 seconds (811.08 fps)
vspipe -p test.vpy -o 1 -r 24 .   45.87s  user 3.16s system 1823% cpu 2.689 total
avg shared (code):         0 KB
avg unshared (data/stack): 0 KB
total (sum):               0 KB
max memory:                1491 MB
page faults from disk:     14
other page faults:         839105

Not exclusive to 16-bit, happens at 8 too.

Easy ZSH loop, sleep to account for CPU boost

for x in 4 6 12 24
sleep 10s && time vspipe -p test.vpy -o 1 -r $x .

Blank output when compiled with GCC and ASM is enabled

Initially brought this up in #13 (comment), thought it made sense to create an issue to track this, even if there's no clue on a solution. Several others have reproduced it, so I wanted to document the workaround as well.

The workaround is to build this plugin with Clang or MSVC. You can use clang by prefixing CC=clang CXX=clang++ to the meson build step.

malloc failure / alignment error on arm64 -> fix included

I build TCanny on an Apple Silicon machine and I always got an error message malloc failure (blur) when I tried to use it.
I noticed that in line 581 of TCanny.cpp the alignment is set to 4, and in case of arm it is not overwritten by SIMD selection.

I made a quick and dirty fix and set it to 8, problem solved:
d->alignment = 8;
Maybe you could either change to a fixed alignment or maybe sizeof(void*) could also work (not tested).

macOS compatibility

For compiling in macOS it needs "-framework OpenCL" instead of "-lOpenCL".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.