-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample3.cpp
74 lines (55 loc) · 1.58 KB
/
example3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Try OpenCV func example
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/cuda.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudafilters.hpp>
#include <opencv2/cudabgsegm.hpp>
#include <opencv2/cudaobjdetect.hpp>
#include <opencv2/cudaoptflow.hpp>
#include <opencv2/cudastereo.hpp>
#include <opencv2/cudafeatures2d.hpp>
#include <iostream>
// Open up the webcam
cv::VideoCapture cap(0);
int main(int argc, char** argv)
{
if (!cap.isOpened()) {
std::cerr << "Camera open failed!\n";
return -1;
}
// Print GPU info
cv::cuda::printCudaDeviceInfo(0);
// Setup variables and matrices
cv::Mat img;
cv::cuda::GpuMat imgGpu, mat;
std::vector<cv::cuda::GpuMat> gpuMats;
while(cap.isOpened()) {
cap >> img;
imgGpu.upload(img);
// Core operations
// 그레이 스케일로 변경
cv::cuda::cvtColor(imgGpu, imgGpu, cv::COLOR_BGR2GRAY);
// 회전 90도
cv::cuda::transpose(imgGpu, imgGpu);
// 3채널로 분해
//cv::cuda::split(imgGpu, gpuMats);
//std::cout << gpuMats.size() << std::endl;
// Do the operations
// 스플릿 한거 합치기
//cv::cuda::merge(gpuMats, imgGpu);
// Elements wise operations
// 채널 제한
//cv::cuda::threshold(imgGpu, imgGpu, 100, 255, cv::THRESH_BINARY);
// Matrix operations
// 정규화
//cv::cuda::normalize(imgGpu, imgGpu, 0, 1, cv::NORM_MINMAX, CV_32F);
imgGpu.download(img);
cv::imshow("Image", img);
if(cv::waitKey(1) == 'q') break;
}
cap.release();
return 0;
}