合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
Qualifier and Type | Field and Description |
|---|---|
public static final int | AR可追踪对象信息。 |
public static final int | AR Engine SDK版本信息。 |
Constructor Name |
|---|
public ARSession(Context context) 创建与Application context绑定的Session。 |
Qualifier and Type | Method Name and Description |
|---|---|
void | addServiceListener(ServiceListener listener) 添加事件监听器。 |
void | configure(ARConfigBase config) 配置session。service通过修改config中的启用项EnableItem适配设备支持的选项。应用使用config.getEnableItem()检查对应的设置项,以便获取当前Session的启用项。 |
createAnchor(ARPose pose) 使用pose创建一个持续跟踪的锚点。 | |
Collection<ARAnchor> | 获取所有锚点,包括TrackingState为PAUSED、TRACKING和STOPPED。应用处理时需要仅绘制TRACKING状态的锚点,删除STOPPED状态的锚点。 |
Collection<ARPlane> | 获取所有检测到的平面,如果ARConfigBase.PlaneFindingMode为DISABLED,则返回空。 注意 该方法已废弃,请使用getAllTrackables()。 |
<T extends ARTrackable> Collection<T> | getAllTrackables(Class<T> filterType) 获取所有指定类型的可跟踪对像集合,使用方法如:Collection<ARPlane> allFaces = mSession.getAllTrackables(ARPlane.class)获取所有跟踪到的平面。 |
| 返回当前Session对应的相机配置实例。 | |
void | getProjectionMatrix(float[] dest, int offset, float near, float far) 返回投影矩阵,该矩阵用于在相机预览的图像中渲染虚拟物体和平面。 注意 该方法已废弃,请使用ARCamera上的对应接口。 |
int | 获取支持的语义识别模式,可同时支持多种模式,如同时支持平面和目标语义模式,则返回3,即SEMANTIC_PLANE | SEMANTIC_TARGET。 |
boolean | isSupported(ARConfig config) 注意 该方法已废弃。目前该函数仅返回true。 |
void | pause() 暂停AR Engine ,停止相机预览流,不清除平面和锚点数据,释放相机(否则其他应用无法使用相机服务),不会断开与服务端的连接。调用后需要使用resume()恢复。 |
void | removeAnchors(Collection<ARAnchor> anchors) 删除anchors中的锚点,请使用ARAnchor.detach()单独删除。 注意 该方法已废弃,无替代。 |
void | resume() |
void | resume(ARConfig config) 根据config恢复session,有两种使用场景:启动服务和服务被暂停后重启。注意:调用了ARSession.stop()之后,该方法不能恢复。 注意 该方法已废弃,请使用resume()方法,不支持在session pause以后重新修改config。 |
void | setCameraTextureName(int textureId) 设置可用于存储相机预览流数据的openGL textureId,应用调用ARSession.update()后,AR Engine会更新相机预览到纹理textureId中。textureId使用时需要指定为GL_TEXTURE_EXTERNAL_OES,如:GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId)。 |
void | setCloudServiceAuthInfo(String authInfo) 2D云识别和3D云识别需设置云服务特性所需的认证参数,字符串格式为Json,包含modelName、 appId和appSecret。 |
void | setDisplayGeometry(float width, float height) 设置显示的高和宽(以像素为单位)。该高和宽是显示view的高和宽,如果不一致,会导致显示相机预览出错。 注意 该方法已废弃,请使用setDisplayGeometry(int displayRotation, int widthPx, int heightPx)替换。 |
void | setDisplayGeometry(int displayRotation, int widthPx, int heightPx) 设置显示界面的旋转角度、宽和高。 |
void | setEnvironmentTextureProbe(float[] arBoundBox) 设置环境纹理探针。AR Engine Server 3.15及以后版本可用。 作用:设置虚拟物体在世界坐标系下的空间包围盒,包围盒采用AABB形式,float[]{xmin, ymin, zmin, xmax, ymax, zmax}。 |
void | setEnvironmentTextureUpdateMode(EnvironmentTextureUpdateMode textureUpdateMode) 设置环境纹理更新模式。AR Engine Server 3.15及以后版本可用。 |
void | stop() 停止AR Engine,停止相机预览流,清除平面和锚点数据,并释放相机,终止本次会话。调用后,如果要再次启动,需要新建ARSession。 |
update() 更新AR Engine的计算结果,应用应在需要获取最新的数据时调用此接口,如相机发生移动以后,使用此接口可以获取新的锚点坐标、平面坐标、相机获取的图像帧等。如果ARConfigBase.UpdateMode为BLOCKING,那么该函数会阻塞至有新的帧可用。 |
Field |
|---|
public static final int AR_TRACKABLE_OBJECT AR可追踪对象信息。该常量AR Engine Server 3.11及以后可用。 另请参阅:Constant-values |
Field |
|---|
public static final int CURRENT_SDK_VERSIONCODE AR Engine SDK版本信息。 另请参阅:Constant-values |
Constructor |
|---|
public ARSession(Context context) 创建与context绑定的session,AR Engine SDK内部使用context读取包内资源文件。对于普通应用,请传入Application context,对于插件应用,传入插件对应的context。 |
Parameters
Name | Description |
|---|---|
context | 当前应用的上下文信息。 |
Throws
Name | Description |
|---|---|
设备上没有安装AR Engine Service。 | |
设备上安装的AR Engine Service版本过旧,与SDK版本不符。 | |
应用使用的SDK版本过旧,与AR Engine Service版本不符。 |
Method |
|---|
public void addServiceListener(ServiceListener listener) 添加事件监听器。该方法AR Engine Server 3.11及以后可用。 |
Parameters
Name | Description |
|---|---|
listener | 事件监听器。 |
Method |
|---|
public void configure(ARConfigBase config) 配置session。 注意 由于设备能力差异,在调用该函数后,config中的启用项EnableItem会被service尝试修改成设备支持的选项。应用需要在调用此接口后使用config.getEnableItem()检查对应的设置项以便获取当前Session的启用项。 |
Parameters
Name | Description |
|---|---|
config | session配置信息。 |
Throws
Parameters
Name | Description |
|---|---|
pose | 创建锚点时使用的pose信息。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | pose参数为空。 |
设备资源不足,创建锚点失败。 |
Returns
Type | Description |
|---|---|
创建的锚点。 |
Method |
|---|
public Collection<ARAnchor> getAllAnchors() 获取所有锚点,包括TrackingState为PAUSED,TRACKING和STOPPED。应用处理时需要仅绘制TRACKING状态的锚点,删除STOPPED状态的锚点。 |
Returns
Type | Description |
|---|---|
Collection<ARAnchor> | 所有锚点集合。 |
该方法已废弃,请使用getAllTrackables()。
Method |
|---|
public Collection<ARPlane> getAllPlanes() 获取所有检测到的平面,如果ARConfigBase.PlaneFindingMode为DISABLED,则返回空。 |
Returns
Type | Description |
|---|---|
Collection<ARPlane> | 所有检测到的平面。 |
Method |
|---|
public <T extends ARTrackable> Collection<T> getAllTrackables(Class<T> filterType) 获取所有指定类型的可跟踪对像集合,使用方法如:Collection<ARPlane> allFaces = mSession.getAllTrackables(ARPlane.class)获取所有跟踪到的平面。 |
Parameters
Name | Description |
|---|---|
filterType | 需要获取类型。 |
Returns
Type | Description |
|---|---|
<T extends ARTrackable> Collection<T> | 指定类型的可跟踪对象集合。 |
Method |
|---|
public ARCameraConfig getCameraConfig() 返回当前Session对应的相机配置实例。 |
Returns
Type | Description |
|---|---|
当前Session对应的相机配置实例。 |
该方法已废弃,请使用ARCamera上的对应接口。
Method |
|---|
public void getProjectionMatrix(float[] dest, int offset, float near, float far) 返回投影矩阵,该矩阵用于在相机预览的图像中渲染虚拟物体和平面。dest为存放矩阵的数组,offset为初始偏移,near为近裁剪面的距离,far为远裁剪面的距离(单位为米)。 |
Parameters
Name | Description |
|---|---|
dest | 获取得到的投影矩阵。 |
offset | 存放在dest中数据的初始偏移。 |
near | 近裁剪面距离,以米为单位。 |
far | 远裁剪面距离,以米为单位。 |
Method |
|---|
public int getSupportedSemanticMode() 获取支持的语义识别模式,可同时支持多种模式,如同时支持平面和目标语义模式,则返回3,即SEMANTIC_PLANE | SEMANTIC_TARGET。 |
Returns
Type | Description |
|---|---|
int | 语义识别模式,返回值可以是:SEMANTIC_NONE、SEMANTIC_PLANE、SEMANTIC_TARGET。 |
该方法已废弃。目前该函数仅返回true。
Method |
|---|
public boolean isSupported(ARConfig config) |
Parameters
Name | Description |
|---|---|
config | 需要检查的配置信息。 |
Returns
Type | Description |
|---|---|
boolean | 设备是否支持:
|
Method |
|---|
public void pause() 暂停AR Engine,停止相机预览流,不清除平面和锚点数据,释放相机(否则其他应用无法使用相机服务),不会断开与服务端的连接。调用后需要使用resume()恢复。 |
Throws
Name | Description |
|---|---|
致命错误,session没有创建或已经释放。 |
该方法已废弃,无替代。
Method |
|---|
public void removeAnchors(Collection<ARAnchor> anchors) 删除anchors中的锚点,请使用ARAnchor.detach()单独删除。 |
Parameters
Name | Description |
|---|---|
anchors | 需要删除的锚点信息。 |
Throws
Name | Description |
|---|---|
致命错误,session没有创建或已经释放。 |
Method |
|---|
public void resume(ARConfig config) 根据config恢复session,有两种使用场景:启动服务和服务被暂停后重启。 |
Parameters
Name | Description |
|---|---|
config | 恢复session时使用的配置信息。 |
Throws
Name | Description |
|---|---|
当前应用没有相机权限。 | |
传入的config不支持。 |
Method |
|---|
public void setCameraTextureName(int textureId) 设置可用于存储相机预览流数据的openGL textureId,应用调用ARSession.update()后,AR Engine会更新相机预览到纹理textureId中。textureId使用时需要指定为GL_TEXTURE_EXTERNAL_OES,如:GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId)。 |
Parameters
Name | Description |
|---|---|
textureId | 相机预览数据流的openGL textureId。 |
Method |
|---|
public void setCloudServiceAuthInfo(String authInfo) 2D云识别和3D云识别需设置云服务特性所需的认证参数。该方法AR Engine Server 3.11及以后可用。 |
Parameters
Name | Description |
|---|---|
authInfo | 云服务特性所需的认证参数,是JSON字符串,由modelName、appId和appSecret构成形如{"modelName": "xxx","appId": "xxx","appSecret": "xxx"}的格式。
|
该方法已废弃,请使用setDisplayGeometry(int displayRotation, int widthPx, int heightPx)替换。
Method |
|---|
public void setDisplayGeometry(float width, float height) 设置显示的高和宽(以像素为单位)。该高和宽是显示view的高和宽,如果不一致,会导致显示相机预览出错。 |
Parameters
Name | Description |
|---|---|
width | 显示的宽度。 |
height | 显示的高度。 |
Method |
|---|
public void setDisplayGeometry(int displayRotation, int widthPx, int heightPx) 设置显示界面的旋转角度、宽和高。 |
Parameters
Name | Description |
|---|---|
displayRotation | 旋转角度。 |
widthPx | 显示的宽度。 |
heightPx | 显示的高度。 |
Method |
|---|
public void setEnvironmentTextureProbe(float[] arBoundBox) 设置环境纹理探针。 作用:设置虚拟物体在世界坐标系下的空间包围盒,包围盒采用AABB形式,float[]{xmin, ymin, zmin, xmax, ymax, zmax}。 用于EnvironmentTexture。 只接受一个,取最后一次放置的虚拟物生效 |
Parameters
Name | Description |
|---|---|
arBoundBox | AABB(轴对齐包围盒),定义AABB的数据按照(xmin, ymin, zmin, xmax, ymax, zmax)的顺序排布,每6个数值表示一个AABB。长方体包围盒左下角坐标和右上角坐标。 |
Method |
|---|
public void setEnvironmentTextureUpdateMode(EnvironmentTextureUpdateMode textureUpdateMode) 设置环境纹理更新模式。 |
Parameters
Name | Description |
|---|---|
textureUpdateMode | 环境纹理更新模式。 |
Method |
|---|
public void stop() 停止AR Engine,停止相机预览流,清除平面和锚点数据,并释放相机,终止本次会话。调用后,如果要再次启动,需要新建ARSession。 |
Method |
|---|
public ARFrame update() 更新AR Engine的计算结果,应用应在需要获取最新的数据时调用此接口,如相机发生移动以后,使用此接口可以获取新的锚点坐标、平面坐标、相机获取的图像帧等。如果ARConfigBase.UpdateMode为BLOCKING,那么该函数会阻塞至有新的帧可用。 |
Throws
Name | Description |
|---|---|
当前线程没有GL上下文。 | |
在调用update方法前没有调用setCameraTextureName()设置接收相机预览流的纹理。 |
Returns
Type | Description |
|---|---|
AR Engine系统的快照。 |