opencv build from source - jenhaoyang/ml_blog GitHub Wiki

##opencv4 似乎沒有opencv.pc !! 可以嘗試opencv3

git clone https://github.com/opencv/opencv.git
git checkout 3.4.16

cd opencv
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D INSTALL_C_EXAMPLES=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D WITH_V4L=ON \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D WITH_FFMPEG=ON \
      -D BUILD_EXAMPLES=ON ..

make -j4
sudo make install
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

參考:
https://github.com/AlexeyAB/darknet/issues/4256#issuecomment-551630438