-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera_global.go
47 lines (40 loc) · 974 Bytes
/
camera_global.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
package gopylon
/*
#include "camera.h"
*/
import "C"
import "fmt"
func PylonInitialize() {
C.CPylonInitialize()
}
func PylonTerminate() {
C.CPylonTerminate()
}
type Cameras []Camera
func (cameras *Cameras) EnumerateDevices() error {
var num C.size_t
res := C.CPylonEnumerateDevices(&num)
if C.GENAPI_E_OK != res {
return fmt.Errorf("%d", res)
}
fmt.Printf("num is : %d \n", int(num))
for i := 0; i < int(num); i++ {
c := Camera{index: i}
c.GetDeviceInfo()
res := C.CPylonCreateDeviceByIndex(C.ulong(c.index), &(c.HDev))
if C.GENAPI_E_OK != res {
C.CPrintError(res)
return fmt.Errorf("%d", res)
}
*cameras = append(*cameras, c)
}
return nil
}
// char* errMsg;
// size_t length;
// /* Retrieve the error message.
// ... First find out how big the buffer must be, */
// GenApiGetLastErrorMessage( NULL, &length );
// errMsg = (char*) malloc( length );
// /* ... and retrieve the message. */
// GenApiGetLastErrorMessage( errMsg, &length );