Git Product home page Git Product logo

coherent-line-drawing's Introduction

Coherent Line Drawing

C/C++ CI Build Status codecov License: MIT

This project implemented a non-photorealistic rendering technique presented by Kang et al, that can automatically generates a line drawing from a photograph. This project provide an easy-to-use, real-time interactive graphic user interface system.

demo

Workflow (Youtube)

Coherent Line Drawing

Build

Requirement

  • C++ 17
  • CMake
  • OpenCV 3
  • WxWidget 3 (not required for cmd application)
  • Boost (not required for gui application)

If you prefer C++ 11 version, there is a branch called cpp11, the function is equivalent.

It should work fine in Windows/Linux/MacOS.
I provided some scripts that can use in Linux:

# Usage: build.sh [options]
# Options:
#   -c, --clean       Clean build
#   -d, --debug       Build with debug mode
#   -j, --jobs        Use N cores to build
$ ./build.sh

# Usage: linter.sh [options]
# Check code style
# Options:
#   -i                In-place format
$ ./linter.sh

Command Line Version

I provide another command line application that can directly use without graphic interface, the entry point is src/cmd.cpp. The options is list as following, also you can refer to ./test.sh to see how to use:

# Coherent-Line-Drawing Options:
#   -h [ --help ]            Help message
#   -s [ --src ] arg         Source image path
#   -o [ --output ] arg      Output image path
#   --ETF_kernel arg (=5)    ETF kernel size
#   --ETF_iter arg (=1)      Refining n times ETF
#   --CLD_iter arg (=1)      Iterate n times FDoG
#   --sigma_c arg (=1)       Line width
#   --sigma_m arg (=3)       Degree of coherence
#   --rho arg (=0.997)       Noise
#   --tau arg (=0.8)         Thresholding

Pre-Build GUI Version

You can download pre-build version at here.
Including Windows and macOS versions.

Screenshots

demo demo demo

coherent-line-drawing's People

Contributors

kylemcdonald avatar ssarcandy 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coherent-line-drawing's Issues

Won't run - crashes on startup

Running the pre-compiled executable gives me:

/Users/x/Downloads/release-macos/Coherent-Line-Drawing ; exit;
MacBook-Pro:~ x$ /Users/x/Downloads/release-macos/Coherent-Line-Drawing ; exit;
dyld: Library not loaded: lib/libopencv_xphoto.3.1.dylib
  Referenced from: /Users/x/Downloads/release-macos/Coherent-Line-Drawing
  Reason: image not found
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

This is on a 2017 MacBook Pro, running macOS 10.12.6

Possible bug in ETF.cpp?

ETF.cpp:86 is:
float w_m = computeWm(gradientMag.at<float>(y, x), gradientMag.at<float>(r, c));
However gradientMag is a 3-channel Mat (CV_32FC3). gradientMag.at(y, x) actually returns a value at some other position (I'm not sure where it actually accesses). Debugging shows that in most cases it seems to return 0, and thus in most cases computeWm() returns 0.5, effectively disabling the impact of Wm. This problem doesn't make the output image obviously wrong. Though I guess it's better to correct it.
Here is the fix I propose:
float w_m = computeWm( norm( gradientMag.at<Vec3f>(y, x) ), norm( gradientMag.at<float>(r, c) ) );

Linux build: GTK issues

I did a build on Linux. When I ran the generated executable I got the error:

$ ./Coherent-Line-Drawing (Coherent-Line-Drawing:1385): Gtk-ERROR **: 17:42:02.514: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported Trace/breakpoint trap (core dumped)

Before I dig deeper into this problem, has anyone else built a Linux version?

Build fails on OSX M1

Hi, I'd love to try it out, but the supplied binary doesn't seem to work and the build process fails even though I have boost installed.
Monterey 12.1
boost 1.76.0 is already installed and up-to-date.

/usr/sbin/sysctl
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jan/Documents/ML/Coherent-Line-Drawing/build
Consolidate compiler generated dependencies of target cld
Consolidate compiler generated dependencies of target Coherent-Line-Drawing
[  9%] Building CXX object CMakeFiles/cld.dir/src/cmd.cpp.o
[ 18%] Building CXX object CMakeFiles/cld.dir/src/postProcessing.cpp.o
[ 45%] Building CXX object CMakeFiles/cld.dir/src/CLD.cpp.o
[ 81%] Built target Coherent-Line-Drawing
/Users/jan/Documents/ML/Coherent-Line-Drawing/src/cmd.cpp:1:10: fatal error: 'boost/program_options.hpp' file not found
#include <boost/program_options.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/cld.dir/src/cmd.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/Users/jan/Documents/ML/Coherent-Line-Drawing/src/postProcessing.cpp:71:63: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [-Wliteral-conversion]
            cv::arrowedLine(dst, p1, p2, cv::Scalar(1, 0, 0), 1.5, 8, 0, 0.3);
            ~~                                                ^~~
1 warning generated.
make[1]: *** [CMakeFiles/cld.dir/all] Error 2
make: *** [all] Error 2

```

Build fails on Linux

Hi,
I am having trouble installing Coherent-Line-Drawing on Linux.

I downloaded this: https://github.com/SSARCandy/Coherent-Line-Drawing/archive/refs/tags/v1.0.3.zip but when I tried to run ./build.sh from that directory, I got the following error message:

~/Coherent-Line-Drawing-1.0.3$ ./build.sh
/usr/bin/nproc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/build
[ 9%] Building CXX object CMakeFiles/Coherent-Line-Drawing.dir/src/ETF.cpp.o
[ 18%] Building CXX object CMakeFiles/cld.dir/src/cmd.cpp.o
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/ETF.cpp: In member function ‘void ETF::initial_ETF(std::string, cv::Size)’:
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/ETF.cpp:33:47: error: ‘CV_INTER_LINEAR’ was not declared in this scope
33 | cv::resize(flowField, flowField, s, 0, 0, CV_INTER_LINEAR);
| ^~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/Coherent-Line-Drawing.dir/build.make:90: CMakeFiles/Coherent-Line-Drawing.dir/src/ETF.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/Coherent-Line-Drawing.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 27%] Building CXX object CMakeFiles/cld.dir/src/ETF.cpp.o
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/cmd.cpp: In function ‘int main(int, char**)’:
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/cmd.cpp:87:42: error: ‘CV_GRAY2RGB’ was not declared in this scope
87 | cv::cvtColor(cld.result, cld.result, CV_GRAY2RGB);
| ^~~~~~~~~~~
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/cmd.cpp:95:40: error: ‘CV_GRAY2BGR’ was not declared in this scope
95 | cv::cvtColor(vis_etf, vis_etf, CV_GRAY2BGR);
| ^~~~~~~~~~~
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/cmd.cpp:101:42: error: ‘CV_RGB2BGR’ was not declared in this scope; did you mean ‘CV_RGB’?
101 | cv::cvtColor(vis_flow, vis_flow, CV_RGB2BGR);
| ^~~~~~~~~~
| CV_RGB
make[2]: *** [CMakeFiles/cld.dir/build.make:76: CMakeFiles/cld.dir/src/cmd.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/ETF.cpp: In member function ‘void ETF::initial_ETF(std::string, cv::Size)’:
/home/jl/Documents/University/2024/Spring_2024/Paper/program/cpp11/Coherent-Line-Drawing-1.0.3/src/ETF.cpp:33:47: error: ‘CV_INTER_LINEAR’ was not declared in this scope
33 | cv::resize(flowField, flowField, s, 0, 0, CV_INTER_LINEAR);
| ^~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/cld.dir/build.make:90: CMakeFiles/cld.dir/src/ETF.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/cld.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

How do you get around these error messages to install Coherent-Line-Drawing on Linux?

Thanks!

Boost was missing in the requirement

Technically, this does not count as an issue.
But, the Wiki section mentions only OpenCV and WxWidgets as external library dependencies and not the Boost library.

While compiling even with the Boost linked to my IDE, I get the following error.

undefined reference to `boost::program_options::options_description::options_description(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned int, unsigned int)'

This is same for each line of code which has a link to the boost library. I am using Windows 10 with Code::Blocks

how to use release-windows correctly? it does work sometimes

i downloaded the Coherent Line Drawing-release-windows, however, it does not work sometimes with some images, i do not know why? the result, even the original image will be a whole black one after my operation. any one can tell me how to use this GUI correctly? maybe my operation is wrong. Thanks in advance.

Add a License File

I may have missed it, but I don't see a clearly marked license for your work. It looks awesome, but it would be dangerous for others to use without you clearly specifying under what license you're releasing it. Thanks!

OSX GUI is missing a dylib

dyld: Library not loaded: lib/libopencv_imgproc.3.1.dylib

Is there a way to include it into binary without having to install OpenCV?

undeclared fn arrowedLine in src/postProcessing.cpp

I'm running gcc 4.8.4 on Ubuntu 14.04.3 "Trusty Tahr" and have installed cmake, libwxgtk3.0-dev, and libopencv-dev.

Compiling fails:

/home/eritain/Coherent-Line-Drawing/src/postProcessing.cpp: In member function ‘void PP::FlowField(cv::Mat&, cv::Mat&)’: /home/eritain/Coherent-Line-Drawing/src/postProcessing.cpp:66:61: error: ‘arrowedLine’ was not declared in this scope arrowedLine(dis, p, p2, Scalar(255,0, 0), 1.5, 8, 0, 0.3); ^

In OpenCV 3.0, arrowedLine is declared in opencv2/imgproc/imgproc.hpp but I lack the know-how to include that in either include/postProcessing.h or src/postProcessing.cpp (I tried, but no luck). What do?

EDIT: I installed 3.0 but it's still looking at 2.4.8?!

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.