Skip to content

Commit

Permalink
[DOC] update install opencv guide in demo doc
Browse files Browse the repository at this point in the history
  • Loading branch information
seanxcwang committed Apr 26, 2021
1 parent afef21a commit 491dfc8
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 4 deletions.
46 changes: 44 additions & 2 deletions doc/cn/user/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,28 @@ NDK 22和23在链接第三方动态库可能会出错,例如opencv,hiai,
##### Linux
* 环境要求
- Cmake (>=3.11)
- OpenCV3, 可在CMake中通过find_package(OpenCV 3) 成功找到依赖项。
- OpenCV3 (只有webcam的demo会用), 可在CMake中通过find_package(OpenCV 3) 成功找到依赖项。

```
// 手动编译OpenCV3
wget https://github.com/opencv/opencv/archive/3.4.13.zip
unzip 3.4.13.zip
cd opencv-3.4.13
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j4
make install
// 在CMakeList.txt的find_packpage之前添加OpenCV路径
// 例如,进入examples/linux/x86,打开CMakeList.txt
// 在find_package(OpenCV 3 REQUIRED)之前添加
set(OpenCV_DIR <path_to_opencv>/opencv-3.4.13/install/share/OpenCV)
```

* 编译
进入 `examples/linux/x86` 目录,执行 `build_linux_native.sh``build_linux_openvino.sh`。前者使用TNN实现的优化X86后端执行,后者基于Intel OpenVINO后端执行。以`build_linux_native.sh`为例,默认仅编译处理图像的demo,如需编译基于摄像头的人脸配准demo,需要将`build_linux_native.sh`中的"-DTNN_DEMO_WITH_WEBCAM=OFF"修改为"-DTNN_DEMO_WITH_WEBCAM=ON":
```
Expand Down Expand Up @@ -267,7 +288,28 @@ NDK 22和23在链接第三方动态库可能会出错,例如opencv,hiai,
##### MacOS
* 环境要求
- Cmake (>=3.11)
- OpenCV3, 确保可在CMake中通过 `find_package(OpenCV 3)`找到, 可通过brew安装(```brew install opencv@3 && brew link --force opencv@3```)。如果安装brew安装失败,尝试opencv源码编译。
- OpenCV3 (只有webcam的demo会用), 确保可在CMake中通过 `find_package(OpenCV 3)`找到, 可通过brew安装(```brew install opencv@3 && brew link --force opencv@3```),如果失败可使用手动编译

```
// 手动编译OpenCV3
wget https://github.com/opencv/opencv/archive/3.4.13.zip
unzip 3.4.13.zip
cd opencv-3.4.13
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j4
make install
// 在CMakeList.txt的find_packpage之前添加OpenCV路径
// 例如,进入examples/mac/x86,打开CMakeList.txt
// 在find_package(OpenCV 3 REQUIRED)之前添加
set(OpenCV_DIR <path_to_opencv>/opencv-3.4.13/install/share/OpenCV)
```

* 编译
进入 `examples/mac/x86` 目录,执行 `build_macos_native.sh``build_macos_openvino.sh`。前者使用TNN实现的优化X86后端执行,后者基于Intel OpenVINO后端执行。以`build_macos_native.sh`为例,默认仅编译处理图像的demo,如需编译基于摄像头的人脸配准demo,需要将`build_macos_native.sh`中的"-DTNN_DEMO_WITH_WEBCAM=OFF"修改为"-DTNN_DEMO_WITH_WEBCAM=ON":
```
Expand Down
46 changes: 44 additions & 2 deletions doc/en/user/demo_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,28 @@ NDK 22 and 23 are not suggested, because they may report error when link third p
##### Linux
* Environment Requirements
- Cmake (>=3.11)
- OpenCV3, Can be imported in CMake by find_package(OpenCV 3)
- OpenCV3 (only used by webcam demo), Can be imported in CMake by find_package(OpenCV 3)

```
// Install OpenCV3 manually
wget https://github.com/opencv/opencv/archive/3.4.13.zip
unzip 3.4.13.zip
cd opencv-3.4.13
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j4
make install
// add OpenCV path before find_package in CMakeList.txt
// for example, move to examples/linux/x86, open CMakeList.txt
// add the following before find_package(OpenCV 3 REQUIRED)
set(OpenCV_DIR <path_to_opencv>/opencv-3.4.13/install/share/OpenCV)
```

* Compile
Move to `examples/linux/x86` directory and execute `build_linux_naitve.sh` or `build_linux_openvino.sh`. In the former case, TNN uses its optimized X86 backend to execute models, while the Intel OpenVINO backend is used in forward inference in the later case. Take `build_linux_native.sh` as an example, by default, only image demos will be compiled. If you want to compile the face alignmnt camera demo, you need to change the "-DTNN_DEMO_WITH_WEBCAM=OFF to "-DTNN_DEMO_WITH_WEBCAM=ON" in `build_linux_native.sh`:
```
Expand Down Expand Up @@ -271,7 +292,28 @@ NDK 22 and 23 are not suggested, because they may report error when link third p
##### MacOS
* Environment Requirements
- Cmake (>=3.11)
- OpenCV3, Can be imported in CMake by ```find_package(OpenCV 3)```. you can install opencv with brew (```brew install opencv@3 && brew link --force opencv@3```). If install failed, try to compile opencv with source code.
- OpenCV3 (only used by webcam demo), Can be imported in CMake by ```find_package(OpenCV 3)```. you can install opencv with brew (```brew install opencv@3 && brew link --force opencv@3```). If brew install failed, you can install opencv manually.

```
// Install OpenCV3 manually
wget https://github.com/opencv/opencv/archive/3.4.13.zip
unzip 3.4.13.zip
cd opencv-3.4.13
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
make -j4
make install
// add OpenCV path before find_package in CMakeList.txt
// for example, move to examples/linux/x86, open CMakeList.txt
// add the following before find_package(OpenCV 3 REQUIRED)
set(OpenCV_DIR <path_to_opencv>/opencv-3.4.13/install/share/OpenCV)
```

* Compile
Move to `examples/mac/x86` directory and execute `build_macos_native.sh` or `build_macos_openvino.sh`. In the former case, TNN uses its optimized X86 backend to execute models, while the Intel OpenVINO backend is used in forward inference in the later case. Take `build_macos_native.sh` as an example, by default, only image demos will be compiled. If you want to compile the face alignmnt camera demo, you need to change the "-DTNN_DEMO_WITH_WEBCAM=OFF to "-DTNN_DEMO_WITH_WEBCAM=ON" in `build_macos_native.sh`:
```
Expand Down

0 comments on commit 491dfc8

Please sign in to comment.