# opencv_example **Repository Path**: hanlt/opencv_example ## Basic Information - **Project Name**: opencv_example - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: public - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-11-19 - **Last Updated**: 2024-11-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 构建 1. 从源码编译OpenCV ``` $ git clone https://github.com/opencv/opencv.git $ cmake -G Ninja -S opencv -B opencv/build -DCMAKE_INSTALL_PREFIX=opencv/build/install $ ninja -C opencv/build install ``` 2. 从源码编译Google Benchmark ``` $ git clone https://github.com/google/benchmark.git $ cmake -G Ninja -S benchmark -DCMAKE_BUILD_TYPE=Release -B benchmark/build -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON $ ninja -C benchmark/build ``` 3. 编译本项目 ``` $ git clone https://gitee.com/hanlt/opencv_example.git $ cmake -G Ninja -S opencv_example -DCMAKE_BUILD_TYPE=Release -B opencv_example/build -DOpenCV_DIR= -Dbenchmark_DIR= $ ninja -C opencv_example/build ``` ## 测试 可执行程序位于 `opencv_example/build`目录中: - contours 边缘检测 - gary 灰度化 - qrcode 二维码检测 - remap 仿射变换 - smooth 高斯模糊 示例: ``` $ cd opencv_example $ ./build/smooth ---------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------- GaussianBlur 178 ms 154 ms 4 BM_imread 72.1 ms 72.1 ms 10 BM_GaussianBlur 48.3 ms 39.8 ms 19 BM_imwrite 34.7 ms 34.5 ms 21 ``` 分别表示GaussianBlur的总执行时间以及imread、GaussianBlur核心运算和imwrite的执行时间