Giter VIP home page Giter VIP logo

opencv-gpu-py's Introduction

Python OpenCV GPU Face Detection

Python wrapper for GPU CascadeClassifier, should work with OpenCV 2 and 3. Will fall back to CPU CascadeClassifier if CUDA isn't installed, but if the CPU version enough, just use stock OpenCV Python.

Installation

First install CUDA.

On Debian/Ubuntu, after downloading the .deb provided by NVIDIA:

sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb # Filename will vary
sudo apt-get update && sudo apt-get install cuda
echo "export CUDA_HOME=/usr/local/cuda-7.5" >> ~/.bashrc
echo "export PATH=$PATH:$CUDA_HOME/bin" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64" >> ~/.bashrc

Build/install OpenCV 3 from source:

sudo apt-get update && sudo apt-get install -y \
    build-essential cmake git libgtk2.0-dev pkg-config \
    libavcodec-dev libavformat-dev libswscale-dev python-dev \
    python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev
git clone https://github.com/Itseez/opencv
mkdir opencv/build && cd opencv/build
# Build OpenCV 2.4 instead of 3:
# mkdir opencv/build && cmake opencv && git checkout 2.4 && cd build
cmake .. && make -j$(nproc) && sudo make install

Install opencv-gpu-py:

git clone https://github.com/alexanderkoumis/opencv-gpu-py
pip install --user -e opencv-gpu-py

Test:

cd opencv-gpu-py
python test/test.py

Usage

# Full example in test/test.py
import cv2gpu

if cv2gpu.is_cuda_compatible():
    cv2gpu.init_gpu_detector('cascade_frontalface_cpu.xml')
else:
    cv2gpu.init_cpu_detector('cascade_frontalface_gpu.xml')

for (x, y, w, h) in cv2gpu.find_faces('image.jpg'):
    # Do something with face rectangle

opencv-gpu-py's People

Contributors

alexanderkoumis avatar

Watchers

 avatar James Cloos 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.