• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A machine vision library written in SYCL and C++ that shows performance-portable implementation of graph algorithms


Overview

VisionCpp is a lightweight header-only library for computer vision and image processing. The aim of the library is to provide a toolbox that enables performance portability for heterogeneous platforms using modern C++.

Written using SYCL 1.2.1 and compiled/tested with ComputeCpp to accelerate vision code using OpenCL devices.

Table of contents

Integration

You will need to install ComputeCpp in order to use VisionCpp, you can follow the ComputeCpp Getting Started guide that outlines the installation process. All you need to do is include the VisionCpp.hpp header in your project and you are good to go! ( assuming that OpenCL and ComputeCPP is installed correctly. )

#include <visioncpp.hpp> //all that is needed

VisionCpp Tutorials

There are some tutorials explaining how to perform different operations using VisionCpp. These cover basic Hello World, Anisotropic Diffusion, Bayer Filter Demosaic, Dense Depth Reconstruction with Block Matching Algorithm and Harris Corner Detection.

Sample Code

Below is a very simple application that will do the conversion RGB -> HSV. Full source code can be found in the examples folder. RGB is assumed to be a three-channel unsigned char storage with a reasonable channel order.

  // main, args, checks and all the boring stuff

  // ...

  // where VisionCpp will run.
  auto dev = visioncpp::make_device<visioncpp::backend::sycl,
                                    visioncpp::device::cpu>();

  // create a host container for input data
  std::shared_ptr<unsigned char> in_rgb(new unsigned char[3],
  [](unsigned char *dataMem) { delete[] dataMem;});

  in_rgb.get()[0] = atoi(argv[1]);
  in_rgb.get()[1] = atoi(argv[2]);
  in_rgb.get()[2] = atoi(argv[3]);

  // create a host container for output data
  std::shared_ptr<unsigned char> out_hsv(new unsigned char[3],
  [](unsigned char *dataMem) { delete[] dataMem;});

  // exiting this scope will sync data
  {
    // definition of the VisionCpp pipeline:

    // create terminal nodes - a leaf node ( data node ) of the expression tree.
    // terminal struct takes 4 arguments
    // 1st template parameter specifies the data U8 (unsigned char) C3 (three
    // channels)
    // 2nd number of columns in the storage
    // 3rd number of rows in the storage
    // 4th underlying storage type - currently only Buffer2D supported
    auto data =
        visioncpp::terminal<visioncpp::pixel::U8C3, 1, 1,
                            visioncpp::memory_type::Buffer2D>(in_rgb.get());
    auto data_out =
        visioncpp::terminal<visioncpp::pixel::U8C3, 1, 1,
                            visioncpp::memory_type::Buffer2D>(out_hsv.get());

    // unsigned char -> float RGB storage conversion
    auto node = visioncpp::point_operation<visioncpp::OP_U8C3ToF32C3>(data);
    // float RGB to float HSV conversion
    auto node2 = visioncpp::point_operation<visioncpp::OP_RGBToHSV>(node);
    // helper node that allows display of HSV
    // for unsigned char: V <- 255*V, S <- 255*S, H <- H/2 ( to fit in range of 0..255 )
    auto node3 = visioncpp::point_operation<visioncpp::OP_HSVToU8C3>(node2);

    // assign operation that writes output of the pipe to output terminal node
    auto pipe = visioncpp::assign(data_out, node3);
    // execute the pipeline
    // 1st template parameter defines if VisionCpp back-end fuses the expression
    // 2nd & 3rd shared memory sizes ( column, row )
    // 4th & 5th local work group size ( column , row )
    visioncpp::execute<visioncpp::policy::Fuse, 1, 1, 1, 1>(pipe, dev);
  }

  printf("RGB: %u %u %u \nHSV: %u %u %u \n", in_rgb.get()[0], in_rgb.get()[1],
         in_rgb.get()[2], out_hsv.get()[0], out_hsv.get()[1], out_hsv.get()[2]);

Requirements

To successfully compile VisionCpp tests, you will need:

Build

Assuming you are in the root of a git repo:

mkdir build
cd  build
cmake .. -DComputeCpp_DIR={PATH_TO_COMPUTECPP_ROOT} -DCMAKE_CXX_COMPILER={FAVORITE_CXX_COMPILER}
make -j8
make test

The output binaries will be catalogued in bin folder.

| - build
  | - bin
    | - example
    | - test

Examples

There is a set of example code in the /example/ folder of the repository. Most of the examples are performing image operations from the camera input.

Documentation

Online documentation can be found here.

The documentation is created using Doxygen.

make doc

The documentation will be created in html folder in build directory.

| - build
  | - doc

Contributing

Contributors always welcome! See CONTRIBUTING.md for details.

The list of contributors.

Resources

License

The Apache License, Version 2.0 License. See LICENSE for more.

Known Issues

  • The Tuple class works only with clang++.

More Repositories

1

syclacademy

SYCL Academy, a set of learning materials for SYCL heterogeneous programming
HTML
454
star
2

computecpp-sdk

Collection of samples and utilities for using ComputeCpp, Codeplay's SYCL implementation
C
322
star
3

portBLAS

An implementation of BLAS using the SYCL open standard.
C++
256
star
4

portDNN

portDNN is a library implementing neural network algorithms written using SYCL
C++
108
star
5

oneapi-construction-kit

C++
68
star
6

SYCL-ML

SYCL-ML is a C++ library, implementing classical machine learning algorithms using SYCL.
C++
61
star
7

SYCL-For-CUDA-Examples

Examples for using SYCL on CUDA
Shell
52
star
8

llvm-leg

Codeplay's tutorial LLVM LEG backend - as presented at the 2014 LLVM Developers' Meeting in San Jose.
C++
37
star
9

LPGPU2-CodeXL

LPGPU2 CodeXL power performance analysis and feedback tool for GPUs
C++
35
star
10

sycl-for-cuda

Codeplay project for contributions to the LLVM SYCL implementation
C++
30
star
11

standards-proposals

Repository for publicly sharing proposals in various standards groups
C++
27
star
12

portFFT

portFFT is a library implementing Fast Fourier Transforms using SYCL
C++
14
star
13

sycl-info

Tool to show information about available SYCL implementations
C++
11
star
14

cuda-to-sycl-nbody

C++
11
star
15

lldb-msp430

Codeplay's tutorial LLDB-MSP430 - as presented at the 2016 EuroLLVM Developers' Meeting in Barcelona.
C++
10
star
16

parallelts-range-exploration

Repository to exchange current work with rangesTS and Parallel STL
C++
8
star
17

SYCL-samples

A collection of samples written using the SYCL standard for C++.
C++
8
star
18

blog-ray

SYCL enabled ray tracer
C++
6
star
19

sycl-project-list

SYCL Open Source Projects List
4
star
20

sycl.tech-website

Angular front-end for the SYCL.tech website.
TypeScript
3
star
21

sycl.tech-content

Content for the SYCL.tech Website
Python
3
star
22

CUDA_to_SYCL_examples

Example code for the guide
C++
3
star
23

py_gen

Python library for generating C++ code
Python
3
star
24

sycl-crowd-simulation

A crowd simulation algorithm implemented using C++ and SYCL.
Python
3
star
25

mlir-sycl

C++
3
star
26

syclops-website

SYCLOPS Research Project Website
HTML
2
star
27

TensorOpt

C++
2
star
28

SYCLcompat

1
star
29

clang-leg

Codeplay's tutorial Clang LEG changes - as presented at the 2014 LLVM Developers' Meeting in San Jose.
C++
1
star
30

onnxruntime

Codeplay's fork of the onnxruntime open source project adding a SYCL backend providing DNN model support across various SYCL-enabled hardware targets.
C++
1
star
31

computecpp-cmake-template

CMake
1
star
32

Template-Repo

Makefile
1
star