Giter Club home page Giter Club logo

canny-edge-detector's Introduction

Canny Edge Detector

Canny edge detector written in CUDA C++. Provides both serial and GPU implementations.

Getting Started

This guide assumes you're on a Linux system with the NVIDIA toolchain supporting CUDA (nvcc, nsight, etc.) already installed.

  1. Install Magick++ library (see below, just need to run a script and wait for installation to complete)
  2. Source the magick.env script (see below)
  3. Compile the edge_detect program (see below)
  4. Run edge_detect --help to see command line arguments. The user can specify input and output filenames, as well as execution of the serial (CPU) or parallel (GPU) implementation.
  5. Run the edge_detect program on an image of your choice (sample images provided in img/)

Dependencies

  • Linux
  • CUDA GPGPU framework (nvcc)
  • Magick++ image library

Magick++ Installation

The edge detection program uses the Magick++ library to read and write images of arbitrary encoding. The library also provides low-level access to the raw pixels of an image, which are then transformed and filtered to produce an edge detected image.

Note: we assume that the user does not have administrative access, and thus can't install packages (as might be the case on a shared server). For that reason, we download and install Magick++7 in-tree in a non-standard location that the user has full control over.

./third_party/install_magick++.sh
source ./third_party/magick.env

Compilation

Binaries will be located in the bin/ directory. All CPU code objects are compiled with g++. CUDA kernel objects are compiled with nvcc. The final executable is also compiled with nvcc. Note that multithreaded make is broken with nvcc in this build system.

Ensure all dependencies have installed successfully, then run:

make

Execution

The edge detector supports serial execution on a host CPU, or parallel execution on an NVIDIA GPU. For command line argument specifics, use the --help option on the generated binary.

To run with default arguments (serial implementation, engine test image):

make run

If you plan to run the binary directly (i.e. not using the makefile), ensure you source magick.env:

source third_party/magick.env

Debug

To debug, you'll need to compile with the debug option and run manually.

# source environment for manual cmd line execution
source third_party/magick.env

# remove old binaries
make clean

# compile with debug symbols and statements
make DEBUG=1

Debugging Host code

# run GNU Debugger
gdb ./bin/edge_detect

# once in the gdb terminal, set breakpoints, arguments, etc.
> set args <cmd line args>
> b <file.extension>:<line number> # set break point
> run # run program until breakpoint
> n # execute next line
> step # step down into next line (inside functions, etc.)

Debugging GPU code

Look for online tutorials for this, it's a bit more involved, though similar, to regular gdb-based debugging. This can also be done using the Nsight tool if you have Eclipse installed.

# run CUDA-GNU Debugger
cuda-gdb

canny-edge-detector's People

Contributors

anilreddyp avatar kinap avatar

Watchers

 avatar  avatar

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.