-
Notifications
You must be signed in to change notification settings - Fork 867
/
asyncarray.go
53 lines (43 loc) · 925 Bytes
/
asyncarray.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
//go:build openvino
// +build openvino
package gocv
import (
"errors"
)
/*
#include <stdlib.h>
#include "dnn.h"
#include "asyncarray.h"
#include "core.h"
*/
import "C"
type AsyncArray struct {
p C.AsyncArray
}
// NewAsyncArray returns a new empty AsyncArray.
func NewAsyncArray() AsyncArray {
return newAsyncArray(C.AsyncArray_New())
}
// Ptr returns the AsyncArray's underlying object pointer.
func (a *AsyncArray) Ptr() C.AsyncArray {
return a.p
}
// Get async returns the Mat
func (m *AsyncArray) Get(mat *Mat) error {
result := C.AsyncArray_GetAsync(m.p, mat.p)
err := C.GoString(result)
if len(err) > 0 {
return errors.New(err)
}
return nil
}
// newAsyncArray returns a new AsyncArray from a C AsyncArray
func newAsyncArray(p C.AsyncArray) AsyncArray {
return AsyncArray{p: p}
}
// Close the AsyncArray object.
func (a *AsyncArray) Close() error {
C.AsyncArray_Close(a.p)
a.p = nil
return nil
}