wsl2 ubuntu22.04安装opencv
时间: 2023-09-06 09:09:06 浏览: 399
要在WSL2 Ubuntu 22.04上安装OpenCV 4.5.4,可以按照以下步骤进行操作:
1. 首先,确保你的系统已经安装了WSL2,并且已经成功安装了Ubuntu 22.04。
2. 打开终端,并更新系统的软件包列表,可以运行以下命令:
```
sudo apt update
```
3. 接下来,安装OpenCV的依赖项。运行以下命令:
```
sudo apt install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
```
4. 然后,安装OpenCV的额外依赖项。运行以下命令:
```
sudo apt install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
```
5. 下载OpenCV 4.5.4的源代码。可以使用Git进行克隆,运行以下命令:
```
git clone https://github.com/opencv/opencv.git
```
6. 进入下载好的OpenCV目录,创建一个build文件夹,并进入该文件夹。运行以下命令:
```
cd opencv
mkdir build
cd build
```
7. 使用CMake进行配置。运行以下命令:
```
cmake ..
```
8. 编译和安装OpenCV。运行以下命令:
```
make -j$(nproc)
sudo make install
```
9. 最后,验证OpenCV是否成功安装。你可以编写一个简单的C++程序,使用OpenCV库进行图像处理,并编译运行该程序。
这样,你就成功在WSL2 Ubuntu 22.04上安装了OpenCV 4.5.4。希望对你有帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [ubuntu22.04安装OpenCV及Opencvcontrib,cuda,cudnn,pytorch](https://blog.csdn.net/rotga/article/details/132080966)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [【环境配置】Windows 11 的 WSL(Ubuntu2204) 安装OpenCV 4.5.4 (亲测有效)](https://blog.csdn.net/zhoujinwang/article/details/127741366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文