Add Swap Memory
$ sudo apt-get install zram-config
$ sudo gedit /usr/bin/init-zram-swapping
Replace the line:
mem=$(((totalmem / 2 / ${NRDEVICES}) * 1024))
with this line:
mem=$(((totalmem / ${NRDEVICES}) * 1024))
And then reboot.
Install Opencv 4.1
1. Updating the packages:
$ sudo apt update
$ sudo apt install -y build-essential cmake git libgtk2.0-dev pkg-config libswscale-dev libtbb2 libtbb-dev
$ sudo apt install -y python-dev python3-dev python-numpy python3-numpy
$ sudo apt install -y curl
2. Install video & image formats:
$ sudo apt install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
$ sudo apt install -y libavcodec-dev libavformat-dev
$ sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
$ sudo apt install -y libv4l-dev v4l-utils qv4l2 v4l2ucp libdc1394-22-dev
3. Download OpenCV & Contribs Modules:
$ curl -L https://github.com/opencv/opencv/archive/4.1.0.zip -o opencv-4.1.0.zip
$ curl -L https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -o opencv_contrib-4.1.0.zip
4. Unzipping packages:
$ unzip opencv-4.1.0.zip
$ unzip opencv_contrib-4.1.0.zip
$ cd opencv-4.1.0/
5. Create directory:
$ mkdir release
$ cd release/
6. Build Opencv using Cmake:
cmake -D WITH_CUDA=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules \
-D WITH_GSTREAMER=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python2=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local ..
7. Compile the OpenCV with Contribs Modules:
$ make -j4
$ sudo make install
The installation is now completed.
> 제대로 설치되었는지 확인
$ pkg-config --modversion opencv
$ pkg-config --libs --cflags opencv
> 가상환경이 아닌 곳에서는 정상 실행되지만 가상환경에서는 정상실행이 안됨. 그럴때 아래 2번까지만 진행했을때 정상적으로 동작확인.
1. Try search opencv4.pc and notice the location of the file (usr/lib/aarch64-linux-gnu/pkgconfig/)
2. Then rename it to opencv.pc
3. Add `export PKG_CONFIG_PATH=/path/to/` to .bashrc so terminal recognized it.
'OS & Tools > Linux' 카테고리의 다른 글
[Jetson_nano] virtualenvwrapper (0) | 2020.02.18 |
---|---|
[ubuntu 16.04] anaconda,tensorflow-gpu,opencv 등 설치 (0) | 2020.02.04 |
[ubuntu 16.04] CUDA & CuDNN 설치 (1) | 2020.02.04 |
[ubuntu 16.04] GTX 1660Ti 드라이버 설치 및 듀얼 모니터 설정 (1) | 2020.02.04 |
[ubuntu 16.04] 나의 데스크탑 사양 및 파티션 설정 (0) | 2020.02.04 |