三行代码,接入所有能力
-- 截图并识别所有文字
Import "TE.lua"
TE.socr_start("你的授权key")
snapshot("/sdcard/screen.png", 0, 0, 720, 1280)
Dim result = TE.socr("/sdcard/screen.png")
Dim tab = TE.JsonToTable(result)
If tab And tab["success"] = True Then
For Each item In tab["data"]
TracePrint "文字: " & item["text"]
TracePrint "坐标: " & item["left"] & "," & item["top"]
Next
End If
-- 找图并点击
Import "TE.lua"
TE.socr_start("你的授权key")
snapshot("/sdcard/screen.png", 0, 0, 720, 1280)
Dim result = TE.socr_opencv("/sdcard/screen.png", _
"/sdcard/button.png", 0.85)
Dim tab = TE.JsonToTable(result)
If tab And tab["success"] = True And tab["count"] > 0 Then
Dim m = tab["data"](0)
Tap (m["left"] + m["right"]) / 2, _
(m["top"] + m["bottom"]) / 2
End If
-- 检测画面中的物体
Import "TE.lua"
TE.socr_start("你的授权key")
snapshot("/sdcard/screen.png", 0, 0, 720, 1280)
Dim result = TE.socr_yolo("/sdcard/screen.png", _
Array("person", "phone"), 0.4)
Dim tab = TE.JsonToTable(result)
If tab And tab["success"] = True And tab["found"] = True Then
For Each cls In tab["data"]
For Each obj In cls.Value
Dim xy = obj["center"]
Tap xy(0), xy(1)
Next
Next
End If