-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgproc.go
70 lines (61 loc) · 1.78 KB
/
imgproc.go
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
package opencv
/*
#cgo linux pkg-config: opencv
#cgo darwin pkg-config: opencv
#include "cpp/imgproc/imgproc.h"
#include "stdlib.h"
*/
import "C"
import (
//"runtime"
"unsafe"
)
const (
CV_FILLED = C.CV_FILLED
)
/** Constants for color conversion */
const (
CV_BGR2GRAY = C.CV_BGR2GRAY
CV_BGR2HSV = C.CV_BGR2HSV
)
//Histograms
func CalcHist(images *Mat, nimages int, channels []int, mask *InputArray, hist *OutputArray, dims int, histSize []int, ranges [][]float32) {
c_ranges := C.makeFloatArray(C.int(len(ranges)))
defer C.freeFloatArray(c_ranges, C.int(len(ranges)))
for i, range_i := range ranges {
array := C.makeFloat(C.int(len(range_i)))
for ii, val := range range_i {
C.setFloat(array, C.float(val), C.int(ii))
}
C.setFloatArray(c_ranges, array, C.int(i))
}
C.calcHist(images.Pointer(),
C.int(nimages),
(*C.int)(unsafe.Pointer(&channels[0])),
mask.Pointer(), hist.Pointer(),
C.int(dims),
(*C.int)(unsafe.Pointer(&histSize[0])),
c_ranges)
}
func CalcHistWithSparseMat(images *Mat, nimages int, channels []int, mask *InputArray, hist *SparseMat, dims int, histSize []int, ranges [][]float32) {
c_ranges := C.makeFloatArray(C.int(len(ranges)))
defer C.freeFloatArray(c_ranges, C.int(len(ranges)))
for i, range_i := range ranges {
array := C.makeFloat(C.int(len(range_i)))
for ii, val := range range_i {
C.setFloat(array, C.float(val), C.int(ii))
}
C.setFloatArray(c_ranges, array, C.int(i))
}
C.calcHistWithSparseMat(images.Pointer(),
C.int(nimages),
(*C.int)(unsafe.Pointer(&channels[0])),
mask.Pointer(), hist.Poniter(),
C.int(dims),
(*C.int)(unsafe.Pointer(&histSize[0])),
c_ranges)
}
//Miscellaneous Image Transformations
func CvtColor(src *InputArray, dst *OutputArray, code int) {
C.cvtColor(src.Pointer(), dst.Pointer(), C.int(code))
}