forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuda.cpp
121 lines (96 loc) · 2.21 KB
/
cuda.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "cuda.h"
GpuMat GpuMat_New() {
return new cv::cuda::GpuMat();
}
GpuMat GpuMat_NewFromMat(Mat mat) {
return new cv::cuda::GpuMat(*mat);
}
GpuMat GpuMat_NewWithSize(int rows, int cols, int type) {
return new cv::cuda::GpuMat(rows, cols, type);
}
void GpuMat_Upload(GpuMat m, Mat data, Stream s){
if (s == NULL) {
m->upload(*data);
return;
}
m->upload(*data, *s);
}
void GpuMat_Download(GpuMat m, Mat dst, Stream s){
if (s == NULL) {
m->download(*dst);
return;
}
m->download(*dst, *s);
}
int GpuMat_Empty(GpuMat m){
return m->empty();
}
void GpuMat_Close(GpuMat m){
delete m;
}
void PrintCudaDeviceInfo(int device){
cv::cuda::printCudaDeviceInfo(device);
}
void PrintShortCudaDeviceInfo(int device){
cv::cuda::printShortCudaDeviceInfo(device);
}
int GetCudaEnabledDeviceCount(){
return cv::cuda::getCudaEnabledDeviceCount();
}
int GetCudaDevice() {
return cv::cuda::getDevice();
}
void SetCudaDevice(int device) {
cv::cuda::setDevice(device);
}
void ResetCudaDevice(){
cv::cuda::resetDevice();
}
void GpuMat_ConvertTo(GpuMat m, GpuMat dst, int type, Stream s) {
if (s == NULL) {
m->convertTo(*dst, type);
return;
}
m->convertTo(*dst, type, *s);
}
void GpuMat_ConvertToWithParams(GpuMat m, GpuMat dst, int type, float alpha, float beta, Stream s) {
if (s == NULL) {
m->convertTo(*dst, type, alpha, beta);
return;
}
m->convertTo(*dst, type, alpha, beta, *s);
}
void GpuMat_CopyTo(GpuMat m, GpuMat dst, Stream s) {
if (s == NULL) {
m->copyTo(*dst);
return;
}
m->copyTo(*dst, *s);
}
GpuMat GpuMat_Reshape(GpuMat m, int cn, int rows) {
return new cv::cuda::GpuMat(m->reshape(cn, rows));
}
int GpuMat_Cols(GpuMat m) {
return m->cols;
}
int GpuMat_Rows(GpuMat m) {
return m->rows;
}
int GpuMat_Channels(GpuMat m) {
return m->channels();
}
int GpuMat_Type(GpuMat m) {
return m->type();
}
Stream Stream_New() {
return new cv::cuda::Stream();
}
void Stream_Close(Stream s){
delete s;
}
bool Stream_QueryIfComplete(Stream s) {
return s->queryIfComplete();
}
void Stream_WaitForCompletion(Stream s) {
s->waitForCompletion();
}