Code Monkey home page Code Monkey logo

picameratesting's Introduction

PiCameraTesting

Objectives

The objectives of this project are as follows:

  1. Identify the algorithms needed to perform human detection and tracking
  2. Test the feasbility of using these algorithms on the Raspberry Pi platform

The algorithms are implemented in Python using the OpenCV library.

Requirements

  • Hardware
    • Raspberry Pi
    • PiCamera
    • USB Camera (optional)
  • Software
    • OpenCV 3.2.0 and above
    • Python 3.4 and above (tested with up to Python 3.6.1)

Installing Python3 and OpenCV on Raspbian Wheezy/Jessie

Raspbian Wheezy

Because python3 available on the repository is Python 3.2, it is strongly recommended to compile at least Python 3.4 (3.6 recommended) from source and install it on the Pi.

Python 3.6

sudo apt-get update
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar xzvf Python-3.6.1.tgz
cd Python-3.6.1
./configure
make -j4
sudo make altinstall 

If any of the packages cannot be found, try a newer version number.

Virtualenv

It is highly recommended to use virtualenv to manage Python environments.

sudo pip3.6 install virtualenv virtualenvwrapper

Open ~/.profile using one's preferred editior and add in the following lines at the bottom of the file.

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

After saving and exiting, use source ~/.profile to load the changes made.

mkvirtualenv humanDetection -p python3.6
workon humanDetection

All work will be performed inside the humanDetection python virtual environment.

OpenCV

cd ~
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 3.2.0
cd ~
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout 3.2.0

It is very important that both opencv and opencv_contrib are on the same version.

workon humandetection
pip install numpy "picamera[array]" imutils
cd ~/opencv
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..

It is important to check the output of cmake to ensure that the Python interpreter point to the Python binary and the numpy points to the numpy install. If it doesn't point properly, delete the build folder and reinstall numpy. Afterwhich perform cmake again.

make -j4
sudo make install
sudo ldconfig
cd /usr/local/lib/python3.6/site-packages/
sudo mv cv2.cpython-36m-arm-linux-gnueabihf.so cv2.so
cd ~/virtualenvs/humanDetection/lib/python3.6/site-packages
ln -s /usr/local/lib/python3.6/site-packages/cv2.so cv2.so

Test the install by import cv2 inside the python interpreter. If it doesnt throw an error, cv2.__version__ and observe the output.

Test that the PiCamera is working properly using raspistill -o output.jpg.

Adapted from [http://www.pyimagesearch.com/2015/07/27/installing-opencv-3-0-for-both-python-2-7-and-python-3-on-your-raspberry-pi-2/]

picameratesting's People

Watchers

M Rubern Chakravarthi 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.