Giter Site home page Giter Site logo

opencv_dnn's Introduction

ROS package for using OpenCV's DNN capability

Usage

Plugins are used for processing the output on the network. Available plugins are:

  • opencv_dnn::YOLOv8Parser (default)
  • opencv_dnn::YOLOv5Parser

Topics

Input topic:

  • image

Output topics:

  • ~/detections
  • detection_image
  • ~/class_labels

Parameters

  • model
  • model_path
  • configuration
  • configuration_path
  • detections_parser
  • threshold
  • nms_threshold
  • class_names
  • input/width
  • input/height

ROS noetic

For building on Ubuntu 20.04, an updated OpenCV (4.5+) is needed.

Cuda

If using cuda, you may want to install the latest version.

To see what's installed:

apt list --installed | grep cuda

From https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ubuntu

sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update

Note, for Jetsons, use the appropriate architecture:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/arm64/cuda-keyring_1.1-1_all.deb

As of this writing, OpenCV will not build using Cuda 12.2, so install 12.1.

sudo apt install cuda-12-1

Remove metapackage that installs latest cuda:

sudo apt remove cuda
sudo apt autoremove

Add following to ~/.bashrc and make sure to source it or reboot.

export PATH=/usr/local/cuda-12.1/bin${PATH:+:${PATH}}

Clone OpenCV from github

cd ~/src
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build

Without cuda:

cmake ../ -D CMAKE_INSTALL_PREFIX=~/.local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules

With cuda:

cmake ../ -D CMAKE_INSTALL_PREFIX=~/.local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D OPENCV_DNN_CUDA=ON -D WITH_CUDA=ON

OR with cuda but leaner for faster build: cmake ../ -D CMAKE_INSTALL_PREFIX=~/.local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D OPENCV_DNN_CUDA=ON -D WITH_CUDA=ON -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF -D BUILD_TESTS=OFF

make -j4
make install

This will install OpenCV in ~/.local

To avoid link errors, the vision_opencv package should also be built against this alternate OpenCV so clone it into your workspace.

https://github.com/rolker/vision_opencv

Weights

See onnx model zoo

Parsing class labels from ONNX

The src/onnx/onnx.proto file was copied from: https://github.com/onnx/onnx/blob/main/onnx/onnx.proto

Docker

To build the docker image.

docker compose build

Start the dev container

docker compose up -d dev

or

docker compose up -d dev-nvidia

To open a shell in the dev container

docker exec -it opencv_dnn-dev-1 /bin/bash

opencv_dnn's People

Contributors

jennaehnot avatar rolker avatar valschmidt avatar

Watchers

 avatar  avatar  avatar  avatar

opencv_dnn's Issues

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.