-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot.go
38 lines (32 loc) · 680 Bytes
/
screenshot.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
package main
import (
sdk "dahuaCamSDK"
"encoding/json"
"fmt"
"os"
)
func main() {
sdk, err := sdk.NewSDK()
if err != nil {
panic(err)
}
// 调用高安全级别登录函数
loginId, info, err := sdk.Login("112.240.143.194", 37777, "admin", "admin123")
if err != nil {
fmt.Println("Login failed:", err)
return
}
j, _ := json.Marshal(info)
fmt.Println(string(j))
b, err := sdk.ScreenShot(loginId, 0)
if err != nil {
fmt.Println("ScreenShot failed:", err)
}
err = os.WriteFile("screenshot.jpg", b, 0644)
if err != nil {
fmt.Println("WriteFile failed:", err)
}
if err := sdk.Logout(loginId); err != nil {
fmt.Println("Logout failed:", err)
}
}