Skip to content

Commit

Permalink
OpenCV 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chong Yoe Yat committed Oct 19, 2020
1 parent 4f292f9 commit 74634dd
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 7 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# OpenCV 4.3.0 For Raspberry Pi 4 Python 2 and 3
# OpenCV 4.5.0 For Raspberry Pi 3 and 4 Python 2 and 3

Raspbian Buster 10 Pre built OpenCV 4.3.0
Raspbian Buster 10 Pre built OpenCV 4.5.0
Turned on compile flags TBB NEON VFPV3

# Installation Step

wget https://github.com/cyysky/OpenCV-Raspberry-Pi-4-Package-for-Python/raw/master/opencv_4.3.0-1_armhf.deb
wget https://github.com/cyysky/OpenCV-Raspberry-Pi-4-Package-for-Python/raw/master/opencv_4.5.0-1_armhf.deb

sudo dpkg -i opencv_4.3.0-1_armhf.deb # This will install fail for dependency
sudo dpkg -i opencv_4.5.0-1_armhf.deb # This will install fail for dependency

sudo apt-get -f install # Auto install dependency package

sudo dpkg -i opencv_4.3.0-1_armhf.deb # Now start install

sudo apt-get install tesseract-ocr # Optional : tesseract-ocr
sudo dpkg -i opencv_4.5.0-1_armhf.deb # Now start install

#if have import issue https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi/issues/67

Expand Down
51 changes: 51 additions & 0 deletions StepForBuilding/4.5.0/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -ex

OPENCV_VERSION=4.5.0
pushd ~/opencv/opencv-$OPENCV_VERSION
mkdir -p build
pushd build
RPI_VERSION=$(awk '{print $3}' < /proc/device-tree/model)
if [[ $RPI_VERSION -ge 4 ]]; then
NUM_JOBS=$(nproc)
else
NUM_JOBS=1 # Earlier versions of the Pi don't have sufficient RAM to support compiling with multiple jobs.
fi

# -D ENABLE_PRECOMPILED_HEADERS=OFF
# is a fix for https://github.com/opencv/opencv/issues/14868

# -D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic
# is a fix for https://github.com/opencv/opencv/issues/15192

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-$OPENCV_VERSION/modules \
-D OPENCV_ENABLE_NONFREE=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_DOCS=ON \
-D BUILD_EXAMPLES=ON \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D BUILD_TIFF=ON \
-D WITH_FFMPEG=ON \
-D WITH_TBB=ON \
-D BUILD_TBB=ON \
-D WITH_OPENMP=ON \
-D ENABLE_NEON=ON \
-D ENABLE_LTO=ON \
-D WITH_OPENCL=ON \
-D WITH_GSTREAMER=ON \
-D CPU_BASELINE=NEON \
-D ENABLE_VFPV3=ON \
-D WITH_OPENGL=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_QT=ON \
-D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic \
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON_EXECUTABLE=$(which python2) \
..
#make -j "$NUM_JOBS"
popd; popd
12 changes: 12 additions & 0 deletions StepForBuilding/4.5.0/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -ex

OPENCV_VERSION=4.5.0
cd ~
mkdir -p opencv && pushd opencv

wget -O "opencv-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz"
wget -O "opencv_contrib-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.tar.gz"
tar -xvf "opencv-${OPENCV_VERSION}.tar.gz"
tar -xvf "opencv_contrib-${OPENCV_VERSION}.tar.gz"
popd
35 changes: 35 additions & 0 deletions StepForBuilding/4.5.0/stepfor4.5.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
./download-opencv.sh

sudo nano /etc/dphys-swapfile
#set CONF_SWAPSIZE=100 to 512 with the Nano text editor
sudo dphys-swapfile setup
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start


# checkinstall to make debian package https://www.theimpossiblecode.com/blog/build-faster-opencv-raspberry-pi3/
# checkinstall bug https://github.com/opencv/opencv/issues/8897
git clone https://github.com/giuliomoro/checkinstall
cd checkinstall
sudo make install

./build-opencv.sh

make
checkinstall --install=no --pkgname=opencv --pkgversion=4.5.0 --provides=opencv --nodoc --backup=no --exclude=$HOME --requires="devscripts,debhelper,cmake,libldap2-dev,libgtkmm-3.0-dev,libarchive-dev,libcurl4-openssl-dev,intltool,build-essential,cmake,pkg-config,libjpeg-dev,libtiff5-dev,libjasper-dev,libavcodec-dev,libavformat-dev,libswscale-dev,libv4l-dev,libxvidcore-dev,libx264-dev,libgtk2.0-dev,libgtk-3-dev,libatlas-base-dev,libblas-dev,libeigen2-dev,libeigen3-dev,liblapack-dev,gfortran,python2.7-dev,python3-dev,python-pip,python3-pip,python,python3,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,libavresample-dev,libavresample4-dbgsym,libavresample4,qt5-default,tesseract-ocr,libtesseract-dev,libleptonica-dev,libglu1-mesa-dev,freeglut3-dev,mesa-common-dev,liblapacke-dev,libopenblas-dev,libopenblas-base,libgoogle-glog-dev,protobuf-compiler,caffe-cpu"

#Debian package
sudo dpkg -i opencv_4.5.0-1_armhf.deb
sudo apt-get -f install
sudo dpkg -i opencv_4.5.0-1_armhf.deb

# Python 3 Check
python3
import cv2

# Python 2 Check
python
import cv2



Binary file added opencv_4.5.0-1_armhf.deb
Binary file not shown.

0 comments on commit 74634dd

Please sign in to comment.