-
Notifications
You must be signed in to change notification settings - Fork 863
/
persistence_filenode.go
84 lines (67 loc) · 1.82 KB
/
persistence_filenode.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package gocv
/*
#include <stdlib.h>
#include "persistence.h"
*/
import "C"
import "unsafe"
type FileNodeType int
const (
FileNodeTypeNone FileNodeType = 0
FileNodeTypeInt FileNodeType = 1
FileNodeTypeReal FileNodeType = 2
FileNodeTypeFloat FileNodeType = FileNodeTypeReal
FileNodeTypeStr FileNodeType = 3
FileNodeTypeString FileNodeType = FileNodeTypeStr
FileNodeTypeSeq FileNodeType = 4
FileNodeTypeMap FileNodeType = 5
FileNodeTypeTypeMask FileNodeType = 7
FileNodeTypeFlow FileNodeType = 8
FileNodeTypeUniform FileNodeType = 8
FileNodeTypeEmpty FileNodeType = 16
FileNodeTypeNamed FileNodeType = 32
)
// FileNode is a wrapper for the OpenCV FileNode class
//
// Ref: https://docs.opencv.org/4.x/de/dd9/classcv_1_1FileNode.html
type FileNode struct {
p C.FileNode
}
func (fn *FileNode) Empty() bool {
return bool(C.FileNode_Empty(fn.p))
}
func (fn *FileNode) IsInt() bool {
return bool(C.FileNode_IsInt(fn.p))
}
func (fn *FileNode) IsMap() bool {
return bool(C.FileNode_IsMap(fn.p))
}
func (fn *FileNode) IsNamed() bool {
return bool(C.FileNode_IsNamed(fn.p))
}
func (fn *FileNode) IsNone() bool {
return bool(C.FileNode_IsNone(fn.p))
}
func (fn *FileNode) IsReal() bool {
return bool(C.FileNode_IsReal(fn.p))
}
func (fn *FileNode) IsSeq() bool {
return bool(C.FileNode_IsSeq(fn.p))
}
func (fn *FileNode) IsString() bool {
return bool(C.FileNode_IsString(fn.p))
}
func (fn *FileNode) Keys() []string {
c_keys_count := C.FileNode_KeysCount(fn.p)
c_keys := C.FileNode_Keys(fn.p)
defer C.FileNode_KeysFree(c_keys, c_keys_count)
keys := make([]string, int(c_keys_count))
c_keys_slice := unsafe.Slice(c_keys, c_keys_count)
for i := 0; i < int(c_keys_count); i++ {
keys[i] = C.GoString(c_keys_slice[i])
}
return keys
}
func (fn *FileNode) Close() {
C.FileNode_Close(fn.p)
}