forked from dolfly/termux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cameraInfo.go
43 lines (37 loc) · 1.03 KB
/
cameraInfo.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
package termux
import (
"bytes"
"encoding/json"
)
// CameraInfoPiece represent the info of one camera on the device
type CameraInfoPiece struct {
ID string `json:"id"`
Facing string `json:"facing"`
JPEGOutputSizes []struct {
Width int `json:"width"`
Height int `json:"height"`
} `json:"jpeg_output_sizes"`
FocalLengths []float64 `json:"focal_lengths"`
AEModes []string `json:"auto_exposure_modes"`
PhysicalSize struct {
Width float64 `json:"width"`
Height float64 `json:"height"`
} `json:"physical_size"`
Capabilities []string `json:"capabilities"`
}
// CameraInfo gets the information of available cameras on the device
func CameraInfo() ([]CameraInfoPiece, error) {
buf := bytes.NewBuffer([]byte{})
if err := exec(nil, buf, "CameraInfo", nil, ""); err != nil {
return nil, err
}
res := buf.Bytes()
if err := checkErr(res); err != nil {
return nil, err
}
records := make([]CameraInfoPiece, 0)
if err := json.Unmarshal(res, &records); err != nil {
return nil, err
}
return records, nil
}