Skip to content

Commit a4d08d3

Browse files
committed
pkg-config
1 parent 32ada66 commit a4d08d3

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

ch02-安装OpenCV/安装OpenCV后验证.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
##安装OpenCV后验证
22

3+
- pkg-config
4+
```bash
5+
pkg-config --modversion opencv
6+
3.3.0
7+
```
8+
39
```python
410
import cv2
511
print(cv2.getBuildInformation())
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# 使用CUDA进行GPU加速
2+
3+
- 参考
4+
- [Compiling OpenCV with CUDA support](https://www.pyimagesearch.com/2016/07/11/compiling-opencv-with-cuda-support/)
5+
- [CUDA文档](https://opencv.org/platforms/cuda.html)
6+
7+
- 验证安装
8+
```python
9+
import cv2
10+
print(cv2.getBuildInformation())
11+
#Use Cuda: YES (ver 8.0)
12+
#表示成功
13+
```
14+
- 代码C++
15+
```cython
16+
#include <iostream>
17+
#include "opencv2/opencv.hpp"
18+
#include "opencv2/gpu/gpu.hpp"
19+
20+
int main (int argc, char* argv[])
21+
{
22+
try
23+
{
24+
cv::Mat src_host = cv::imread("file.png", CV_LOAD_IMAGE_GRAYSCALE);
25+
cv::gpu::GpuMat dst, src;
26+
src.upload(src_host);
27+
28+
cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);
29+
30+
cv::Mat result_host;
31+
dst.download(result_host);
32+
33+
cv::imshow("Result", result_host);
34+
cv::waitKey();
35+
}
36+
catch(const cv::Exception& ex)
37+
{
38+
std::cout << "Error: " << ex.what() << std::endl;
39+
}
40+
return 0;
41+
}
42+
```
43+
- 编译
44+
-

0 commit comments

Comments
 (0)