OpenCV 3.4x on BananaPi

From Banana Pi Wiki
Revision as of 23:31, 30 August 2018 by Sinovoip (talk | contribs)
Jump to: navigation, search

Using Python To Install OpenCV 3.4x on Banana Pi M2P(H3)

  • Install OpenCV 3.4x on Banana Pi M2P(H3) we use Banana Pi BPI-M2+ to this test.I will show you how to install OpenCV on BPI M2P(H3) in this thread.


  • Step 1: Install Dependency Packages**
apt-get update
apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
apt-get install build-essential cmake pkg-config libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev v4l-utils libxvidcore-dev libx264-dev ffmpeg
apt-get install libgtk2.0-dev libatlas-base-dev gfortran python2.7-dev python3-dev checkinstall
  • Step 2 : Download OpenCV Code
git clone --branch 3.4.0
git clone --branch 3.4.0
  • Step 3 : cmake OpenCV Code
cd <path>/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release  -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON_INCLUDE_DIR=/usr/bin/python -D OPENCV_EXTRA_MODULES_PATH=<path>/opencv_contrib/modules ..


  • Step 4 : Using python to test camera


import numpy as np
import cv2
cap = cv2.VideoCapture(1) #/dev/video1
   # Capture frame-by-frame
   ret, frame =
   # Our operations on the frame come here
   #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
   # Display the resulting frame
   if cv2.waitKey(1) & 0xFF == ord('q'):
# When everything done, release the capture

    • FAQ:**
  • If you meet problem like this:


  • replace "/usr/bin/python" by "/usr/bin/python2.7" Or use "ln -s /usr/bin/python2.7 /usr/bin/python"