opencv에서 gstreamer 빌드

bong·2024년 11월 12일

ubuntu

목록 보기
2/2

gstreamer 관련 패키지 설치

sudo apt update
sudo apt install -y build-essential cmake git pkg-config libgtk-3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

opencv와 opencv_contrib 모듈 로드

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

빌드 디렉토리 생성

cd opencv
mkdir build
cd build

python3에서 사용할 수 있도록 cmake 명령 설정

cmake -D CMAKE_BUILD_TYPE=Release \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
      -D WITH_GSTREAMER=ON \
      -D WITH_FFMPEG=ON \
      -D PYTHON3_EXECUTABLE=$(which python3) \
      -D PYTHON3_INCLUDE_DIR=$(python3 -c "from sysconfig import get_paths as gp; print(gp()['include'])") \
      -D PYTHON3_LIBRARY=$(python3 -c "from sysconfig import get_paths as gp; print(gp()['stdlib'])") \
      -D PYTHON3_PACKAGES_PATH=$(python3 -c "from sysconfig import get_paths as gp; print(gp()['purelib'])") \
      ..

빌드 진행 후 설치

make -j$(nproc)
sudo make install

OpenCV 설치가 완료된 후, Python에서 GStreamer 지원이 활성화되었는지 확인
GStreamer: YES 표시되면 설치 완료

import cv2
print(cv2.getBuildInformation())
profile
늅늅

0개의 댓글