自动识别页面
<h3>概述</h3>
<p>在自动识别书本页面的识别步骤。</p>
<h3>1.在onCreate()中首先设定机型</h3>
<p><strong>(自定义名称的机型名称,统一与玩瞳售后沟通进行机型适配,对该机型进行书本识别支持)</strong></p>
<pre><code class="language-java"> com.visiontalk.vtloginsdk.utils.DeviceUtils.getInstance().setCustomDeviceBrand(&quot;huawei_mate50_plus&quot;);</code></pre>
<p><strong>备注:</strong></p>
<h3>2.在onResume()中进行识别SDK初始化</h3>
<pre><code class="language-java"> private int[] cameraSize = new int[]{640, 480};
mVTBRSDKManager = new VTBRSDKManager(context, cameraSize[0], cameraSize[1],
new CameraCallback() {
@Override
public void onCameraDisconnected() {
L.e(&quot; &gt;&gt; onCameraDisconnected&quot;);
// MyToast.getInstance().showToast(context, &quot;摄像头连接断开~&quot;);
cameraState = TypeUtil.CameraState.CLOSE.getFunction();
}
@Override
public void onCameraError(int error) {
L.e(&quot; &gt;&gt; onCameraError error: %s&quot;, error);
// MyToast.getInstance().showToast(context, &quot;摄像头运行异常~&quot;);
cameraState = TypeUtil.CameraState.CLOSE.getFunction();
}
@Override
public void getCamera1(Camera camera1) {
}
});
mVTBRSDKManager.setICameraPreviewCallback(null);//重置掉,如果有需要则在后面再设置
openCameraCallback = null;//重置掉
mNetMonitor = new NetworkMonitor(context);
mAppAudioTips = new AppAudioTips();
mRecognizeAudioTips = new RecognizeAudioTips();
mBookPredictTips = new BookPredictTips();
mRecognizeAudioTips.setPlayType(0);
//
mVTBRSDKManager.init();
mVTBRSDKManager.setFingerDetectListener(iFingerDetectListener);
mVTBRSDKManager.setRecognizeListener(iRecognizeListener);
mVTBRSDKManager.setStateDetectListener(iStateDetectListener);
//
mNetMonitor.registerNetMonitor(iNetworkStateCallback);
UdidType udidType = UdidType.valueOf(BuildConfig.UDID_TYPE);
VTBRConfigure.setUdidType(udidType);
// VTBRConfigure.setFingerHighLoc(true);//本地相机支持高清库
VTBRConfigure.setFingerHighLoc(false);//本地相机暂不支持高清库
BaseConfig.getInstance().setPlayMode(PlayMode.MODE_ONLINE);
PlayMode.setPlayMode(PlayMode.MODE_ONLINE);</code></pre>
<h4>2.1 对识别sdk进行设定预览画布</h4>
<p>接着进行设置camera预览画布VTTextureView</p>
<p><strong>事例代码:</strong></p>
<pre><code class="language-java"> private VTTextureView textureView;
public void setTextureView(Context context, VTTextureView textureView) {
textureView.setSurfaceTextureCallback(surfaceTextureCallback);
this.textureView = textureView;
if (getVTBRSDKManager() != null &amp;&amp; getVTBRSDKManager().getCameraCtrl(context) != null)
getVTBRSDKManager().getCameraCtrl(context).setTextureView(this.textureView);
}
</code></pre>
<h4>2.2 初始化License</h4>
<p>内部license登录</p>
<p><strong>事例代码:</strong></p>
<pre><code class="language-java">
public void initializeLicense(String license) {
if (mVTBRSDKManager != null)
mVTBRSDKManager.initialize(license, iInitializeListener);
}
</code></pre>
<h4>2.3 License初始化回调成功后,则进行打开Camera操作</h4>
<p>可设置是否立即开启识别</p>
<p><strong>事例代码:</strong></p>
<pre><code class="language-java">
@Override
public void onInitSuccess() {
openCamera(false);
}
public void openCamera(int cameraId, boolean isResume) {
if (mVTBRSDKManager != null)
mVTBRSDKManager.openCamera();
if (isStartRecognize) {//是否开启识别
startRecognize();
}
cameraState = TypeUtil.CameraState.OPEN.getFunction();
}
public void startRecognize() {
if (mVTBRSDKManager != null) {
mVTBRSDKManager.startRecognize();
}
}
</code></pre>