玩瞳文档中心


SDK拓展接口

<h2>1. 概述</h2> <p>SDK拓展接口是针对一些特殊需求所开放的接口,例如授权码获取license、用户反馈等。该部分的接口入口类为 <strong>basesdk</strong> 中的 <strong>VTBaseSDKManagerExt</strong> 。</p> <h2>2. 接口说明</h2> <h3>1. 获取VTBaseSDKManagerExt实例</h3> <p><strong>接口名称:</strong></p> <pre><code class="language-java">public static VTBaseSDKManagerExt getInstance()</code></pre> <h3>2. initialize接口</h3> <p>获取到 <strong>VTBaseSDKManagerExt</strong> 实例后,需要调用该接口初始化后,才能调用后续的接口。</p> <pre><code class="language-java">public void initialize(Context context)</code></pre> <p><strong>参数:</strong></p> <table> <thead> <tr> <th>参数名</th> <th>说明</th> <th>类型</th> </tr> </thead> <tbody> <tr> <td>context</td> <td>Context,不能为NULL</td> <td>Context</td> </tr> </tbody> </table> <h3>3. 授权码获取license</h3> <p>通过该接口可通过授权码获取对应的license</p> <p><strong>接口名称:</strong></p> <pre><code class="language-java">public void getLicense(String code, QRCodeAuthCallback callback)</code></pre> <p><strong>参数:</strong></p> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>code</td> <td>String</td> <td>授权license</td> </tr> <tr> <td>QRCodeAuthCallback</td> <td>QRCodeAuthCallback</td> <td>回调</td> </tr> </tbody> </table> <h4>3.1 QRCodeAuthCallback</h4> <pre><code class="language-java">public interface QRCodeAuthCallback { /** * 授权码认证成功 * * @param license license */ void onQRCodeAuthSuccess(String license); /** * 授权码认证失败 * * @param code 错误码 * @param errMsg 错误信息 */ void onQRCodeAuthFail(int code, String errMsg); }</code></pre> <h3>4. 用户反馈</h3> <p>该接口为用户反馈接口,当不识别某本书的时候,可通过该接口将设备的相机预览的帧数据反馈给玩瞳。</p> <p><strong>接口名称:</strong></p> <pre><code class="language-java">public void userFeedback(byte[] data, FeedbackCallback callback)</code></pre> <p><strong>参数:</strong></p> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>code</td> <td>byte[]</td> <td>授权license</td> </tr> <tr> <td>callback</td> <td>FeedbackCallback</td> <td>回调</td> </tr> </tbody> </table> <p><strong>备注:</strong></p> <p>相机预览帧数据的图像格式一般为yuv NV21,在此前需将数据转换成Jpeg数据再上传。样例代码可参考如下:</p> <pre><code class="language-java">/** * 将NV21数据转换成JPEG数据 * * @param nv21Data 原始数据 * @param width 相机预览宽度 * @param height 相机预览高度 * @return JPEG数据流 */ private byte[] convertNv21ToJpeg(byte[] nv21Data, int width, int height) { YuvImage image = new YuvImage(nv21Data, ImageFormat.NV21, width, height, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compressToJpeg(new android.graphics.Rect(0, 0, image.getWidth(), image.getHeight()), 100, baos); return baos.toByteArray(); }</code></pre> <h4>4.1 FeedbackCallback</h4> <pre><code class="language-java">public interface FeedbackCallback { /** * 反馈成功 */ void onFeedbackSuccess(); /** * 反馈失败 * * @param code 错误码 * @param errMsg 错误信息 */ void onFeedbackFail(int code, String errMsg); }</code></pre>

页面列表

ITEM_HTML