Skip to content

Tracking (JavaScript)

Tracking

Scripting Name:Insight.Tracking

管理底层 AR 算法返回的跟踪数据。

Static Properties


faceResultJsonString

type : string

(只读)获得面部识别结果的 JSON 字符串。

gestureResultJsonString

type : string

(只读)获得手势识别结果的 JSON 字符串。

quadCount

type : number

(只读)获得 AR 识别平面个数。

reason

type : number

(只读)获得 AR 跟踪失败时的错误信息编号。

status

type : number

(只读)获得当前 AR 跟踪状态。

type

type : number

(只读)获得当前 AR 跟踪类型。

cloudLocationStatus

type : number

(只读)获得云定位的识别状态。

0:默认值

1:云定位正常,成功

16:云定位失败

10000+:客户端或服务器问题,errorCode+10000,errorCode 有可能为负数

其他:算法问题

cloudLocationReason

type : string

(只读)获得云定位的识别状态描述,一般处理 Error 情况。

cloudLocationTotalCount

type : number

(只读)获得云定位的请求总计数。

Static Methods


EstimateIllumination

javascript
public static boolean EstimateIllumination(number type);

获得真实相机(手机摄像头)中光照信息的估算值。

Parameters

  • type : number 算法类型,type=0 表示在线光照恢复算法,type=1 表示离线光照恢复算法 返回值为算法是否成功的标识位。

⚠️ 目前版本只支持离线光照恢复算法,不支持在线光照恢复算法。

[注解] 调用该方法后,场景中的主光源和主相机中的光照恢复信息会被更新,可以调用 Camera:EstimationSphericalHarmonicIntensity()获得球谐光照强度的估算值,调用 Light:EstimationColor()获得主光源颜色的估算值,调用 Light:EstimationIntensity()获得主光源强度的估算值。

QuadGetCenter

javascript
public static Insight.Vector3 QuadGetCenter(string name);

根据 AR 识别平面的名称获得平面中心点坐标。

Parameters

  • name : string 识别平面的名称

QuadGetName

javascript
public static stirng QuadGetName(number index);

根据 AR 识别平面的编号获得平面名称。

Parameters

  • index : number 识别平面的编号

QuadGetRotation

javascript
public static Insight.Quaternion QuadGetRotation(string name);

根据 AR 识别平面的名称获得平面旋转信息。

Parameters

  • name : string 识别平面的名称

QuadGetScale

javascript
public static Insight.Vector3 QuadGetScale(string name);

根据 AR 识别平面的名称获得平面缩放信息。

Parameters

  • name : string 识别平面的名称

QuadGetValid

javascript
public static boolean QuadGetValid(string name);

根据 AR 识别平面的名称判断平面是否有效。

Parameters

  • name : string 识别平面的名称

Raycasting

javascript
public static Insight.TrackingResult Raycasting(number x, number y);

获得当前的跟踪信息。

Parameters

  • x : number 屏幕二维坐标点的 x,以像素为单位
  • y : number 屏幕二维坐标点的 y,以像素为单位 返回值类型参见 TrackingResult。

GetResultString

【已废弃】【已废弃】【请使用 OnRecongnizedTarget 】

javascript
public static string Insight.TrackingResult GetResultString(number type);

根据跟踪类型获得当前的跟踪信息。

Parameters

  • type : 跟踪类型 返回值** json字符串** TRACKING_RESULT_STRING_FACE_JSON = 0, TRACKING_RESULT_STRING_GESTURE_JSON = 1, TRACKING_RESULT_STRING_OBJECT_JSON = 2, TRACKING_RESULT_STRING_QRCODE_JSON =3, TRACKING_RESULT_STRING_ARCODE_JSON = 4, TRACKING_RESULT_STRING_2DIMAGE_JSON =5, TRACKING_RESULT_STRING_BODY_JSON = 6, TRACKING_RESULT_STRING_COUNT =7,

OnRecongnizedTarget

javascript
public static void OnRecongnizedTarget(DuktapeObject arg0,DuktapeObject arg1);

获取非挂起子事件的识别结果事件

Parameters

  • type : 跟踪类型
  • string 值 "InsightARClassifiedTypeQRCode" "InsightARClassifiedTypeARCode" "InsightARClassifiedType2dImage" "InsightARClassifiedTypeObject" "InsightARClassifiedTypeFace" "InsightARClassifiedTypeGesture" "InsightARClassifiedTypeBody" "InsightARClassifiedTypeFaceUnity"

示例调用:

javascript
Insight.Tracking.OnRecongnizedTarget( this, this.OnRecongnizedTarget);

示例回调方法:

javascript
OnRecongnizedTarget: function( type, result ){
 Insight.Debug.Log("js OnRecongnizedTarget " + type + ", " + result);
}

GetCurrentAREngine

javascript
public static int GetCurrentAREngine();

返回当前大场景算法正在运行的算法类型

示例调用:

javascript
Insight.Debug.Log("js CurrentAREngine " + Insight.Tracking.GetCurrentAREngine());

返回值:int

javascript
enum AREngines_Type { 
 NONE_SUPPORTED = 0, 
 INSIGHT_AR = 1, 
 ARCORE = 2, 
 ARKIT = 4, 
 HUAWEI_AR = 8, 
 }