树莓派Ubuntu24.04配置opencv
时间: 2024-12-27 21:32:22 浏览: 3
树莓派(Raspberry Pi)上安装Ubuntu 24.04并配置OpenCV通常涉及几个步骤:
1. 更新系统和安装基本依赖:
```bash
sudo apt update
sudo apt upgrade
sudo apt install -y software-properties-common python-software-properties
```
2. 添加Ubuntu宇宙软件仓库(如果你没有添加过):
```bash
sudo add-apt-repository universe
```
3. 安装支持包和Git:
```bash
sudo apt install -y git build-essential cmake libudev-dev swig libssl-dev
```
4. 下载并安装最新版本的OpenCV:
```bash
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout tags/4.7.0
mkdir build
cd build
cmake -DWITH_CUDA=OFF -DBUILD_opencv_python=ON ..
make -j$(nproc)
sudo make install
```
5. 配置Python环境:
```bash
sudo apt-get install python3-pip
pip3 install numpy
pip3 install opencv-python-headless
```
6. 检查安装是否成功:
```bash
python3 -c "import cv2; print(cv2.__version__)"
```
阅读全文