Giter VIP home page Giter VIP logo

nvision-cpp's Introduction

nvision

Cpp17 License

nvision is a header-only C++ library for computer vision applications using the Eigen3 library.

nvision provides:

  • image filters like gauss, box, laplace, sobel and scharr
  • feature detectors like Harris, ShiTomasi, FAST and ORB
  • feature descriptors like BRIEF and ORB
  • optical flow estimation using LucasKanade and HornSchunck
  • projective routines for triangulation and camera calibration
  • handling files in pgm, ppm, png and jpgformat

Install

nvision uses the build2 build system. You can easily use it as dependency by adding it to your manifest file. It will also resolve all additional dependecies of nvision for you.

depends: libnvision ^1.0.0 # base library with CV algorithms
depends: libnvision-jpeg ^1.0.0 # for JPEG support
depends: libnvision-png ^1.0.0 # for PNG support

Otherwise you can simply copy the header files into your project and include them directly.

The core library and all algorithms only require Eigen3 as dependency. Make sure it can be found by your build system

For loading PNG and JPEG files you will need to link against libpng and libjpg-turbo additionally.

In Debian based systems you can simply install these dependencies using apt-get.

apt-get install libeigen3-dev libpng-dev libjpg-turbo-dev

Usage

nvision has many different modules and classes for filtering, feature or edge detection, optical flow and projective geometry.

Check the libnvision-exmaples/ directory for detailed examples and have a look at the docs for detailed information.

A simple getting started example with a gauss filter:

#include <iostream>
#include <nvision/filter.h>
#include <nvision/imageio.h>

int main(int argc, const char **argv)
{
    if(argc != 3)
    {
        std::cerr << "usage: simple_gauss <in-file> <out-file>" << std::endl;
        return -1;
    }

    // Each value per pixel and depth is representd by
    // a 8-Bit integer.
    nvision::Image<nvision::RGB> src;

    // Load the image from a file. The file type is determined by the extension
    // of the file.
    std::cout << "Load " << argv[1] << std::endl;
    nvision::imload(argv[1], src);

    // Create a Gauss filter object. The template parameter determines the
    // internal Scalar type, which is used for computations (e.g. Kernel and
    // Kernel application).
    nvision::GaussFilter<nvision::float32, 9> filter(8.0f);

    // Apply the filter to the source image and store it in dest.
    std::cout << "Apply filter" << std::endl;
    nvision::Image<nvision::RGB> dest = filter(src);

    // Save the image to a file. The file type is determined by the extension
    // of the file.
    std::cout << "Save " << argv[2] << std::endl;
    nvision::imsave(argv[2], dest);

    return 0;
}

A simple getting started example with FAST feature detection:

/* simple_fast.cpp
 *
 * Author: Fabian Meyer
 * Created On: 18 Jun 2019
 */

#include <iostream>
#include <nvision/feature.h>
#include <nvision/draw.h>
#include <nvision/imageio.h>

using namespace nvision;

int main(int argc, const char **argv)
{
    if(argc != 3)
    {
        std::cerr << "usage: simple_fast <in-file> <out-file>" << std::endl;
        return -1;
    }

    // Each value per pixel and depth is representd by
    // a 8-Bit integer.
    nvision::Image<nvision::RGBf> src;

    // Load the image from a file. The file type is determined by the extension
    // of the file.
    std::cout << "Load " << argv[1] << std::endl;
    nvision::imload(argv[1], src);

    std::cout << "Convert to gray scale" << std::endl;
    nvision::Image<nvision::Grayf> gray = nvision::image::convert<Grayf>(src);

    // Create a FAST feature detector object. The template parameter determines the
    // internal Scalar type, which is used for computations and feature point
    // representation.
    nvision::FASTFeature<nvision::float32> detector;

    // Extract feature points from the image.
    using FeatureMatrix = typename nvision::FASTFeature<nvision::float32>::FeatureMatrix;
    FeatureMatrix keypoints;
    std::cout << "Detect features" << std::endl;
    detector(gray, keypoints);

    std::cout << "Draw " << keypoints.cols() << " keypoints" << std::endl;
    nvision::image::draw(src, keypoints, nvision::Marker::Circle, nvision::color::red<RGBf>());

    // Save the image to a file. The file type is determined by the extension
    // of the file.
    std::cout << "Save " << argv[2] << std::endl;
    nvision::imsave(argv[2], src);

    return 0;

    return 0;
}

Compile

nvision can be compiled using the build2 build system.

bdep init -C @gcc-debug cc config.config.load=build-config/gcc.debug.build
b

This will resolve all dependencies of nvision and build all examples and unit tests with your default compiler. You can run the unit tests using build2 again.

bdep test

nvision-cpp's People

Contributors

rookfighter avatar

Stargazers

xiaodong chen avatar Halcao avatar Robert Maier avatar Sanford Wilkinson avatar  avatar Lyot avatar eros avatar Qi Renjie avatar bin.sun avatar Jakob Wilm avatar  avatar Stephan Manthe avatar Casey Sanchez avatar  avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

nvision-cpp's Issues

How to use these optical flows to track points?

Hi,

Thank you for such a wonderful & lightweight computer vision library. I am detecting fast keypoints on camera stream by fetching camera feed using opencv then I am converting that cv::mat to cve::imagef and detecting fast keypoint using cve also getting hs optical flow using the same imagef. Now I am willing to track those detected keypoints with hs of. Is it possible as I can see it's kind of dense optical flow? Although with opencv fernback optical flow i can track sparse points but can't figure out how to do it here. Can you please suggest me?

some questions about the library

First, thanks for the great work. I have some questions though:

  1. I think the example code for Gauss filter in the main page is outdated (probably for old cve namespace I guess) because my compiler complains that there's no type Image8. From the file (https://github.com/Rookfighter/nvision/blob/master/include/nvision/src/core/image_type.h) I am not able to find neither the type Image8 nor Imagef for FAST example.
    It would be great the examples are updated according to the current library format.

  2. When I installed nvision library using cmake, I ran into the problem of hierarchy issue of directories, e.g. #include "nvision/src/core/pixel.h" instead of #include "src/core/pixel.h" in https://github.com/Rookfighter/nvision/blob/master/include/nvision/core.h
    So I had to manually adjust all those things. I guess this is not a problem for build2? or Do you have better suggestions for that matter?

  3. Do you have plan to provide other optic flow algorithms such as (https://link.springer.com/chapter/10.1007/978-3-540-24673-2_3)?

  4. Let's say I want to extend some boundary conditions as flexibly as I can, e.g. central difference with 5 points instead of 3 points, using 5 points boundaries instead of three points or less and set different values at boundaries for customized derivative filters etc. What would you recommend to approach to the task?

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.