Difference between revisions of "OpenCV 3.4x on BananaPi"

From Banana Pi Wiki
Jump to: navigation, search
(Created page with "Using Python To Install OpenCV 3.4x on Banana Pi M2P(H3) **Install OpenCV 3.4x on Banana Pi M2P(H3)** ![image|614x499](upload://xBjBsoWjXC6wOa7XMddbYEp93yL.jpg) I will show...")
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Using Python To Install OpenCV 3.4x on Banana Pi M2P(H3)
 
Using Python To Install OpenCV 3.4x on Banana Pi M2P(H3)
  
**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.
![image|614x499](upload://xBjBsoWjXC6wOa7XMddbYEp93yL.jpg)
 
  
I will show you how to install OpenCV on BPI M2P(H3) in this thread.
+
[[File:Opencv1.jpg]]
  
**Step 1: Install Dependency Packages**
 
  
* apt-get update
+
*Step 1: Install Dependency Packages**
* 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**
+
apt-get update
* git clone https://github.com/opencv/opencv.git --branch 3.4.0
+
apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler
* git clone https://github.com/opencv/opencv_contrib.git --branch 3.4.0
+
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 3 : cmake OpenCV Code**
+
*Step 2 : Download 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 ..
 
  
![image|661x500](upload://ft8wrCupWdg9YhhcKkQyjzypdO2.png)
+
git clone https://github.com/opencv/opencv.git --branch 3.4.0
 +
git clone https://github.com/opencv/opencv_contrib.git --branch 3.4.0
  
**Step 4 : Using python to test camera**
+
*Step 3 : cmake OpenCV Code
* python readvideo.py
 
  
  <a class="attachment" href="/uploads/default/original/2X/5/5a6d7d8a9134c8467a6a7adf1267c01035e2bd62.py">readvideo.py</a> (441 字节)
+
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 ..
  
**FAQ:**
+
[[File:Opencv_2.png]]
* If you meet problem like this:
 
![image|539x195](upload://8hJMnyFnqIOGeUSI0QiPLzuRMF0.png)
 
  
* replace "/usr/bin/python" by "/usr/bin/python2.7" Or use "ln -s /usr/bin/python2.7 /usr/bin/python"
+
*Step 4 : Using python to test camera
 +
 
 +
python readvideo.py
 +
 
 +
import numpy as np
 +
import cv2
 +
cap = cv2.VideoCapture(1) #/dev/video1
 +
 
 +
while(True):
 +
    # Capture frame-by-frame
 +
    ret, frame = cap.read()
 +
 
 +
    # Our operations on the frame come here
 +
    #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
 +
    # Display the resulting frame
 +
    cv2.imshow('frame',frame)
 +
    if cv2.waitKey(1) & 0xFF == ord('q'):
 +
        break
 +
 
 +
# When everything done, release the capture
 +
cap.release()
 +
cv2.destroyAllWindows()
 +
 
 +
 
 +
*FAQ:
 +
If you meet problem like this:
 +
 
 +
[[File:Opencv3.png]]
 +
 
 +
replace "/usr/bin/python" by "/usr/bin/python2.7" Or use "ln -s /usr/bin/python2.7 /usr/bin/python"
 +
 
 +
Forum pthread:
 +
 
 +
http://forum.banana-pi.org/t/using-python-to-install-opencv-3-4x-on-banana-pi-m2p-h3/6657
 +
 
 +
=Documents=
 +
 
 +
Banana Pi BPI-M2 Zero with OpenCV :https://bluexmas.tistory.com/category/OS/Banana%20Pi%20%EF%BC%8FBPI-Bit?page=2

Latest revision as of 17:59, 2 April 2019

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.

Opencv1.jpg


  • 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 https://github.com/opencv/opencv.git --branch 3.4.0
git clone https://github.com/opencv/opencv_contrib.git --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 ..

Opencv 2.png

  • Step 4 : Using python to test camera

python readvideo.py

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


  • FAQ:

If you meet problem like this:

Opencv3.png

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

Forum pthread:

http://forum.banana-pi.org/t/using-python-to-install-opencv-3-4x-on-banana-pi-m2p-h3/6657

Documents

Banana Pi BPI-M2 Zero with OpenCV :https://bluexmas.tistory.com/category/OS/Banana%20Pi%20%EF%BC%8FBPI-Bit?page=2