实习日志10

1.用户信息

1.1.在用户管理中编辑用户信息

1.2.绑定公司id

1.3.显示在页面

2.修改识别逻辑

2.1.分析

先识别,再判断,清空键把识别结果清空

2.2.写码

修改了发票识别逻辑,略...

3.接高拍仪

3.1.js引入报错

分析:

遇到的错误表示不同版本的 jQuery 之间存在兼容性问题。具体来说,您在同一项目中同时使用 jQuery 1.4.4 和 jQuery 3.6.0,并且它们相互冲突。

可以采取以下步骤来解决问题:

  1. 使用单个版本的jQuery:理想情况下,您应该在整个项目中使用单个版本的 jQuery。选择 jQuery 1.4.4 或 jQuery 3.6.0,并确保所有脚本都使用相同的版本。

  2. 升级到兼容版本:如果可能,请考虑升级您的项目,以使用与您正在使用的特性和功能兼容的更新版本的 jQuery。使用较新版本的 jQuery 可能有助于避免兼容性问题。

  3. 脚本加载顺序:确保在依赖 jQuery 的任何其他脚本之前加载 jQuery。脚本加载的顺序至关重要,应首先加载 jQuery。

  4. 删除重复的 jQuery 实例:检查引入

错误“Uncaught TypeError: $.ajax is not a function表示“.ajax”函数未定义或不可用。此问题可能由于多种原因而发生,包括与其他库的潜在冲突或不正确的脚本加载顺序。

以下是排查和解决问题的一些步骤:

  1. 检查jQuery版本:
    确认您具有包含“$.ajax”函数的 jQuery 版本。根据您之前的消息,您使用的是 jQuery 3.6.0,它应该具有此功能。确保加载的 jQuery 版本没有问题。

  2. 装货顺序:
    验证脚本的加载顺序。jQuery 和其他依赖项应在使用它们的脚本之前加载。例如:

 <!-- 首先加载 jQuery --><script src=“path/to/jquery-3.6.0.min.js”></script><!-- 加载其他脚本,包括 gpyhs.js --><script src=“path/to/gpyhs.js”></script>
  1. 检查冲突:
    确保与其他可能覆盖或干扰 jQuery 的库或脚本没有冲突。某些库或插件可能彼此不兼容。

  2. 使用’jQuery’:可能与使用的其他库发生冲突。尝试将“gpyhs.js”文件中的“$”替换为“jQuery”,看看它是否解决了问题:
    ‘’'javascript
    jQuery.ajax({
    您的 ajax 配置在这里
    });

  3. jQuery 迁移:
    如果要升级 jQuery,请考虑使用 jQuery Migrate 插件。它可以帮助识别和解决使用较新版本的 jQuery 时的兼容性问题。

3.2.改了js文件,以适用于活字格

var socket;
var isSocketConnect = false;
var openFlagA = false;var isOpenMainCamera = false;var MainCanvas;
var MainContext;var pMainShowStartX = 0;
var pMainShowStartY = 0;var isMouseDown = false;
var pALastX = 0;
var pALastY = 0;
var pACurrentX = 0;
var pACurrentY = 0;var MainCamCutMode = 0;//window.onload = function (event) {
//    WebSocketConnect();
//}//>>>>>>>>>>>>>>>>.修改的地方>>>>>>>>>>>>>>>
function releaseSocketPro() {if (isSocketConnect) {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xFF;socket.send(aDataArray.buffer);}
}window.onbeforeunload = function () {CloseCamera();  //关闭摄像头isOpenMainCamera = false;try {releaseSocketPro();   //>>>>>>>>>>>>>>>>.修改的地方>>>>>>>>>>>>>>>socket.close();socket = null;}catch (ex) {}console.log("onbeforeunload");};//function CloseConnect() {
//    isSocketConnect = false;
//    CloseCamera();  //关闭摄像头
//    try {
//        releaseSocketPro();   //>>>>>>>>>>>>>>>>.修改的地方>>>>>>>>>>>>>>>
//        socket.close();
//        socket = null;
//    }
//    catch (ex) {
//    }
// }function jQuery$(id) {return document.getElementById(id);
}function toSleep(milliSeconds) {var startTime = new Date().getTime();while (new Date().getTime() < startTime + milliSeconds);
}function stringToUint8Array(str) {var arr = [];for (var i = 0, j = str.length; i < j; ++i) {arr.push(str.charCodeAt(i));}arr.push('\0');var tmpUint8Array = new Uint8Array(arr);return tmpUint8Array
}function Uint8ArrayToString(fileData) {var dataString = "";for (var i = 0; i < fileData.length; i++) {dataString += String.fromCharCode(fileData[i]);}return dataString
}function stringToByte(str) {var bytes = new Array();var len, c;len = str.length;for (var i = 0; i < len; i++) {c = str.charCodeAt(i);if (c >= 0x010000 && c <= 0x10FFFF) {bytes.push(((c >> 18) & 0x07) | 0xF0);bytes.push(((c >> 12) & 0x3F) | 0x80);bytes.push(((c >> 6) & 0x3F) | 0x80);bytes.push((c & 0x3F) | 0x80);} else if (c >= 0x000800 && c <= 0x00FFFF) {bytes.push(((c >> 12) & 0x0F) | 0xE0);bytes.push(((c >> 6) & 0x3F) | 0x80);bytes.push((c & 0x3F) | 0x80);} else if (c >= 0x000080 && c <= 0x0007FF) {bytes.push(((c >> 6) & 0x1F) | 0xC0);bytes.push((c & 0x3F) | 0x80);} else {bytes.push(c & 0xFF);}}return bytes;
}function byteToString(arr) {if (typeof arr === 'string') {return arr;}var str = '',_arr = arr;for (var i = 0; i < _arr.length; i++) {var one = _arr[i].toString(2),v = one.match(/^1+?(?=0)/);if (v && one.length == 8) {var bytesLength = v[0].length;var store = _arr[i].toString(2).slice(7 - bytesLength);for (var st = 1; st < bytesLength; st++) {store += _arr[st + i].toString(2).slice(2);}str += String.fromCharCode(parseInt(store, 2));i += bytesLength - 1;} else {str += String.fromCharCode(_arr[i]);}}return str;
}function addEvent(obj, xEvent, fn) {if (obj.attachEvent) {obj.attachEvent('on' + xEvent, fn);} else {obj.addEventListener(xEvent, fn, false);}
}function InitCanvas(DivMainBox, mX, mY, mwidth, mheight) {//var DivMainBox = jQuery$("CameraCtl");if (mwidth != 0 && mheight != 0) {MainCanvas = document.createElement("canvas");MainCanvas.style.border = "solid 1px #A0A0A0";MainCanvas.id = "MainCamCanvas";MainCanvas.width = mwidth;MainCanvas.height = mheight;MainContext = MainCanvas.getContext("2d");DivMainBox.appendChild(MainCanvas);      //添加画布MainCanvas.onmousedown = MainCanvasMouseDown;MainCanvas.onmousemove = MainCanvasMouseMove;MainCanvas.onmouseup = MainCanvasMouseUp;MainCanvas.onmouseout = MainCanvasMouseOut;addEvent(MainCanvas, 'mousewheel', onMouseWheel);addEvent(MainCanvas, 'DOMMouseScroll', onMouseWheel);}}//*************摄像头操作初始化***************
function Cam_ControlInit(documentObj, mX, mY, mwidth, mheight) {WebSocketConnect();InitCanvas(documentObj, mX, mY, mwidth, mheight);//console.log("Cam_ControlInit");
}//*************获取设备数目***************
function Cam_GetDevCount() {GetDevCount();
}//***************获取分辨率***************
function Cam_GetDevResolution(iCamNo) {GetResolution(iCamNo);
}//*************打开主摄像头***************function Cam_Open(iCamNo, width, height) {OpenCamera(iCamNo, width, height);}//*************关闭摄像头***************function Cam_Close() {CloseCamera();  isOpenMainCamera = false;}//*************拍照***************function Cam_Photo(fileAddr) {if (MainCamCutMode == 2) {var rectx, recty, rectw, recth;if (pALastX > pACurrentX)rectx = pACurrentX;elserectx = pALastX;if (pALastY > pACurrentY)recty = pACurrentY;elserecty = pALastY;rectw = Math.abs(pACurrentX - pALastX);recth = Math.abs(pACurrentY - pALastY);SetCutRect(rectx, recty, rectw, recth);  //手动裁剪区域}    CaptureImage(fileAddr);}//*************放大***************function Cam_ZoomIn() {ZoomIn();
}//*************缩小***************
function Cam_ZoomOut() {ZoomOut();
}//*************适合大小***************
function Cam_BestSize() {BestSize();
}//*************1:1***************
function Cam_TrueSize() {TrueSize();
}//*************旋转***************
function Cam_Rotate(angle) {Rotate(angle);
}//*************左旋***************
function Cam_RotateLeft() {RotateL();
}//*************右旋***************
function Cam_RotateRight() {RotateR();
}//*************对焦***************
function Cam_Focus() {ManualFocus();
}//*************设置视频属性***************
function Cam_ShowVideoProp() {ShowVideoProp();
}//*************设置裁剪模式***************
function Cam_SetCutMode( CutMode) {SetCutMode(CutMode);
}//*************读取身份证信息*************
function Cam_ReadIdCard(cardImgPath) {ReadIdCard(cardImgPath);
}//*************读取身份证信息并生成正反面合并证件照*************
function Cam_ReadIdCardEx(cardImgPath) {ReadIdCardEx(cardImgPath);
}//*************上传文件*************
function UploadFile(url, filepath) {toUploadFile(url, filepath);
}function UploadFileEx(lpServer, port, lpAddr, filepath) {toUploadFileEx(lpServer, lpAddr, port, filepath);
}//*************设置文件格式*************
function Cam_SetFileType(filetype) {SetFileType(filetype);
}//*************设置JPG图片质量*************
function Cam_SetJpgQuality(val) {SetJpgQuality(val);
}//*************设置色彩模式*************
function Cam_SetColorMode(colorMode) {SetColorMode(colorMode);
}//*************设置去黑边*************
function Cam_SetDeleteBlackEdge(flag) {SetDeleteBlackEdge(flag);
}//*************设置去底色*************
function Cam_SetDeleteBgColor(flag) {SetDeleteBgColor(flag);
}//*************从摄像头中识别二维码条码*************
function Cam_RecogQrBarCodeFromCamera(type) {RecogQrBarCodeFromCamera(type);
}//*************从图片文件中识别二维码条码*************
function Cam_RecogQrBarCodeFromFile(type,filePath) {RecogQrBarCodeFromFile(type, filePath);
}//*************添加要合并的图片到PDF*************
function Cam_AddImgFileToPDF(filePath) {AddImgFileToPDF(filePath);
}//*************添加要合并PDF的图片路径集合*************
function Cam_AddImgFileToPDFex(filePath) {AddImgFileToPDFex(filePath);
}//*************合并PDF*************
function Cam_CombinePDF(filePath) {CombinePDF(filePath);
}//*************添加要合并的图片*************
function Cam_AddMergeImageFile(filePath) {AddMergeImageFile(filePath);
}//*************合并图像*************
function Cam_MergeImages(filePath,dir) {MergeImages(filePath, dir);
}//*************获取驱动盘符*************
function GetDrives() {if (isSocketConnect) {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA6;socket.send(aDataArray.buffer);}
}//*************设置水印*************
function SetWaterMark(isAdd, wType, addTime, wTransp, wPos, wSize, wColor, szInfo) {if (isSocketConnect) {if (szInfo == "")return;var info = encodeURI(szInfo);//console.log(info);var infoArray = stringToByte(info);var len = infoArray.length;var totalLen = len + 10;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA7;aDataArray[3] = isAdd;aDataArray[4] = wType;aDataArray[5] = addTime;aDataArray[6] = wPos;aDataArray[7] = wSize;aDataArray[8] = wTransp;aDataArray[9] = wColor;for (var i = 0; i < len; i++) {aDataArray[10 + i] = infoArray[i];}socket.send(aDataArray.buffer);}
}function ReadCamLicense() {if (isSocketConnect) {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA5;socket.send(aDataArray.buffer);}
}function SetInchImgType(sizetype) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xB0;aDataArray[3] = sizetype;socket.send(aDataArray.buffer);}
}function SetInchLineType(linetype) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xB1;aDataArray[3] = linetype;socket.send(aDataArray.buffer);}
}/****************************************************************************************/function DeleteFile(filePath) {if (isSocketConnect) {if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA8;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA8;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA8;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}
}//开始录像
function StartRecord(filePath,fps) {if (isSocketConnect) {if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 12;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xF0;aDataArray[3] = fps;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 0;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);//console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 12;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xF0;aDataArray[3] = fps;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 90;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[12 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 12;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xF0;aDataArray[3] = fps;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 90 + tmpLen;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[12 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}
}//停止录像
function StopRecord() {if (isSocketConnect) {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xF1;socket.send(aDataArray.buffer);}}function CombinePDF(filePath) {if (isSocketConnect) {//        if (filePath == "") {
//            var len = 0;
//            var aDataArray = new Uint8Array(3);
//            aDataArray[0] = 0x77;
//            aDataArray[1] = 0x88;
//            aDataArray[2] = 0x32;
//            for (var i = 0; i < len; i++) {
//                aDataArray[3 + i] = pathArray[i];
//            }
//            socket.send(aDataArray.buffer);
//        }
//        else {
//            var path = encodeURI(filePath);
//            var pathArray = stringToByte(path);
//            var len = pathArray.length;
//            var totalLen = len + 3;
//            var aDataArray = new Uint8Array(totalLen);
//            aDataArray[0] = 0x77;
//            aDataArray[1] = 0x88;
//            aDataArray[2] = 0x32;
//            for (var i = 0; i < len; i++) {
//                aDataArray[3 + i] = pathArray[i];
//            }
//            socket.send(aDataArray.buffer);//        }       if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x32;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);//console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x32;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x32;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}}function AddImgFileToPDF(filePath) {if (isSocketConnect) {if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x31;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x31;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x31;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(200);}}}
}function AddImgFileToPDFex(filePath) {if (isSocketConnect) {if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x33;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x33;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x33;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}
}function AddMergeImageFile(filePath) {if (isSocketConnect) {if (filePath == "") {var len = 0;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC0;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);var pathArray = stringToByte(path);var len = pathArray.length;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC0;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}}
}function MergeImages(filePath, dir) {if (isSocketConnect) {if (filePath == "") {var len = 0;var totalLen = len + 4;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC1;aDataArray[3] = dir;for (var i = 0; i < len; i++) {aDataArray[4 + i] = pathArray[i];}socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);var pathArray = stringToByte(path);var len = pathArray.length;var totalLen = len + 4;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC1;aDataArray[3] = dir;for (var i = 0; i < len; i++) {aDataArray[4 + i] = pathArray[i];}socket.send(aDataArray.buffer);}}}function RecogQrBarCodeFromCamera(type) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA3;aDataArray[3] = type;socket.send(aDataArray.buffer);}
}function RecogQrBarCodeFromFile(type, filePath) {if (isSocketConnect) {console.log(filePath);var path = encodeURI(filePath);var pathArray = stringToByte(path);var len = pathArray.length;var totalLen = len + 4;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA4;aDataArray[3] = type;for (var i = 0; i < len; i++) {aDataArray[4 + i] = pathArray[i];}socket.send(aDataArray.buffer);}
}function SetFileType(filetype) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x28;aDataArray[3] = filetype;if (filetype == 1)  //png格式aDataArray[3] = 2;if (filetype == 2)  //pdf格式aDataArray[3] = 4;socket.send(aDataArray.buffer);}
}function SetJpgQuality(val) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x29;aDataArray[3] = val;socket.send(aDataArray.buffer);}
}function SetColorMode(colorMode) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA0;aDataArray[3] = colorMode;socket.send(aDataArray.buffer);}
}function SetDpi(xDpi,yDpi) {if (isSocketConnect) {var aDataArray = new Uint8Array(7);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA9;aDataArray[3] = xDpi >> 8 & 0xff;aDataArray[4] = xDpi & 0xff;aDataArray[5] = yDpi >> 8 & 0xff;aDataArray[6] = yDpi & 0xff;socket.send(aDataArray.buffer);}
}function SetDeleteBlackEdge(flag) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA1;aDataArray[3] = flag;socket.send(aDataArray.buffer);}
}function Cam_SetDeleteBgColor(flag) {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xA2;aDataArray[3] = flag;socket.send(aDataArray.buffer);}
}function toUploadFile(url, filepath) {if (isSocketConnect) {//console.log(url);var urlpath = encodeURI(url);var urlpathArray = stringToByte(urlpath);//console.log(urlpath);var imgpath = encodeURI(filepath);var imgpathArray = stringToByte(imgpath);var len = urlpathArray.length + imgpathArray.length;var pathDataArray = new Uint8Array(len);for (var i = 0; i < urlpathArray.length; i++) {pathDataArray[i] = urlpathArray[i];}for (var i = 0; i < imgpathArray.length; i++) {pathDataArray[urlpathArray.length + i] = imgpathArray[i];}var packageCount = 0;var tmpLen=len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 17;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x90;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = urlpathArray.length >> 16 & 0xff;aDataArray[7] = urlpathArray.length >> 8 & 0xff;aDataArray[8] = urlpathArray.length & 0xff;aDataArray[9] = imgpathArray.length >> 16 & 0xff;aDataArray[10] = imgpathArray.length >> 8 & 0xff;aDataArray[11] = imgpathArray.length & 0xff;aDataArray[12] = packageCount >> 8 & 0xff;   //包总数aDataArray[13] = packageCount & 0xff;   //包总数aDataArray[14] = 90;   //分包长度aDataArray[15] = pindex >> 8 & 0xff;   //包序号aDataArray[16] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[17 + i] = pathDataArray[i + pindex*90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 17;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x90;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = urlpathArray.length >> 16 & 0xff;aDataArray[7] = urlpathArray.length >> 8 & 0xff;aDataArray[8] = urlpathArray.length & 0xff;aDataArray[9] = imgpathArray.length >> 16 & 0xff;aDataArray[10] = imgpathArray.length >> 8 & 0xff;aDataArray[11] = imgpathArray.length & 0xff;aDataArray[12] = packageCount >> 8 & 0xff;   //包总数aDataArray[13] = packageCount & 0xff;   //包总数aDataArray[14] = 90 + tmpLen;   //分包长度aDataArray[15] = pindex >> 8 & 0xff;   //包序号aDataArray[16] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[17 + i] = pathDataArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}function toUploadFileEx(lpServer, lpAddr, port, filepath) {if (isSocketConnect) {//console.log(url);var lpServerPath = encodeURI(lpServer);var lpServerArray = stringToByte(lpServerPath);var lpAddrPath = encodeURI(lpAddr);var lpAddrArray = stringToByte(lpAddrPath);var imgpath = encodeURI(filepath);var imgpathArray = stringToByte(imgpath);var len = lpServerArray.length + lpAddrArray.length + imgpathArray.length;var pathDataArray = new Uint8Array(len);for (var i = 0; i < lpServerArray.length; i++) {pathDataArray[i] = lpServerArray[i];}for (var i = 0; i < lpAddrArray.length; i++) {pathDataArray[lpServerArray.length + i] = lpAddrArray[i];}for (var i = 0; i < imgpathArray.length; i++) {pathDataArray[lpServerArray.length + lpAddrArray.length + i] = imgpathArray[i];}var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 23;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x92;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = port >> 16 & 0xff;aDataArray[7] = port >> 8 & 0xff;aDataArray[8] = port & 0xff;aDataArray[9] = lpServerArray.length >> 16 & 0xff;aDataArray[10] = lpServerArray.length >> 8 & 0xff;aDataArray[11] = lpServerArray.length & 0xff;aDataArray[12] = lpAddrArray.length >> 16 & 0xff;aDataArray[13] = lpAddrArray.length >> 8 & 0xff;aDataArray[14] = lpAddrArray.length & 0xff;aDataArray[15] = imgpathArray.length >> 16 & 0xff;aDataArray[16] = imgpathArray.length >> 8 & 0xff;aDataArray[17] = imgpathArray.length & 0xff;aDataArray[18] = packageCount >> 8 & 0xff;   //包总数aDataArray[19] = packageCount & 0xff;   //包总数aDataArray[20] = 90;   //分包长度aDataArray[21] = pindex >> 8 & 0xff;   //包序号aDataArray[22] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[23 + i] = pathDataArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 23;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x92;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = port >> 16 & 0xff;aDataArray[7] = port >> 8 & 0xff;aDataArray[8] = port & 0xff;aDataArray[9] = lpServerArray.length >> 16 & 0xff;aDataArray[10] = lpServerArray.length >> 8 & 0xff;aDataArray[11] = lpServerArray.length & 0xff;aDataArray[12] = lpAddrArray.length >> 16 & 0xff;aDataArray[13] = lpAddrArray.length >> 8 & 0xff;aDataArray[14] = lpAddrArray.length & 0xff;aDataArray[15] = imgpathArray.length >> 16 & 0xff;aDataArray[16] = imgpathArray.length >> 8 & 0xff;aDataArray[17] = imgpathArray.length & 0xff;aDataArray[18] = packageCount >> 8 & 0xff;   //包总数aDataArray[19] = packageCount & 0xff;   //包总数aDataArray[20] = 90 + tmpLen;   //分包长度aDataArray[21] = pindex >> 8 & 0xff;   //包序号aDataArray[22] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[23 + i] = pathDataArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}function AddOcrRecogFile(filePath) {if (isSocketConnect) {if (filePath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC3;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(filePath);console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC3;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC3;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(200);}}//        if (filePath == "") {
//            var len = 0;
//            var totalLen = len + 3;
//            var aDataArray = new Uint8Array(totalLen);
//            aDataArray[0] = 0x77;
//            aDataArray[1] = 0x88;
//            aDataArray[2] = 0xC3;
//            for (var i = 0; i < len; i++) {
//                aDataArray[3 + i] = pathArray[i];
//            }
//            socket.send(aDataArray.buffer);
//        }
//        else {//            var path = encodeURI(filePath);
//            var pathArray = stringToByte(path);
//            var len = pathArray.length;
//            var totalLen = len + 3;
//            var aDataArray = new Uint8Array(totalLen);
//            aDataArray[0] = 0x77;
//            aDataArray[1] = 0x88;
//            aDataArray[2] = 0xC3;
//            for (var i = 0; i < len; i++) {
//                aDataArray[3 + i] = pathArray[i];
//            }
//            socket.send(aDataArray.buffer);//        }}
}function OcrCallProEx(languageIndex, outpath, isDelSrcFile) {if (isSocketConnect) {var iRestPath = encodeURI(outpath);var txtpathArray = stringToByte(iRestPath);var len = txtpathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 13;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC4;aDataArray[3] = languageIndex;aDataArray[4] = isDelSrcFile;aDataArray[5] = len >> 16 & 0xff;aDataArray[6] = len >> 8 & 0xff;aDataArray[7] = len & 0xff;;aDataArray[8] = packageCount >> 8 & 0xff;   //包总数aDataArray[9] = packageCount & 0xff;   //包总数aDataArray[10] = 90;   //分包长度aDataArray[11] = pindex >> 8 & 0xff;   //包序号aDataArray[12] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[13 + i] = txtpathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 13;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC4;aDataArray[3] = languageIndex;aDataArray[4] = isDelSrcFile;aDataArray[5] = len >> 16 & 0xff;aDataArray[6] = len >> 8 & 0xff;aDataArray[7] = len & 0xff;aDataArray[8] = packageCount >> 8 & 0xff;   //包总数aDataArray[9] = packageCount & 0xff;   //包总数aDataArray[10] = 90 + tmpLen;   //分包长度aDataArray[11] = pindex >> 8 & 0xff;   //包序号aDataArray[12] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[13 + i] = txtpathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}function OcrCallPro(languageIndex, filePath, txtpath) {if (isSocketConnect) {//console.log(url);var urlpath = encodeURI(filePath);var urlpathArray = stringToByte(urlpath);//console.log(urlpath);var iRestPath = encodeURI(txtpath);var txtpathArray = stringToByte(iRestPath);var len = urlpathArray.length + txtpathArray.length;var pathDataArray = new Uint8Array(len);for (var i = 0; i < urlpathArray.length; i++) {pathDataArray[i] = urlpathArray[i];}for (var i = 0; i < txtpathArray.length; i++) {pathDataArray[urlpathArray.length + i] = txtpathArray[i];}var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 18;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC2;aDataArray[3] = languageIndex;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = urlpathArray.length >> 16 & 0xff;aDataArray[8] = urlpathArray.length >> 8 & 0xff;aDataArray[9] = urlpathArray.length & 0xff;aDataArray[10] = txtpathArray.length >> 16 & 0xff;aDataArray[11] = txtpathArray.length >> 8 & 0xff;aDataArray[12] = txtpathArray.length & 0xff;aDataArray[13] = packageCount >> 8 & 0xff;   //包总数aDataArray[14] = packageCount & 0xff;   //包总数aDataArray[15] = 90;   //分包长度aDataArray[16] = pindex >> 8 & 0xff;   //包序号aDataArray[17] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[18 + i] = pathDataArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 18;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xC2;aDataArray[3] = languageIndex;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = urlpathArray.length >> 16 & 0xff;aDataArray[8] = urlpathArray.length >> 8 & 0xff;aDataArray[9] = urlpathArray.length & 0xff;aDataArray[10] = txtpathArray.length >> 16 & 0xff;aDataArray[11] = txtpathArray.length >> 8 & 0xff;aDataArray[12] = txtpathArray.length & 0xff;aDataArray[13] = packageCount >> 8 & 0xff;   //包总数aDataArray[14] = packageCount & 0xff;   //包总数aDataArray[15] = 90 + tmpLen;   //分包长度aDataArray[16] = pindex >> 8 & 0xff;   //包序号aDataArray[17] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[18 + i] = pathDataArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}function StartWiseCaptrue(folderPath) {if (isSocketConnect) {if (folderPath == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen = 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xE0;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 0;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(folderPath);console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 11;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xE0;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 11;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xE0;aDataArray[3] = len >> 16 & 0xff;aDataArray[4] = len >> 8 & 0xff;aDataArray[5] = len & 0xff;aDataArray[6] = packageCount >> 8 & 0xff;   //包总数aDataArray[7] = packageCount & 0xff;   //包总数aDataArray[8] = 90 + tmpLen;   //分包长度aDataArray[9] = pindex >> 8 & 0xff;   //包序号aDataArray[10] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[11 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(200);}}}
}function StopWiseCaptrue() {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0xE1;socket.send(aDataArray.buffer);
}function ReadIdCard(cardImgPath) {if (isSocketConnect) {if (cardImgPath == "") {var len = 0;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x80;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}else {var path = encodeURI(cardImgPath);var pathArray = stringToByte(path);var len = pathArray.length;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x80;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}       }
}function ReadIdCardEx(cardImgPath) {if (isSocketConnect) {if (cardImgPath == "") {var len = 0;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x81;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}else {var path = encodeURI(cardImgPath);var pathArray = stringToByte(path);var len = pathArray.length;var totalLen = len + 3;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x81;for (var i = 0; i < len; i++) {aDataArray[3 + i] = pathArray[i];}socket.send(aDataArray.buffer);}}
}function GetDevCount() {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x50;  socket.send(aDataArray.buffer);
}function GetResolution(iCamNo) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x51;aDataArray[3] = iCamNo;socket.send(aDataArray.buffer);
}function OpenCamera(iCamNo, width, height) {pALastX = 0;pALastY = 0;pACurrentX = 0;pACurrentY = 0;if (isSocketConnect) {var aDataArray = new Uint8Array(12);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x01;   //打开摄像头aDataArray[3] = iCamNo;aDataArray[4] = MainCanvas.width >> 8 & 0xff;aDataArray[5] = MainCanvas.width & 0xff;aDataArray[6] = MainCanvas.height >> 8 & 0xff;aDataArray[7] = MainCanvas.height & 0xff;aDataArray[8] = width >> 8 & 0xff;aDataArray[9] = width & 0xff;aDataArray[10] = height >> 8 & 0xff;aDataArray[11] = height & 0xff;socket.send(aDataArray.buffer);}
}function CloseCamera() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x02;  //关闭摄像头aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function CaptureImage(fileAddr) {if (isSocketConnect) {// var pathArray = stringToUint8Array(fileAddr);if (fileAddr == "") {var packageCount = 1;var len = 0;var pindex = 0;var totalLen =  12;  var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x10;aDataArray[3] = 0x00;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 0;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);socket.send(aDataArray.buffer);}else {var path = encodeURI(fileAddr);//console.log(path);var pathArray = stringToByte(path);var len = pathArray.length;var packageCount = 0;var tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;packageCount++;}console.log("packageCount:" + packageCount);var pindex = 0;tmpLen = len;while (tmpLen > 0) {tmpLen = tmpLen - 90;if (tmpLen > 0) {var totalLen = 90 + 12;var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x10;aDataArray[3] = 0x00;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 90;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < 90; i++) {aDataArray[12 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}else {var totalLen = 90 + tmpLen + 12;  // 此时tmpLen为负数,做加法运算var aDataArray = new Uint8Array(totalLen);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x10;aDataArray[3] = 0x00;aDataArray[4] = len >> 16 & 0xff;aDataArray[5] = len >> 8 & 0xff;aDataArray[6] = len & 0xff;aDataArray[7] = packageCount >> 8 & 0xff;   //包总数aDataArray[8] = packageCount & 0xff;   //包总数aDataArray[9] = 90 + tmpLen;   //分包长度aDataArray[10] = pindex >> 8 & 0xff;   //包序号aDataArray[11] = pindex & 0xff;    //包序号console.log("pindex:" + pindex);for (var i = 0; i < (90 + tmpLen); i++) {aDataArray[12 + i] = pathArray[i + pindex * 90];}socket.send(aDataArray.buffer);}pindex++;toSleep(80);}}}}function ZoomIn() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x03;  //放大aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function ZoomOut() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x04;  //缩小aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function BestSize() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x05;  //适合大小aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function TrueSize() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x06;  //1:1aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function Rotate(angle) {if (isSocketConnect) {var aDataArray = new Uint8Array(5);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x78;aDataArray[3] = 0x00;if (angle > 3 || angle<0)angle=0;aDataArray[4] = angle;socket.send(aDataArray.buffer);}}function RotateL() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x07;  //左旋aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function RotateR() {if (isSocketConnect ) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x08;  //右旋aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}
}function ManualFocus() {if (isSocketConnect) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x30;aDataArray[3] = 0x00; socket.send(aDataArray.buffer);}}function SetCutMode(cutMode) {if (isSocketConnect) {MainCamCutMode = cutMode; var aDataArray = new Uint8Array(5);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x11;  //设置裁剪模式aDataArray[3] = 0x00;aDataArray[4] = cutMode;socket.send(aDataArray.buffer);     }
}function SetCutRect(rectX,rectY,rectW,rectH) {if (isSocketConnect) {var aDataArray = new Uint8Array(12);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x13;  //设置裁剪模式aDataArray[3] = 0x00;aDataArray[4] = rectX >> 8 & 0xff;aDataArray[5] = rectX & 0xff;aDataArray[6] = rectY >> 8 & 0xff;aDataArray[7] = rectY & 0xff;aDataArray[8] = rectW >> 8 & 0xff;aDataArray[9] = rectW & 0xff;aDataArray[10] = rectH >> 8 & 0xff;aDataArray[11] = rectH & 0xff;//console.log(aDataArray[8] + "," + aDataArray[9]);socket.send(aDataArray.buffer);}
}function SetCustomArea(iX1, iY1, iX2, iY2) {if (isSocketConnect) {var aDataArray = new Uint8Array(12);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x23;  //设置自定义裁剪区域aDataArray[3] = 0x00;aDataArray[4] = iX1 >> 8 & 0xff;aDataArray[5] = iX1 & 0xff;aDataArray[6] = iY1 >> 8 & 0xff;aDataArray[7] = iY1 & 0xff;aDataArray[8] = iX2 >> 8 & 0xff;aDataArray[9] = iX2 & 0xff;aDataArray[10] = iY2 >> 8 & 0xff;aDataArray[11] = iY2 & 0xff;socket.send(aDataArray.buffer);}
}function ShowVideoProp() {if (isSocketConnect ) {var aDataArray = new Uint8Array(4);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x12;  //设置视频属性aDataArray[3] = 0x00;socket.send(aDataArray.buffer);}}function MoveOffsetXY(px,py,xdir,ydir) {if (isSocketConnect) {var aDataArray = new Uint8Array(10);aDataArray[0] = 0x77;aDataArray[1] = 0x88;aDataArray[2] = 0x09;  //移动aDataArray[3] = 0x00;aDataArray[4] = px >> 8 & 0xff;aDataArray[5] = px & 0xff;aDataArray[6] = py >> 8 & 0xff;aDataArray[7] = py & 0xff;aDataArray[8] = xdir ;aDataArray[9] = ydir ;socket.send(aDataArray.buffer);}
}function onMouseWheel(ev) { /*当鼠标滚轮事件发生时,执行一些操作*/var ev = ev || window.event;var down = true;per = 1;down = ev.wheelDelta ? ev.wheelDelta < 0 : ev.detail > 0;if (down) {ZoomOut();//per += 0.05;//console.log("onMouseWheel down");} else {ZoomIn();//per -= 0.05;//console.log("onMouseWheel up");}//    if (ev.preventDefault) { /*FF 和 Chrome*///        ev.preventDefault(); // 阻止默认事件//    }return false;
}function MainCanvasMouseDown(e) {isMouseDown = true;pALastX = e.pageX - MainCanvas.offsetLeft;pALastY = e.pageY - MainCanvas.offsetTop;if (MainCamCutMode == 2) {pACurrentX = pALastX;pACurrentY = pALastY;}
}function MainCanvasMouseUp(e) {isMouseDown = false;
}function MainCanvasMouseOut(e) {isMouseDown = false;
}function MainCanvasMouseMove(e) {if (isMouseDown) {if (MainCamCutMode == 2) {pACurrentX = e.pageX - MainCanvas.offsetLeft;pACurrentY = e.pageY - MainCanvas.offsetTop;//console.log("MainCanvas:" + MainCanvas.offsetLeft + "," + MainCanvas.offsetTop);var rectx,recty,rectw,recth ;if (pALastX > pACurrentX)rectx = pACurrentX;elserectx = pALastX;if (pALastY > pACurrentY)recty = pACurrentY;elserecty = pALastY;rectw = Math.abs(pACurrentX - pALastX);recth = Math.abs(pACurrentY - pALastY);SetCutRect(rectx, recty, rectw, recth);  //手动裁剪区域//console.log(rectx + "," + recty + "," + rectw + "," + recth);}else {pACurrentX = e.pageX - MainCanvas.offsetLeft;pACurrentY = e.pageY - MainCanvas.offsetTop;var dx = pACurrentX - pALastX;var dy = pACurrentY - pALastY;var xdir = 0;var ydir = 0;if (dx < 0)xdir = 0;elsexdir = 1;if (dy < 0)ydir = 0;elseydir = 1;pALastX = pACurrentX;pALastY = pACurrentY;MoveOffsetXY(Math.abs(dx), Math.abs(dy), xdir, ydir);            }      }
}/************************************************************************************************************************************************///>>>>>>>>>>>>>>>>.修改的地方>>>>>>>>>>>>>>>
var lockReconnect = false;
var connectCount = 0;
var heartTimerId = -1;//心跳检测
function heartCheck() {clearInterval(heartTimerId);heartTimerId = setInterval(function () {if (isSocketConnect) {var aDataArray = new Uint8Array(3);aDataArray[0] = 0x11;aDataArray[1] = 0x11;aDataArray[2] = 0x11;socket.send(aDataArray.buffer);console.log("heartCheck...........");}}, 6000);
}//var heartCheck = {   
//    timeout: 4000,    //4秒发一次心跳
//    timeoutObj: null,
//    serverTimeoutObj: null,
//    reset: function () {
//        //console.log("clearTimeout");
//        clearTimeout(this.timeoutObj);
//        clearTimeout(this.serverTimeoutObj);
//        return this;
//    },//    start: function () {
//        var self = this;
//        console.log(self.timeout);
//        this.timeoutObj = setTimeout(function(){
//            //这里发送一个心跳,后端收到后,返回一个心跳消息,
//            console.log("websocket ping 01");
//            var aDataArray = new Uint8Array(3);
//            aDataArray[0] = 0x11;
//            aDataArray[1] = 0x11;
//            aDataArray[2] = 0x11;
//            socket.send(aDataArray.buffer);
//            console.log("websocket ping 02");
//            self.serverTimeoutObj = setTimeout(function () {//如果超过一定时间还没重置,说明后端主动断开了
//                console.log("websocket ping 03");
//                socket.close();     //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
//            }, self.timeout)
//        }, this.timeout)
//    }
//}//掉线重连
var intervalId = -1;
function reconnect() {clearInterval(intervalId);intervalId = setInterval(function () {if (isSocketConnect == false) {WebSocketConnect();console.log("reconnect...")}console.log("reconnectTimer.........!")}, 3000);}function WebSocketConnect() {socket = new WebSocket("ws://127.0.0.1:22225");socket.binaryType = "arraybuffer";try {socket.onopen = function (event) {//heartCheck.reset().start(); heartCheck();isSocketConnect = true;clearInterval(intervalId);//if (isOpenMainCamera == false)         Cam_GetDevCount();console.log("socket.onopen");};socket.onclose = function (event) {console.log("socket.onclose");isSocketConnect = false;reconnect();jQuery$("TextInfo").value = "websocket connect close!"};socket.onerror = function (event) {isSocketConnect = false;reconnect();jQuery$("TextInfo").value = "websocket connect error!"};socket.onmessage = function (event) {//heartCheck.reset().start();      var rDataArr = new Uint8Array(event.data);if (rDataArr.length > 0) {if (rDataArr[0] == 0x11 && rDataArr[1] == 0x11 && rDataArr[2] == 0x11) {console.log("heart socket!!!!");}if (rDataArr[0] == 0x55 && rDataArr[1] == 0x66) {//摄像头数目返回if (rDataArr[2] == 0x50) {var devCount = rDataArr[3];var devNameBufLen = rDataArr.length - 4;var devNameData = new Uint8Array(devNameBufLen);for (var i = 0; i < devNameBufLen; i++) {devNameData[i] = rDataArr[4 + i];}//var AllCamName = Uint8ArrayToString(devNameData);var str = byteToString(devNameData);var AllCamName = decodeURIComponent(str);var camName = new Array();camName = AllCamName.split('|');GetDevCountAndNameResultCB(devCount, camName);}//摄像头分辨率返回if (rDataArr[2] == 0x51) {var resCount = rDataArr[3];var resArr = new Array();for (var i = 0; i < resCount; i++) {var width = rDataArr[4 + i * 4 + 0] * 256 + rDataArr[4 + i * 4 + 1];var height = rDataArr[4 + i * 4 + 2] * 256 + rDataArr[4 + i * 4 + 3];var resStr = "" + width + "*" + height;resArr.push(resStr);}GetResolutionResultCB(resCount, resArr);}//摄像头开启状态返回if (rDataArr[2] == 0x01) {if (rDataArr[3] == 0x01) {isOpenMainCamera = true;GetCameraOnOffStatus(0);//Cam_Rotate(1);}if (rDataArr[3] == 0x03) {isOpenMainCamera = false;GetCameraOnOffStatus(1);}}if (rDataArr[2] == 0xA5) {var flag;if (rDataArr[3] == 0x00) {flag = 2;}if (rDataArr[3] == 0x01) {flag = 0;}if (flag == 0) {var ResultStr = "";var pDataLen = rDataArr.length - 4;if (pDataLen > 0) {var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[4 + i];}var str = byteToString(pData);console.log(str);ResultStr = decodeURIComponent(str);}console.log(ResultStr);}}//当前拍照状态返回if (rDataArr[2] == 0x10) {//console.log(rDataArr[3]);//GetCaptrueStatusResultCB(rDataArr[3]);}//拍照结果返回if (rDataArr[2] == 0x10) {var flag;if (rDataArr[3] == 0x01) {flag = 0;var imgpathLen = rDataArr[4] * 256 + rDataArr[5];if (imgpathLen == 0) {var base64Len = rDataArr[6] * 65536 + rDataArr[7] * 256 + rDataArr[8];var imgPathStr = "";var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[9 + imgpathLen + i];}var base64Str = Uint8ArrayToString(base64Data);GetCaptrueImgResultCB(flag, imgPathStr, base64Str);}else {var base64Len = rDataArr[6] * 65536 + rDataArr[7] * 256 + rDataArr[8];var pData = new Uint8Array(imgpathLen);for (var i = 0; i < imgpathLen; i++) {pData[i] = rDataArr[9 + i];}var str = byteToString(pData);var imgPathStr = decodeURIComponent(str);var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[9 + imgpathLen + i];}var base64Str = Uint8ArrayToString(base64Data);GetCaptrueImgResultCB(flag, imgPathStr, base64Str);}}if (rDataArr[3] == 0x02) {flag = 2;GetCaptrueImgResultCB(flag, "", "");}}//身份证信息返回if (rDataArr[2] == 0x80) {var flag;if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}var pDataLen = rDataArr.length - 4;var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[4 + i];}var str = byteToString(pData);var AllInfoStr = decodeURIComponent(str);var resultStr = new Array();resultStr = AllInfoStr.split(';');//console.log(resultStr);GetIdCardInfoResultCB(flag, resultStr[0], resultStr[1], resultStr[2], resultStr[3], resultStr[4], resultStr[5], resultStr[6], resultStr[7], resultStr[8], resultStr[9]);}//身份证信息及证件合并照片信息返回if (rDataArr[2] == 0x81) {var flag;if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}var pDataLen = rDataArr.length - 4;var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[4 + i];}var str = byteToString(pData);var AllInfoStr = decodeURIComponent(str);var resultStr = new Array();resultStr = AllInfoStr.split(';');GetIdCardInfoAndImgResultCB(flag, resultStr[0], resultStr[1], resultStr[2], resultStr[3], resultStr[4], resultStr[5], resultStr[6], resultStr[7], resultStr[8], resultStr[9], resultStr[10]);}//上传结果返回if (rDataArr[2] == 0x90) {var flag;if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}if (rDataArr[3] == 0x03) {flag = 3;}var pDataLen = rDataArr.length - 6;if (pDataLen <= 0) {HttpResultCB(flag, ResultStr);}var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[6 + i];}var str = byteToString(pData);console.log(str);var ResultStr = decodeURIComponent(str);console.log(ResultStr);HttpResultCB(flag, ResultStr);}//添加需要OCR识别的图片文件返回结果if (rDataArr[2] == 0xC3) {var flag;var base64Len = rDataArr.length - 4;var base64Str = "";if (base64Len > 0) {var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[4 + i];}base64Str = Uint8ArrayToString(base64Data);}if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}AddOcrRecogFileResultCB(flag, base64Str);}//OCR识别结果if (rDataArr[2] == 0xC2) {var flag, proValue;flag = rDataArr[3];proValue = rDataArr[4];var ResultStr = "";console.log("result:" + flag + "_proValue:" + proValue);if (flag == 0) {//var pDataLen = rDataArr.length - 7;//var pData = new Uint8Array(pDataLen);//for (var i = 0; i < pDataLen; i++) {//    pData[i] = rDataArr[7 + i];//}//var str = byteToString(pData);//console.log(str);//ResultStr = decodeURIComponent(str);//console.log(ResultStr);var pathLen = rDataArr[5] * 256 + rDataArr[6];var base64Len = rDataArr[7] * 65536 + rDataArr[8] * 256 + rDataArr[9];var pData = new Uint8Array(pathLen);for (var i = 0; i < pathLen; i++) {pData[i] = rDataArr[10 + i];}var str = byteToString(pData);ResultStr = decodeURIComponent(str);var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[10 + pathLen + i];}var base64Str = Uint8ArrayToString(base64Data);OcrCallResultCB(flag, proValue, ResultStr, base64Str);}else {OcrCallResultCB(flag, proValue, ResultStr, "");}}//条码二维码识别结果返回if (rDataArr[2] == 0x91) {var flag;if (rDataArr[3] == 0x00) {flag = 2;    //未识别到内容}if (rDataArr[3] == 0x01) {flag = 0;    //识别到内容}var ResultStr = "";var pDataLen = rDataArr.length - 4;if (flag == 0 && pDataLen > 0) {var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[4 + i];}var str = byteToString(pData);ResultStr = decodeURIComponent(str);}console.log(ResultStr);QrBarCodeRecogResultCB(flag, ResultStr);}//添加合并PDF文件结果返回if (rDataArr[2] == 0x31) {var flag;var base64Len = rDataArr.length - 4;var base64Str = "";if (base64Len > 0) {var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[4 + i];}base64Str = Uint8ArrayToString(base64Data);}if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}AddImgFileToPDFResultCB(flag, base64Str);}//合并PDF结果返回if (rDataArr[2] == 0x32) {var flag;var base64Len = rDataArr.length - 4;var base64Str = "";if (base64Len > 0) {var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[4 + i];}base64Str = Uint8ArrayToString(base64Data);}if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}PdfCombineResultCB(flag, base64Str);}//添加合并图像文件结果返回if (rDataArr[2] == 0xC0) {var flag;var base64Len = rDataArr.length - 4;var base64Str = "";if (base64Len > 0) {var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[4 + i];}base64Str = Uint8ArrayToString(base64Data);}if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}AddMergeImageFileResultCB(flag, base64Str);}//合并图像结果返回if (rDataArr[2] == 0xC1) {var flag;var base64Len = rDataArr.length - 4;var base64Str = "";if (base64Len > 0) {var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[4 + i];}base64Str = Uint8ArrayToString(base64Data);}if (rDataArr[3] == 0x01) {flag = 0;}if (rDataArr[3] == 0x02) {flag = 2;}console.log("MergeImagesResultCB 01");MergeImagesResultCB(flag, base64Str);console.log("MergeImagesResultCB 02");}if (rDataArr[2] == 0xA5) {var flag;if (rDataArr[3] == 0x00) {flag = 2;}if (rDataArr[3] == 0x01) {flag = 0;}var ResultStr = "";if (flag == 0) {var pDataLen = rDataArr.length - 4;if (pDataLen > 0) {var pData = new Uint8Array(pDataLen);for (var i = 0; i < pDataLen; i++) {pData[i] = rDataArr[4 + i];}var str = byteToString(pData);ResultStr = decodeURIComponent(str);}// console.log(ResultStr);}GetLicenseResultCB(ResultStr);}//获取驱动盘符if (rDataArr[2] == 0xA6) {var strLen = rDataArr.length - 3;if (strLen > 0) {var driveData = new Uint8Array(strLen);for (var i = 0; i < strLen; i++) {driveData[i] = rDataArr[3 + i];}var driveStr = Uint8ArrayToString(driveData);GetDriveResultCB(driveStr);}else {GetDriveResultCB("");}}//连拍返回结果if (rDataArr[2] == 0xE0) {var flag;if (rDataArr[3] == 0) {//console.log("wise captrue fail !!");GetWiseCaptrueResultCB(2, Steady, "", "");}else {var Steady = rDataArr[4];if (Steady == 1) {var imgpathLen = rDataArr[5] * 256 + rDataArr[6];var base64Len = rDataArr[7] * 65536 + rDataArr[8] * 256 + rDataArr[9];var pData = new Uint8Array(imgpathLen);for (var i = 0; i < imgpathLen; i++) {pData[i] = rDataArr[10 + i];}var str = byteToString(pData);var imgPathStr = decodeURIComponent(str);var base64Data = new Uint8Array(base64Len);for (var i = 0; i < base64Len; i++) {base64Data[i] = rDataArr[10 + imgpathLen + i];}var base64Str = Uint8ArrayToString(base64Data);GetWiseCaptrueResultCB(0, Steady, imgPathStr, base64Str);}else {GetWiseCaptrueResultCB(0, Steady, "", "");}}}//删除文件结果if (rDataArr[2] == 0xA8) {var flag;if (rDataArr[3] == 0) {flag = 0;}else {flag = 2;}GetDeleteFileResultCB(flag);}//摄像头数据if (rDataArr[2] == 0xcc) {var ww = rDataArr[3] * 256 + rDataArr[4];var hh = rDataArr[5] * 256 + rDataArr[6];pMainShowStartX = rDataArr[7] * 256 + rDataArr[8];pMainShowStartY = rDataArr[9] * 256 + rDataArr[10];MainContext.clearRect(0, 0, MainCanvas.width, MainCanvas.height);var imgData = MainContext.createImageData(ww, hh);var dataNum = 0;dataNum = dataNum + 11;for (var i = 0; i < imgData.data.length; i += 4) {imgData.data[i + 0] = rDataArr[dataNum];imgData.data[i + 1] = rDataArr[dataNum + 1];imgData.data[i + 2] = rDataArr[dataNum + 2];imgData.data[i + 3] = 255;dataNum = dataNum + 3;}MainContext.putImageData(imgData, pMainShowStartX, pMainShowStartY);if (MainCamCutMode == 2) {MainContext.strokeStyle = 'blue'; // 设置线条的颜色MainContext.lineWidth = 2; // 设置线条的宽度MainContext.beginPath(); // 绘制直线MainContext.rect(pALastX, pALastY, (pACurrentX - pALastX), (pACurrentY - pALastY));MainContext.closePath();MainContext.stroke();}}rDataArr = null;}}};    }catch (ex) {alert("异常错误!") }
}

//时间格式化显示
function formatDate(time) {var date = new Date(time);var year = date.getFullYear(),month = date.getMonth() + 1,day = date.getDate(),hour = date.getHours(),min = date.getMinutes(),sec = date.getSeconds();var newTime = year +(month < 10 ? '0' + month : month) +(day < 10 ? '0' + day : day) +(hour < 10 ? '0' + hour : hour) +(min < 10 ? '0' + min : min) +(sec < 10 ? '0' + sec : sec) ;return newTime;
}function sleep(milliSeconds) {var startTime = new Date().getTime();while (new Date().getTime() < startTime + milliSeconds);
}function ShowInfo(op) {var obj = document.getElementById("TextInfo");obj.value = obj.value + "\r\n" + op
}/*----------------------------------------------------
---(必须重写该函数)返回获取的设备数目及设备名称  ---
-----------------------------------------------------*/
function GetDevCountAndNameResultCB(devCount, devNameArr) {if (devCount > 0) {var obj = document.getElementById("DevName");obj.options.length = 0;for (var i = 0; i < devCount; i++) {var objOption = document.createElement("option");objOption.text = devNameArr[i];objOption.value = i;obj.options.add(objOption);}obj.selectedIndex = 0;var CamID = obj.selectedIndex;//获取分辨率Cam_GetDevResolution(CamID);}else {ShowInfo("没有发现合适的设备!");}
}/*---------------------------------------------------
---  (必须重写该函数)返回获取的设备分辨率信息   ---
----------------------------------------------------*/
function GetResolutionResultCB(resCount, resArr) {if (resCount > 0) {var selectIndex = 0;var obj = document.getElementById("DevResolution");obj.options.length = 0;for (var i = 0; i < resCount; i++) {var objOption = document.createElement("option");objOption.text = resArr[i];objOption.value = i;obj.options.add(objOption);//默认500万分辨率打开if (resArr[i] == "2592*1944") {selectIndex = i;}}obj.selectedIndex = selectIndex;//打开摄像头Cam_Close();sleep(100);var restr = obj[obj.selectedIndex].text;var pos = restr.lastIndexOf("*");var width = parseInt(restr.substring(0, pos));var height = parseInt(restr.substring(pos + 1, restr.length));var CamID = document.getElementById("DevName").selectedIndex;Cam_Open(CamID, width, height);}else {ShowInfo("获取分辨率信息失败!");}
}/*---------------------------------------------------
---     (必须重写该函数)返回摄像头开启状态      ---
----------------------------------------------------*/
function GetCameraOnOffStatus(status) {if (status == 0) {ShowInfo("设备开启成功");//Cam_Rotate(1);   // 0-> 0度, 1->90度, 2->180度, 3->270度}else {ShowInfo("设备开启失败!");}}//    /*---------------------------------------------------
//    --------     (必须重写该函数)当前拍照状态 ---------
//    ----------------------------------------------------*/
//    function GetCaptrueStatusResultCB(status) {
//        if (status == 0) {
//            ShowInfo("拍照完成");
//        }
//        else {
//            ShowInfo("正在拍摄...");
//        }//    }/*---------------------------------------------------
--------     (必须重写该函数)拍照结果     ---------
----------------------------------------------------*/
function GetCaptrueImgResultCB( flag, path , base64Str) {if (flag == 0) {var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + base64Str;if (path == "") {ShowInfo("拍照成功");}else {ShowInfo("拍照成功,图片保存位置:" + path);}}else {ShowInfo("拍照失败!");}}/*---------------------------------------------------
------  (必须重写该函数)身份证信息返回结果   ------
----------------------------------------------------*/
function GetIdCardInfoResultCB(flag, Name, Sex, Nation, Born, Address, CardNum, IssuedAt, EffectedDate, CardImgPath, CardImgBase64) {if (flag == 0) {document.getElementById("CardName").value = Name;document.getElementById("CardSex").value = Sex;document.getElementById("CardNation").value = Nation;document.getElementById("CardBorn").value = Born;document.getElementById("CardAddress").value = Address;document.getElementById("CardNum").value = CardNum;document.getElementById("CardIssuedAt").value = IssuedAt;document.getElementById("CardEffectDate").value = EffectedDate;var obj = document.getElementById("IdCardPhoto");obj.src = "data:;base64," + CardImgBase64;ShowInfo("读卡成功");}else {ShowInfo("读卡失败!");}}/*-------------------------------------------------------------------
------  (必须重写该函数)身份证信息及正反面合并照片返回结果   ------
--------------------------------------------------------------------*/
function GetIdCardInfoAndImgResultCB(flag, Name, Sex, Nation, Born, Address, CardNum, IssuedAt, EffectedDate, CardImgPath, CardHeadImgBase64, CardImgBase64) {if (flag == 0) {document.getElementById("CardName").value = Name;document.getElementById("CardSex").value = Sex;document.getElementById("CardNation").value = Nation;document.getElementById("CardBorn").value = Born;document.getElementById("CardAddress").value = Address;document.getElementById("CardNum").value = CardNum;document.getElementById("CardIssuedAt").value = IssuedAt;document.getElementById("CardEffectDate").value = EffectedDate;var obj = document.getElementById("IdCardPhoto");obj.src = "data:;base64," + CardHeadImgBase64;var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + CardImgBase64;ShowInfo("读卡成功");}else {ShowInfo("读卡失败!");}}/*---------------------------------------------------
------  (必须重写该函数)条码二维码识别返回结果------
----------------------------------------------------*/
function QrBarCodeRecogResultCB(flag,codeStr) {if (flag == 0)ShowInfo("条码/二维码 识别结果:" + codeStr);elseShowInfo("未识别到内容!");
}/************************    初始化操作  *************************/function LoadCameraDocument() {if (!window.WebSocket) {alert("浏览器不支持HTML5,请更新浏览器或者使用其它浏览器");}//console.log("LoadCameraDocument");var obj = document.getElementById("CameraCtl");Cam_ControlInit(obj,0, 0, 600, 400);// 模拟异步硬件初始化setTimeout(function() {// 在此处调用设置默认值的函数SetCameraCutMode();}, 2500); // 假设2.5秒后硬件初始化完成// 模拟异步硬件初始化setTimeout(function() {// 在此处调用设置默认值的函数SetCameraCutMode();}, 4000); // 完不成再来一下
}window.onload = function () {console.log("window.onload");
}/************************    打开摄像头  *************************/
function toOpenCamera() {var CamID = document.getElementById("DevName").selectedIndex;var obj = document.getElementById("DevResolution");var restr = obj[obj.selectedIndex].text;var pos = restr.lastIndexOf("*");var width = parseInt(restr.substring(0, pos));var height = parseInt(restr.substring(pos + 1, restr.length));Cam_Open(CamID, width, height);}/************************    关闭摄像头  *************************/
function toCloseCamera() {Cam_Close();
}/************************    切换摄像头  *************************/
function SelectDevice() {var CamID = document.getElementById("DevName").selectedIndex;//获取分辨率Cam_GetDevResolution(CamID);
}/************************    切换分辨率  *************************/
function SelectResolution() {var obj = document.getElementById("DevResolution");var restr = obj[obj.selectedIndex].text;var pos = restr.lastIndexOf("*");var width = parseInt(restr.substring(0, pos));var height = parseInt(restr.substring(pos + 1, restr.length));var CamID = document.getElementById("DevName").selectedIndex;Cam_Open(CamID, width, height);
}/************************       拍照     *************************/
function TakePhoto() {var name = formatDate(new Date().getTime());var obj = document.getElementById("FileType");var path;Cam_SetFileType(obj.selectedIndex); //设置文件格式if (obj.selectedIndex == 0) {path = "D:\\" + name + ".jpg";}else if (obj.selectedIndex == 1) {path = "D:\\" + name + ".png";}else if (obj.selectedIndex == 2) {path = "D:\\" + name + ".pdf";}else {path = "D:\\" + name + ".jpg";}Cam_Photo(path);  //主摄像头拍照//Cam_Photo("");  //主摄像头拍照}function SetCameraCutMode() {if (document.getElementById("Radio1").checked) {Cam_SetCutMode(0);}if (document.getElementById("Radio3").checked) {Cam_SetCutMode(1);}if (document.getElementById("Radio2").checked) {Cam_SetCutMode(2);}
}/************************    读取身份证  *************************/
function GetIdCardInfo() {var path = "D:\\IdCard.jpg";//Cam_ReadIdCard(path);//Cam_ReadIdCard("");Cam_ReadIdCardEx(path);
}/************************    设置文件格式  *************************/
function toSetFileType() {var obj = document.getElementById("FileType");Cam_SetFileType(obj.selectedIndex);
}/************************    设置色彩模式  *************************/
function toSetColorModel() {var obj = document.getElementById("ColorMode");Cam_SetColorMode(obj.selectedIndex);
}/************************    设置JPG图像质量  *************************/
function toSetJpgQuality() {var obj = document.getElementById("JpgQuality");var val = obj[obj.selectedIndex].text;Cam_SetJpgQuality(val);
}/************************    设置去黑边  *************************/
function toSetDeleteBlackEdge() {var obj = document.getElementById("Checkbox1");if (obj.checked) {Cam_SetDeleteBlackEdge(1);}else {Cam_SetDeleteBlackEdge(0);}
}/************************    设置去底色  *************************/
function toSetDeleteBgColor() {var obj = document.getElementById("Checkbox2");if (obj.checked) {Cam_SetDeleteBgColor(1);}else {Cam_SetDeleteBgColor(0);}
}/*---------------------------------------------------
--------     (必须重写该函数)上传结果     ---------
----------------------------------------------------*/
function HttpResultCB(flag, ResultStr) {if (flag == 0) {alert("上传成功 :" + ResultStr);}else {alert("上传失败!");}
}/***************************    上传  ****************************/
function HttpUploadFile() {var filePath = "D:\\test.jpg";//var url = "http://112.27.213.220:2201/interface/FileUploadCode.jsp";//var url = "http://localhost:9005/MyServletTest/upload";var url = "http://localhost:4523/UploadFile.ashx";//var url = "http://localhost:9005/MyServletTest/upload";UploadFile(url, filePath);}//从摄像头中识别二维码
function RecogQrCodeFromCamera(type){Cam_RecogQrBarCodeFromCamera(type)
}//从图片文件中识别二维码
function RecogBarCodeFromFile(type) {var imgpath = "D:\\123.jpg";Cam_RecogQrBarCodeFromFile(type, imgpath)
}//添加要合并的PDF文件
function ToAddPDFFile() {Cam_AddImgFileToPDF("");
//        var path1 = "D:\\1.jpg";
//        var path2 = "D:\\2.jpg";
//        var path3 = "D:\\3.jpg";
//        var path4 = "D:\\4.jpg";
//        var path5 = "D:\\5.jpg";
//        var path6 = "D:\\6.jpg";
//        //var path7 = "D:\\7.jpg";
//        var allpath = path1 + ";" + path2 + ";" + path3 + ";" + path4 + ";" + path5 + ";" + path6 ;
//        Cam_AddImgFileToPDF(allpath);sleep(100);
}/*---------------------------------------------------
--------     添加合并的PDF文件返回结果     ---------
----------------------------------------------------*/
function AddImgFileToPDFResultCB(flag, base64Str)
{if (flag == 0) {ShowInfo("添加合并的PDF文件成功");var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + base64Str;}else {ShowInfo("添加合并的PDF文件失败!");}
}//PDF合并测试
function ToCombinePDF() {Cam_CombinePDF("D:\\test.pdf");//Cam_CombinePDF("");//Cam_CombinePDF("D:\\QRjoNxNcgw.pdf");
}/*---------------------------------------------------
--------     (必须重写该函数)合并PDF结果     ---------
----------------------------------------------------*/
function PdfCombineResultCB(flag, PdfBase64Str) {if (flag == 0) {ShowInfo("合并PDF完成");console.log(PdfBase64Str);}else {ShowInfo("合并PDF失败!");}
}//添加要合并的图像文件
function ToAddMergeImageFile() {Cam_AddMergeImageFile("");sleep(100);
}/*---------------------------------------------------
--------     添加合并图像文件返回结果     ---------
----------------------------------------------------*/
function AddMergeImageFileResultCB(flag, base64Str) {if (flag == 0) {ShowInfo("添加合并图像文件成功");var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + base64Str;}else {ShowInfo("添加合并图像文件失败!");}
}//图像合并测试
function ToMergeImages() {Cam_MergeImages("D:\\merge.jpg",0);
}/*---------------------------------------------------
--------     (必须重写该函数)图像合并结果     ---------
----------------------------------------------------*/
function MergeImagesResultCB(flag, base64Str) {if (flag == 0) {ShowInfo("图像合并完成");var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + base64Str;}else {ShowInfo("图像合并失败!");}
}/*---------------------------------------------------
-------(必须重写该函数)获取驱动盘符返回结果--------
----------------------------------------------------*/
function GetDriveResultCB(driveStr) {if (driveStr == "") {ShowInfo("获取盘符失败!");}else {ShowInfo(driveStr);}
}//设置水印
function toSetWaterMarkParams() {var isAddMark;var isAddTime;var wTransp;var wPos;var wSize;var wColor;var szInfo;var obj = document.getElementById("Checkbox3");if (obj.checked)isAddMark = 1;elseisAddMark = 0;obj = document.getElementById("Checkbox4");if (obj.checked)isAddTime = 1;elseisAddTime = 0;szInfo = document.getElementById("Text1").value;   //水印内容wTransp = parseInt(document.getElementById("Text2").value); //透明度wSize = parseInt(document.getElementById("Text3").value);   //水印大小wPos = document.getElementById("Select1").selectedIndex;   //水印位置wColor = document.getElementById("Select2").selectedIndex;   //水印颜色SetWaterMark(isAddMark, 0, isAddTime, wTransp, wPos, wSize, wColor, szInfo);  //生效水印设置
}//删除文件
function ToDeleteFile() {var path = "D:\\log.txt";DeleteFile(path);
}//删除文件返回结果
function GetDeleteFileResultCB(flag) {if (flag == 0) {ShowInfo("删除文件成功");}else {ShowInfo("删除文件失败!");}
}/*----------------------------------------------------------------
-------(必须重写该函数)添加需要OCR识别的图片文件返回结果--------
--------------------------------------------------------------*/
function AddOcrRecogFileResultCB(flag, base64Str) {if (flag == 0) {ShowInfo("添加需要OCR识别的图片文件成功");var obj = document.getElementById("CameraPhoto");obj.src = "data:;base64," + base64Str;}else {ShowInfo("添加文件失败!");}
}//添加文件
function ToAddOcrRecogFile() {//AddOcrRecogFile("");  //传空拍照添加,也可以传文件路径var path1 = "D:\\1.jpg";var path2 = "D:\\2.jpg";var path3 = "D:\\3.jpg";var path4 = "D:\\4.jpg";var path5 = "D:\\5.jpg";var path6 = "D:\\6.jpg";//var path7 = "D:\\7.jpg";var allpath = path1 + ";" + path2 + ";" + path3 + ";" + path4 + ";" + path5 + ";" + path6 ;console.log(allpath);AddOcrRecogFile(allpath);
}/*---------------------------------------------------
-------(必须重写该函数)OCR识别结果返回--------
----------------------------------------------------*/
function OcrCallResultCB(flag,proValue, ResultStr, base64Str) {if (flag == 0) {ShowInfo("Ocr文字识别成功:" + ResultStr);//ShowInfo("base64data:" + base64Str);var obj = document.getElementById("mypdf");obj.src = "data:application/pdf;base64," + base64Str;}else if (flag == 1) {ShowInfo("Ocr文字识别进度:" + proValue);}else {if (flag == 40)ShowInfo("Ocr授权失败!");elseShowInfo("Ocr文字识别失败!");}
}//OCR识别(多张合并识别)
function ToOcrCallProEx() {OcrCallProEx(0, "D:\\out.pdf",0);}//OCR测试(单张识别)
function OcrTest() {OcrCallPro(0, "D:\\111.jpg", "D:\\test.txt");
}//开始录像
function ToStartRecord() {ShowInfo("开始录像");StartRecord("D:\\test.avi", 10);
}//停止录像
function ToStopRecord() {ShowInfo("关闭录像,D:\\test.avi");StopRecord();
}

4.更改html样式

4.1.html代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>跨浏览器调用高拍仪测试demo</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head><!-- 引入高拍仪JS接口-->
<script src="gpyhs.js" type="text/javascript" charset="utf-8"></script>
<script src="gpy.js" type="text/javascript" charset="utf-8"></script><body onload="LoadCameraDocument()"><div style="width:602px; height: 640px; border: 10px solid rgba(38,81,253,0); background:rgba(38,81,253,0);  float:left"><br/><div id='CameraCtl' style="width:600px; height: 400px"></div><div style="white-space: nowrap; text-align: center;"><br/><input style="display: inline-block; margin: 0 auto; font-size: 1.5em; padding: 7px 15px; background-color: #007BFF; color: #ffffff; border: none; border-radius: 5px; cursor: pointer;"type="button" value="拍照" onclick="TakePhoto();"/><!--        <input style="display: inline-block; margin: 0 auto; font-size: 1.5em;" type="button" value="拍照"--><!--               onclick="TakePhoto();"/>--><input style="display: inline-block; font-size: 1.5em;" type="button" value="上传" onclick="HttpUploadFile();"/></div>更多设置:<div><input type="button" value="左旋" onclick="Cam_RotateLeft();"/><input type="button" value="右旋" onclick="Cam_RotateRight();"/><input type="button" value="对焦" onclick="Cam_Focus();"/></div><div>设备<select style="width:140px" id="DevName" onchange="SelectDevice()"></select>分辨率<select style="width:140px" id="DevResolution" onchange="SelectResolution()"></select><input type="button" value=" 打开设备 " onclick="toOpenCamera();"/><input type="button" value=" 关闭设备 " onclick="toCloseCamera();"/><br/>裁切模式:<input id="Radio1" name="R1" type="radio" value="V1" onclick="SetCameraCutMode()"/>不裁切<input id="Radio2" name="R1" type="radio" value="V2" onclick="SetCameraCutMode()"/>手动裁切<input id="Radio3" name="R1" type="radio" value="V3" onclick="SetCameraCutMode()" checked="checked"/>自动裁切<br/>文件格式:<select id="FileType" onchange="toSetFileType()"><option value="0">jpg</option><option value="1">png</option><option value="2">pdf</option></select><input id="Checkbox1" type="checkbox" onclick="toSetDeleteBlackEdge()" /> 去黑边<input id="Checkbox2" type="checkbox" onclick="toSetDeleteBgColor()" /> 去底色</div><br/><div style="width:595px; height: 80px"><div>操作提示:</div><textarea style="width:100%; height:100%" id="TextInfo" cols="20" rows="2"></textarea></div></div><div style="width:202px; height: 640px; border: 10px solid rgba(255,255,255,0); background:rgba(199,237,204,0);  float:left">拍照图片<br/><img id="CameraPhoto" src=""style="transform: scale(0.5); transform-origin: left top; max-width: 1200px; max-height: 800px;"/><br/></div></body>
</html>

4.2.界面展示

5.遗留问题

5.1.不知道怎么把数据传回

目前的代码只能实现把图片传到服务器上

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/249684.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL数据库基础第一篇(SQL通用语法与分类)

文章目录 一、SQL通用语法二、SQL分类三、DDL语句四、DML语句1.案例代码2.读出结果 五、DQL语句1.DQL-基本查询2.DQL-条件查询3.DQL-聚合函数4.DQL-分组查询5.DQL-排序查询6.DQL-分页查询7.DQL语句-执行顺序1.案例代码2.读出结果 六、DCL语句1.DCL-管理用户2.DCL-权限控制1.案例…

鸿蒙开发-UI-页面路由

鸿蒙开发-UI-组件 鸿蒙开发-UI-组件2 鸿蒙开发-UI-组件3 鸿蒙开发-UI-气泡/菜单 文章目录 一、基本概念 二、页面跳转 1.router基本概念 2.使用场景 3.页面跳转参数传递 三、页面返回 1.普通页面返回 2.页面返回前增加一个询问框 1.系统默认询问框 2.自定义询问框 总…

【Mysql】数据库架构学习合集

目录 1. Mysql整体架构1-1. 连接层1-2. 服务层1-3. 存储引擎层1-4. 文件系统层 2. 一条sql语句的执行过程2-1. 数据库连接池的作用2-2. 查询sql的执行过程2-1. 写sql的执行过程 1. Mysql整体架构 客户端&#xff1a; 由各种语言编写的程序&#xff0c;负责与Mysql服务端进行网…

【安装记录】Chrono Engine安装记录

本文仅用于个人安装记录。 官方安装教程 https://api.projectchrono.org/8.0.0/tutorial_install_chrono.html Windows下安装 windows下安装就按照教程好了。采用cmake-gui进行配置&#xff0c;建议首次安装只安装核心模块。然后依此configure下irrlicht&#xff0c;sensor…

J-Link:STM32使用J-LINK烧录程序,其他MCU也通用

说明&#xff1a;本文记录使用J-LINK烧录STM32程序的过程。 1. J-LINK驱动、软件下载 1、首先拥有硬件J-Link烧录器。 2、安装J-Link驱动程序SEGGER 下载地址如下 https://www.segger.com 直接下载就可以了。 2.如何使用J-LINK向STM32烧写程序 1、安装好以后打开J-LINK Fl…

从零开始:CentOS系统下搭建DNS服务器的详细教程

前言 如果你希望在CentOS系统上建立自己的DNS服务器,那么这篇文章绝对是你不容错过的宝藏指南。我们提供了详尽的步骤和实用技巧,让你能够轻松完成搭建过程。从安装必要的软件到配置区域文件,我们都将一一为你呈现。无论你的身份是运维人员,还是程序员,抑或是对网络基础设…

【脑电信号处理与特征提取】P7-涂毅恒:运用机器学习技术和脑电进行大脑解码

运用机器学习技术和脑电进行大脑解码 科学研究中的大脑解码 比如2019年在Nature上一篇文章&#xff0c;来自UCSF的Chang院士的课题组&#xff0c;利用大脑活动解码语言&#xff0c;帮助一些患者恢复语言功能。 大脑解码的重要步骤 大脑解码最重要的两步就是信号采集和信号…

Coremail启动鸿蒙原生应用开发,打造全场景邮件办公新体验

1月18日&#xff0c;华为在深圳举行鸿蒙生态千帆启航仪式&#xff0c;Coremail出席仪式并与华为签署鸿蒙合作协议&#xff0c;宣布正式启动鸿蒙原生应用开发。作为首批拥抱鸿蒙的邮件领域伙伴&#xff0c;Coremail的加入标志着鸿蒙生态版图进一步完善。 Coremail是国内自建邮件…

浏览器——HTTP缓存机制与webpack打包优化

文章目录 概要强缓存定义开启 关闭强缓存协商缓存工作机制通过Last-Modified If-Modified-Since通过ETag If-None-Match 不使用缓存前端利用缓存机制&#xff0c;修改打包方案webpack 打包webpack 打包名称优化webpack 默认的hash 值webapck其他hash 类型配置webpack打包 web…

数据结构-内部排序

简介 排序&#xff08;Sorting&#xff09;&#xff1a;将一个数据元素&#xff08;或记录&#xff09;的任意序列&#xff0c;重新排列成一个按关键字有序的序列 排序算法分为内部排序和外部排序 内部排序&#xff1a;在排序期间数据对象全部存放在内存的排序 外部排序&am…

MySQL-运维-主从复制

一、概述 二、原理 三、搭建 1、服务器准备 2、主库配置 &#xff08;1&#xff09;、修改配置文件/etc/my.cnf &#xff08;2&#xff09;、重启MySQL服务器 &#xff08;3&#xff09;、登录mysql&#xff0c;创建远程链接的账号&#xff0c;并授予主从复制权限 &#xff0…

3593 蓝桥杯 查找最大元素 简单

3593 蓝桥杯 查找最大元素 简单 // C风格解法1&#xff0c;通过率100%&#xff0c;多组数据处理样式//str "abcdefgfedcba" //abcdefg(max)fedcba//str "xxxxx" //x(max)x(max)x(max)x(max)x(max)#include<bits/stdc.h>const int N 1e2 10;char …

分类预测 | Matlab实现SCN-Adaboost随机配置网络模型SCN的Adaboost数据分类预测/故障识别

分类预测 | Matlab实现SCN-Adaboost随机配置网络模型SCN的Adaboost数据分类预测/故障识别 目录 分类预测 | Matlab实现SCN-Adaboost随机配置网络模型SCN的Adaboost数据分类预测/故障识别分类效果基本描述程序设计参考资料 分类效果 基本描述 1.Matlab实现SCN-Adaboost随机配置网…

vue——实现多行粘贴到table事件——技能提升

最近在写后台管理系统时&#xff0c;遇到一个需求&#xff0c;就是要从excel表格中复制多行内容&#xff0c;然后粘贴到后台系统中的table表格中。 如下图所示&#xff1a;一次性复制三行内容&#xff0c;光标放在红框中的第一个框中&#xff0c;然后按ctrlv粘贴事件&#xff0…

C#,桌面游戏编程,数独游戏(Sudoku Game)的算法与源代码

本文包括以下内容&#xff1a; &#xff08;1&#xff09;数独游戏的核心算法&#xff1b; &#xff08;2&#xff09;数独游戏核心算法的源代码&#xff1b; &#xff08;3&#xff09;数独游戏的部分题目样本&#xff1b; &#xff08;4&#xff09;适老版《数独》的设计原则…

WordPress如何使用SQL实现一键关闭/开启评论功能(已有评论)

WordPress本人就自带评论功能&#xff0c;不过由于种种原因&#xff0c;有些站长不想开启评论功能&#xff0c;那么应该怎么实现一键关闭评论功能或开启评论功能呢&#xff1f;或者针对已有评论功能的文章进行一键关闭或开启评论功能应该怎么操作&#xff1f; 如果你使用的Wor…

Walrus 0.5发布:重构交互流程,打造开箱即用的部署体验

开源应用管理平台 Walrus 0.5 已于近日正式发布&#xff01; Walrus 0.4 引入了全新应用模型&#xff0c;极大程度减少了重复的配置工作&#xff0c;并为研发团队屏蔽了云原生及基础设施的复杂度。Walrus 0.5 在这一基础上&#xff0c;通过重构交互流程、增强抽象能力&#xff…

【tensorflow 版本 keras版本】

#. 安装tensorflow and keras&#xff0c; 总是遇到版本无法匹配的问题。 安装之前先查表 https://master--floydhub-docs.netlify.app/guides/environments/ 1.先确定你的python version 2.再根据下面表&#xff0c;确定安装的tesorflow, keras

废品上门回收小程序搭建全过程

随着人们对环境保护意识的不断增强&#xff0c;废品回收成为了一项重要的社会活动。为了方便废品回收的顾客和回收者之间的联系&#xff0c;废品上门回收小程序成为了一种流行的解决方案。然而&#xff0c;如何选择一款合适的废品上门回收小程序搭建平台呢&#xff1f;下面将为…

缓存相关问题记录解决

缓存相关问题 在这里我不得不说明,我写的博客都是我自己用心写的,我自己用心记录的,我写的很详细,所以会有点冗长,所以如果你能看的下去的化,会有所收获,我不想写那种copy的文章,因为对我来说没什么益处,我写的这篇博客,就是为了记录我缓存的相关问题,还有我自己的感悟,所以如果…