From cc0de22cc3a7b6d869f0d15aa85ac6f22265211c Mon Sep 17 00:00:00 2001 From: ZockerKatze Date: Fri, 28 Feb 2025 17:58:44 +0100 Subject: [PATCH] minor fix --- build_opencv_windows.bat | 86 ++++++++++++++++++++++++++++++++++++++++ fedora_setup.sh | 44 ++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 build_opencv_windows.bat create mode 100644 fedora_setup.sh diff --git a/build_opencv_windows.bat b/build_opencv_windows.bat new file mode 100644 index 0000000..6df4d39 --- /dev/null +++ b/build_opencv_windows.bat @@ -0,0 +1,86 @@ +@echo off +setlocal enabledelayedexpansion + +:: Check for CUDA installation +where nvcc >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo CUDA not found! Please install CUDA toolkit first. + echo Download from: https://developer.nvidia.com/cuda-downloads + exit /b 1 +) +echo Found CUDA installation: +nvcc --version + +:: Check for GPU +nvidia-smi >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo No NVIDIA GPU found or drivers not installed! + exit /b 1 +) +echo Found GPU: +nvidia-smi -L + +:: Create build directory +if not exist "opencv_build" mkdir opencv_build +cd opencv_build + +:: Clone OpenCV and OpenCV contrib if they don't exist +if not exist "opencv" ( + git clone https://github.com/opencv/opencv.git + cd opencv + git checkout 4.8.0 + cd .. +) + +if not exist "opencv_contrib" ( + git clone https://github.com/opencv/opencv_contrib.git + cd opencv_contrib + git checkout 4.8.0 + cd .. +) + +:: Create and enter build directory +cd opencv +if not exist "build" mkdir build +cd build + +:: Configure OpenCV build with CMake +cmake -G "Visual Studio 17 2022" -A x64 ^ + -D CMAKE_BUILD_TYPE=RELEASE ^ + -D CMAKE_INSTALL_PREFIX=C:/opencv_cuda ^ + -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ^ + -D WITH_CUDA=ON ^ + -D WITH_CUDNN=OFF ^ + -D OPENCV_DNN_CUDA=ON ^ + -D ENABLE_FAST_MATH=1 ^ + -D CUDA_FAST_MATH=1 ^ + -D WITH_CUBLAS=1 ^ + -D WITH_TBB=ON ^ + -D WITH_OPENGL=ON ^ + -D BUILD_opencv_world=ON ^ + -D BUILD_opencv_python3=ON ^ + -D OPENCV_ENABLE_NONFREE=ON ^ + -D INSTALL_PYTHON_EXAMPLES=OFF ^ + -D INSTALL_C_EXAMPLES=OFF ^ + -D BUILD_EXAMPLES=OFF ^ + -D PYTHON3_EXECUTABLE=%USERPROFILE%\AppData\Local\Programs\Python\Python39\python.exe ^ + -D PYTHON3_INCLUDE_DIR=%USERPROFILE%\AppData\Local\Programs\Python\Python39\include ^ + -D PYTHON3_LIBRARY=%USERPROFILE%\AppData\Local\Programs\Python\Python39\libs\python39.lib ^ + -D PYTHON3_NUMPY_INCLUDE_DIRS=%USERPROFILE%\AppData\Local\Programs\Python\Python39\Lib\site-packages\numpy\core\include ^ + .. + +:: Build OpenCV (adjust -j flag based on your CPU cores) +cmake --build . --config Release -j 8 + +:: Install +cmake --install . + +:: Add OpenCV to Python path +set PYTHONPATH=C:\opencv_cuda\python;%PYTHONPATH% + +echo. +echo Build complete! Please add C:\opencv_cuda\python to your PYTHONPATH +echo and ensure C:\opencv_cuda\x64\vc17\bin is in your PATH +echo. +echo You may need to restart your Python IDE for changes to take effect. +pause \ No newline at end of file diff --git a/fedora_setup.sh b/fedora_setup.sh new file mode 100644 index 0000000..1590dae --- /dev/null +++ b/fedora_setup.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Install basic development tools +sudo dnf groupinstall -y "Development Tools" +sudo dnf install -y cmake git pkg-config + +# Install Qt5 +sudo dnf install -y qt5-qtbase-devel qt5-qtmultimedia-devel + +# Install CUDA (if not already installed) +# First, add NVIDIA repository +sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/fedora37/x86_64/cuda-fedora37.repo +sudo dnf clean all +# Install CUDA +sudo dnf module disable -y nvidia-driver +sudo dnf install -y cuda + +# Install OpenCV dependencies +sudo dnf install -y \ + ffmpeg-devel \ + libavcodec-devel \ + libavformat-devel \ + libswscale-devel \ + libv4l-devel \ + xvidcore-devel \ + x264-devel \ + libjpeg-turbo-devel \ + libpng-devel \ + libtiff-devel \ + gtk3-devel \ + atlas-devel \ + gcc-gfortran \ + python3-devel \ + python3-numpy \ + openblas-devel + +# Optional: Install additional multimedia codecs +sudo dnf install -y \ + https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ + https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + +sudo dnf install -y \ + ffmpeg \ + ffmpeg-devel \ No newline at end of file