TestDemo单头.html 46.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>CameraService</title>
    <meta http-equiv="content-type" content="text/html; charset=utf8" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script type="text/javascript" src="jquery.js"></script>    
    <script type="text/javascript" src="jquery.rotate.js"></script>
	<script type="text/javascript" src="./jquery-2.0.3.min.js"></script> 
    <!--[if IE 6]>
    <link rel="stylesheet" href="fix.css" type="text/css" />
	<![endif]-->
	<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
	
	
    
    var phi = 0;
	var camidx = 0; 
	var uuid = "";
	var filepath = "";
	var filelist = "";
	var isIE = false;
	
	var IdBase64 = "";
	var FaceBase64 = "";
	
	var index = 1;

	//修改
	//储存图片路径的变量和数组
	//var imgPath = "";
	var imgPathArray = new Array();
	var imgPathToPdfArray = new Array();
	
	var eqType = "";

	var timer = null;
	function BeginTimer()
	{
		if(timer == null)
		{
			timer = setInterval("GetData()", 3000);
		}
	}

	var Pdftimer = null;
	function BeginPdfTimer(ntime) 
    {
	    if (Pdftimer == null) {
	        Pdftimer = setInterval("GetPdfEx()", ntime * 1000);
	    }
	}
	
	function BrowserType()
	{
		var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
		if (userAgent.indexOf("Firefox") > -1) 
			return "Firefox";
		if (userAgent.indexOf("Chrome") > -1)
			return "Chrome";

		return "IE";
	}
	
	function IsIE()
	{		
		if (BrowserType() == "IE")
			return true;
		else
			return false;
	}
	
			//初始化
	function Init(){
		GetEquipmentType();
		isIE = IsIE();
		if(isIE) //ie浏览器
		{	
			var ui = document.getElementById("noniediv");
			ui.style.display="none";
			ui.style.visibility="hidden";		
			showVideoOcx.StartPreview(document.getElementById('device').selectedIndex);

		}
		else
		{
			var ui = document.getElementById("ocxdiv");
			ui.style.display="none";
			ui.style.visibility="hidden";	
			GetResolution();
			//SetResolution();
			//GetSonixserialNumber();
			OpenCamera();		
		}
	}
	

	function Load()
	{
		document.getElementById('device').add(new Option("主摄像头"));
		document.getElementById('device').add(new Option("副摄像头"));
		document.getElementById('device').selectedIndex = 0;
		
		document.getElementById('subtype').add(new Option("YUY2"));
		document.getElementById('subtype').add(new Option("MJPG"));
		document.getElementById('subtype').selectedIndex = 1;
		
		document.getElementById('jpg').add(new Option("默认质量"));
		document.getElementById('jpg').add(new Option("高质量"));
		document.getElementById('jpg').add(new Option("较高质量"));
		document.getElementById('jpg').add(new Option("中等质量"));
		document.getElementById('jpg').add(new Option("较差质量"));
		document.getElementById('jpg').add(new Option("差质量"));
		document.getElementById('jpg').selectedIndex = 0;
		
		document.getElementById('colorMode').add(new Option("彩色模式"));
		document.getElementById('colorMode').add(new Option("灰色模式"));
		document.getElementById('colorMode').add(new Option("黑白模式"));
		document.getElementById('colorMode').add(new Option("白纸印章"));
		document.getElementById('colorMode').add(new Option("去除背景"));
		document.getElementById('colorMode').selectedIndex = 0;
			
		Init();
		GetAudioList();
		//OpenSerialport(); //需要在打开APP软件才可以打开成功
	}


	function Unload()
	{
		if(isIE)
		{
			showVideoOcx.StopPreview();
		}	
		else
		{
			CloseCamera();
		}
	}

	
	function OpenSerialport()
	{
		var params = "{\"port\":\"0\", \"baud\":\"115200\",\"parity\":\"0\",\"databits\":\"8\",\"stopbits\":\"0\"}"; 
	    var url = "http://127.0.0.1:38088/serialport=initserialport";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "打开端口成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "打开端口失败");
				}
	        }
	    });	
	}
	
	
	function CloseSerialport()
	{
		var params = "{\"port\":\"0\"}"; 
	    var url = "http://127.0.0.1:38088/serialport=deinitserialport";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭端口成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭端口失败");
				}
	        }
	    });	
	}
	

	
	function GetResolution()
	{
		document.getElementById('resolution').options.length = 0;
		var DevIndex = document.getElementById('device').selectedIndex;
		var nMode = document.getElementById('subtype').selectedIndex;
		var params = "{\"camidx\":\"" + DevIndex + "\",\"mode\":\"" + nMode + "\"}"; 
	    var url = "http://127.0.0.1:38088/device=getresolution";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var select = document.getElementById("resolution");
					//获取select下拉框下所有的选项
					while(select.options.length > 0)
					{
						select.remove(i);
					}
					
					var arrays = data.data.split("|");
					for(var i=0; i<arrays.length; i++)
					{
						select.options.add(new Option(arrays[i], arrays[i])); 
					}
							
					var date = new Date().toLocaleString();
					log(date + '\t' + "分辨率数据:" + data.data);
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "分辨率数据失败");
				}
	        }
	    });	
	}
	
	
	function OpenCamera()
	{
		var DevIndex = document.getElementById('device').selectedIndex;
		
		if(isIE)
		{
			showVideoOcx.StartPreview(DevIndex);
		}	
		else
		{
			document.getElementById("ImgMain").src = "";	
			document.getElementById("ImgMain").src = "http://127.0.0.1:38088/video=stream&camidx=" + DevIndex;
		}
	}
	
	function CloseCamera()
	{	
		var DevIndex = document.getElementById('device').selectedIndex;	
		
		if(isIE)
		{
			showVideoOcx.StopPreview();
		}	
		else
		{
			var params = "{\"camidx\":\"" + DevIndex + "\"}"; 
			var url = "http://127.0.0.1:38088/video=close";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭视频成功");
					document.getElementById("ImgMain").src = "";	
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭视频失败");
				}
	        }
			});	
		}
	}
	
	
	function IsDeviceConnect()
	{
		var params = ""; 
		var url = "http://127.0.0.1:38088/device=isconnect";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "摄像头数量:" + data.data);
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取序列号失败");
				}
	        }
	    });
	}
	
	function selectDevice()
	{
		var Cameraflag = 0;
		var DevIndex = document.getElementById('device').selectedIndex;	
		
		if(Cameraflag != DevIndex)		//关闭上次Camera
		{
			Cameraflag = 0;
		}
		else
		{
			Cameraflag = 1;
		}
		
		if(isIE)
		{
			showVideoOcx.StopPreview();
		}	
		else
		{
			var params = "{\"camidx\":\"" + Cameraflag + "\"}"; 
			var url = "http://127.0.0.1:38088/video=close";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭视频成功");
					document.getElementById("ImgMain").src = "";	
					GetResolution();
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭视频失败");
				}
	        }
			});	
		}
		
	}

	function SetResolution()
	{	
		var DevIndex = document.getElementById('device').selectedIndex;
		var nMode = document.getElementById('subtype').selectedIndex;
		
		var select_resolution = document.getElementById("resolution");
		var index_resolution = select_resolution.selectedIndex;		
		var text_resolution = select_resolution.options[index_resolution].text
		var splits = text_resolution.split("*");
		
		var params = "{\"camidx\":\"" + DevIndex + "\",\"mode\":\"" + nMode + "\",\"width\":\"" + splits[0] + "\",\"height\":\"" + splits[1] + "\"}"; 
	    var url = "http://127.0.0.1:38088/device=setresolution";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "分辨率设置成功" );
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "分辨率设置失败");
				}
	        }
	    });	
	}
	
	
	
	
	//参数说明:quality
	//对于 jpg 格式,0表示默认,1 表示高质量,2 表示较高质量,3 表示中等质量),4 表示较差 质量,5 表示差质量
	function GrabImage() 
	{
		var DevIndex = document.getElementById('device').selectedIndex;
		var jpgindex = document.getElementById('jpg').selectedIndex;
	    var cutpage = 0;// document.getElementsByName("cutpage");
		
	//var filepath = "D:\\GrabImage_hImage_pBase64.jpg";
		
		var ClolorIndex = document.getElementById('colorMode').selectedIndex;
		var params = "{\"filepath\":\"\",\"rotate\":\"" + "0" + "\",\"camidx\":\"" + DevIndex + "\",\"cutpage\":\"" +  "0" + "\",\"quality\":\"" +  jpgindex + "\",\"ClolorMode\":\"" + ClolorIndex + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=grabimage";
		
		$.ajax({
	        type: "post",
	       url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
	            if (data.code != 0) 
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "生成图片失败");
	               document.getElementById("result").innerHTML = "GrabImage 失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message;
	            }
	            else 
				{		
				    addImgDiv(data.photoBase64);
	           }
	        }
	    });
	}

	function SetImageSize()
	{
		//默认为分辨率的宽和高,也支持手动输入自定义宽高
		//width:value range[640, 3648]    height:value range[480, 2736]
		//var select_resolution = document.getElementById("resolution");
		//var index_resolution = select_resolution.selectedIndex;		
		//var text_resolution = select_resolution.options[index_resolution].text;
		//var splits = text_resolution.split("*");
		//var width = splits[0];
		//var height = splits[1];
		var width = 1920;
		var height = 1080;
		
		//var params = "{\"width\":\"" + splits[0] + "\",\"height\":\"" + splits[1] + "\"}";
		var params = "{\"height\":\"" + height + "\",\"width\":\"" + width + "\"}";
		
		
	    var url = "http://127.0.0.1:38088/dvideo=setimageSize";
	
		$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if (data.code != 0) 
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置宽高失败");					
	            }
	            else 
				{	
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置宽高成功:" + width + "*" + height);
				}				
	        }	
	    });
	
	}

	function GrabImageBase64() 
	{
		var DevIndex = document.getElementById('device').selectedIndex;
		FaceBase64 = "";
	    var cutpage = document.getElementsByName("cutpage");
	    var params = "{\"filepath\":\"base64\",\"rotate\":\"" + phi.toString() + "\",\"camidx\":\"" + DevIndex + "\",\"cutpage\":\"" +  "0"  + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=grabimage";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
					FaceBase64 = data.photoBase64;
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取图片base64数据:" + data.photoBase64);
					//document.getElementById("snapshot").src = "data:image/jpg;base64," + data.data;
					document.getElementById("snapshot").src = "data:image/jpg;base64," + data.photoBase64;
					document.getElementById("result").innerHTML = "";
					
	        }
	    });
	}	
	

	
	function GrabImagebyautoflat() 
	{
	    var cutpage = 0;// document.getElementsByName("cutpage");
		var leftfilepath = "D://testleft.jpg";
		var rightfilepath = "D://testright.jpg";
		var autoflat = "\"autoflat\":{\"flat\":\"1\",\"leftfilepath\":\"" + leftfilepath.toString() + "\",\"rightfilepath\":\"" + rightfilepath.toString() + "\",\"removefinger\":\"1\",\"doublepage\":\"1\"}";	
		var params = "{\"filepath\":\"\",\"rotate\":\"" + "0" + "\",\"camidx\":\"" + "0" + "\",\"cutpage\":\"" +  "0" + "\"," + autoflat + "}"; 
	    var url = "http://127.0.0.1:38088/video=autoflat";
	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
	            if (data.code != 0) 
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "生成图片失败");
	                document.getElementById("result").innerHTML = "GrabImage 失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message;
	            }
	            else 
				{		
					//index = index + 1;
					//AddPhotoToPDF(data.filepath); //将图片添加到PDF队列中
	                //document.getElementById("snapshot").src = "http://127.0.0.1:38088/video=snapshot&id=" + data.uuid;
	                //uuid = data.uuid;
	                //filepath = data.filepath;
					//var date = new Date().toLocaleString();
	                //log(date + '\t' + "生成图片路径:" + filepath);

				    //addImgDiv(data.filepath);
				    addImgDiv(data.photoBase64);
					addImgDiv(data.leftphotoBase64);
					addImgDiv(data.rightphotoBase64);
	                //alert(data.photoBase64);
	            }
	        }
	    });
	}

	function GetSignData() 
	{	
		if(timer != null)
		{
			clearInterval(timer);	
			timer=null;
		}
		
		var params = ""; 
		var url = "http://127.0.0.1:38088/pendisplay=getsigndata";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					document.getElementById("photo").src= "data:image/gif;base64," + data.data;
					var date = new Date().toLocaleString();
					log(date + '\t' + "remark: " + data.remark + '\t' +"签名图片base64数据:" + data.data);
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取数据失败原因:" + data.message + '\t');
				}
	        }
	    });
	}
	

	function StartSignDlg()
	{
		if(timer != null)
		{
			clearInterval(timer);	
			timer=null;
		}		
		var params = ""; 
		if("GR820" == eqType)//无系统
		{
			params = "{\"pos\": {\"top\":\"250\",\"left\":\"280\",\"width\":\"600\",\"height\":\"250\"},\"remark\":\"" + "开始签名" + "\"}"; 
		}
		
		var url = "http://127.0.0.1:38088/serialport=sign";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "签名窗口弹出成功");
					BeginTimer();
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "签名窗口弹出失败");
				}
	        }
	    });
	}

	function StartAppraiseDlg()
	{
		if(timer != null)
		{
			clearInterval(timer);	
			timer=null;
		}
		var params = ""; 
		var url = "http://127.0.0.1:38088/serialport=appraise";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "评价窗口弹出成功");
					BeginTimer();
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "评价窗口弹出失败");
				}
	        }
	    });
	}

	function GetData()
	{

	    var params = ""; 
	    var url = "http://127.0.0.1:38088/serialport=getdata";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
			
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取签名数据:" + data.data);
					document.getElementById("snapshot").src = "data:image/jpg;base64," + data.data;
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取数据错误");
				}
	        }
	    });
		
		if(timer != null)
		{
			clearInterval(timer);	
			timer=null;
		}		
	}

	
	function FaceComparisonEx()
	{
		var params = "{\"FaceOne\":\"" + IdBase64.toString() + "\",\"FaceTwo\":\"" + FaceBase64.toString() + "\"}"; 
	    var url = "http://127.0.0.1:38088/comparison=imgdata";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "人证比对值一般大于50可以认为是同一个人,比对值为:" + data.data);
				}
				else if(data.code != 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "错误原因:" + data.data);
				}			
	        }
	    });
	}	
	
	function ReadIDCard() 
	{
	IdBase64 = "";
	document.getElementById("result").innerHTML = "二代证信息获取请求中......";
	var params = "";
	var url = "http://127.0.0.1:38088/card=idcard";  	

	$.ajax({  
		type: "post",  
		url: url,  
		dataType: "json", 
		data: params,
		success: function(data)
		{
			if(data.code != 0)
			{
				document.getElementById("result").innerHTML = "ReadIDCard 失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message; 	
			}
			else
			{
				document.getElementById("result").innerHTML = "ReadIDCard <br />返回代码:" + data.code + 
																		 "<br />返回信息:" + data.message +
																		 "<br />姓名:" + data.IDCardInfo.name + 	
																		 "<br />性别:" + data.IDCardInfo.sex +
																		 "<br />民族:" + data.IDCardInfo.nationCode +
																		 "<br />生日:" + data.IDCardInfo.birthday +
																		 "<br />地址:" + data.IDCardInfo.address +
																		 "<br />身份证号:" + data.IDCardInfo.cardID +
																		 "<br />发卡机构:" + data.IDCardInfo.issueOrgan + 
																		 "<br />有效时间:" + data.IDCardInfo.validStart + "-" + data.IDCardInfo.validEnd;
				document.getElementById("photo").src= "data:image/gif;base64," + data.IDCardInfo.photoBase64;
				IdBase64 = data.IDCardInfo.photoBase64;
			}
		}  
		});  
	}
	
	
	function AddPhotoToPDF(PhotoPath)
	{
		var sImagepath = PhotoPath;
		//var params = "{\"ImagePath\":\"" + sImagepath.toString() + "\"}";
		var params = "{\"ImagePath\":\"\", \"ImageBase64\":\"" + sImagepath.toString() + "\"}"; 
	    var url = "http://127.0.0.1:38088/pdf=addimage";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "添加图片到PDF队列成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "添加图片到PDF队列失败");
				}
	        }
	    });	
	}



	function GetPdfEx() 
    {
        if (Pdftimer != null) {
            clearInterval(Pdftimer);
            Pdftimer = null;
        }	

        var sPdfpath = "D:/HttpCamera/test.pdf";
        var params = "{\"PdfPath\":\"" + sPdfpath.toString() + "\"}";
        var url = "http://127.0.0.1:38088/pdf=save";

        $.ajax({
            type: "post",
            url: url,
            dataType: "json",
            data: params,
            success: function (data) {
                if (data.code == 0) {
                    var date = new Date().toLocaleString();
                    //log(date + '\t' + "生成PDF成功:路径是D:/HttpCamera/test.pdf" + '\t' + "Base64数据是:" + data.data);
                    log(date + '\t' + "生成PDF成功:路径是D:/HttpCamera/test.pdf");
                    //alert(data.data);
                }
                else {
                    var date = new Date().toLocaleString();
                    log(date + '\t' + "生成PDF失败,原因:" + data.data);
                }
            }
        });
	}
	
	function GetPDF()
	{
	    for (var i = 0; i < imgPathToPdfArray.length; i++) 
        {
            AddPhotoToPDF(imgPathToPdfArray[i]);
        }

        var ntime;
        ntime = imgPathToPdfArray.length / 5;
        //alert(ntime);
        BeginPdfTimer(ntime);
	}
	
	
	
	function Rotate90()
	{
		var DevIndex = document.getElementById('device').selectedIndex;
		var params = "{\"camidx\":\"" + DevIndex + "\",\"rotate\":\"" + "90" + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=rotate";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置旋转角度成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置旋转角度失败");
				}
	        }
	    });	
	}
	
	
	
	function Rotate270()
	{
		var DevIndex = document.getElementById('device').selectedIndex;
		var params = "{\"camidx\":\"" + DevIndex + "\",\"rotate\":\"" + "270" + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=rotate";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置旋转角度成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置旋转角度失败");
				}
	        }
	    });	
	}


	function FaceLive()
	{
		var date1 = new Date().toLocaleString();
		log(date1 + '\t' + "开始活体比对");
		var params = "{\"time\":\"" + "10" + "\"}"; 
	    var url = "http://127.0.0.1:38088/faceLive=start";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					if(data.data == 1)
					{
						var date = new Date().toLocaleString();
						log(date + '\t' + "活体比对结果:比对通过");
					}
					else
					{
						var date = new Date().toLocaleString();
						log(date + '\t' + "活体比对结果:比对不通过");
					}
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "活体比对失败");
				}
	        }
	    });	
	}


	function GetBarcode()
	{
		var date = new Date().toLocaleString();
		log(date + '\t' + "开始读取");
		
		var params = "{\"time\":\"" + "20" + "\"}"; 
	    var url = "http://127.0.0.1:38088/barcode=get";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					
					var obj2 = eval(data);
					var count = obj2.data.length;
					for(var i=0;i<count;i++)
					{
						var date = new Date().toLocaleString();
						log(date + '\t' + "识别数据:" + obj2.data[i].barcodedata);
					}
					
				}
				else if(data.code == 1)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "识别超时");
				}	
				else if(data.code == 2)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "其他错误");
				}				
	        }
	    });
	}


	function GetBiokey()
	{
		var date = new Date().toLocaleString();
		log(date + '\t' + "开始读取");
		
		var params = "{\"time\":\"" + "20" + "\"}"; //暂时没有意义
	    var url = "http://127.0.0.1:38088/biokey=get";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "指纹base64:" + data.data);
					document.getElementById("snapshot").src = "data:image/bmp;base64," + data.data;
					
				}
				else if(data.code == 1)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "失败");
				}	
			
	        }
	    });
	}



	
	function SetA3A4Switch(obj)
	{
		var params;
		if (obj.checked)
		{
			params = "{\"switchflag\":\"" + "1" + "\",\"a3size\":\"" + "0.5" + "\",\"a4size\":\"" + "0.9" + "\"}"; 
		}
		else
		{
			params = "{\"switchflag\":\"" + "0" + "\",\"a3size\":\"" + "0.5" + "\",\"a4size\":\"" + "0.9" + "\"}"; 
		}
		
	    var url = "http://127.0.0.1:38088/device=a3a4switch";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "切换成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "切换失败");
				}
	        }
	    });
	}

	
	function GetSonixserialNumber()
	{
		var params = ""; 
		var url = "http://127.0.0.1:38088/device=getsonixserialnumber";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "序列号:" + data.data);
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取序列号失败");
				}
	        }
	    });
	}
	
	function GetEquipmentType()
	{
		var params = ""; 
		var url = "http://127.0.0.1:38088/device=getequipmenttype";
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设备型号:" + data.data);
					eqType = data.data;
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取设备型号失败");
				}
	        }
	    });
	}
	
	
	function GetAudioList() 
	{
		document.getElementById("result").innerHTML = "获取音频设备列表... ...";
		
		var params = "{\"action\": \"audio\"}";// 识别区域
		var url = "http://127.0.0.1:38088/video=record";  

		$.ajax({  
			type: "post",  
			url: url,  
			dataType: "json", 
			data: params,
			success: function(data)
			{				
				if(data.code != 0)
				{
					document.getElementById("result").innerHTML = "获取音频设备列表失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message; 	
				}
				else				
				{
					var select = document.getElementById("audio_list");
					//获取select下拉框下所有的选项
					while(select.options.length > 0)
					{
						select.remove(i);
					}
					

					for(var i=0; i<data.audio.length; i++)
					{
						select.options.add(new Option(data.audio[i], data.audio[i])); 
					}
										
					document.getElementById("result").innerHTML = "获取音频设备列表成功<br />返回代码 = " + data.code; 						
				}  
			}
		});  					
	}	
	
	function GetRecordVideoStatus() {
	
		var params = "{\"action\": \"status\"}";// 
		var url = "http://127.0.0.1:38088/video=record"; 
		

		$.ajax({  
			type: "post",  
			url: url,  
			dataType: "json", 
			data: params,
			success: function(data)
			{				
				if(data.code != 0)
				{
					document.getElementById("result").innerHTML = "获取当前视频录制状态失败,返回代码 = " + data.code + ",返回信息 = " + data.message; 	
				}
				else				
				{		
					if(data.status == 100)
					{
						document.getElementById("result").innerHTML = data.message; 	
					}
					else if(data.status == 101)
					{
						document.getElementById("result").innerHTML = data.message + " " + data.time; 	
					}
					else if(data.status == 102)
					{
						document.getElementById("result").innerHTML = data.message; 	
					}
				}  
			}  
			});  
	}		
	
	function StartRecordVideo_WM() 
	{
		document.getElementById("result").innerHTML = "请求开始视频录制... ...";
		
		var DevIndex = document.getElementById('device').selectedIndex;	
	
		var select_resolution = document.getElementById("resolution");
		var index_resolution = select_resolution.selectedIndex;		
		var text_resolution = select_resolution.options[index_resolution].text
		var splits = text_resolution.split("*");
		
		var select = document.getElementById("audio_list");
		var index = select.selectedIndex;		
		var text = "";
		if(index >= 0)
		{
			text = select.options[index].text;
		}
		var sfilepath = "D:/el_test.mp4";
		var watermark = "\"watermark\":{\"pos\":\"2\",\"content\":\"我是水印\",\"transparency\":\"250\",\"fontsize\":\"50\",\"font\":\"微软雅黑\",\"color\":\"red\"}";		
		var params = "{\"action\": \"start\", \"parameter\": {\"camidx\": \"" + DevIndex + "\",\"width\": \"" + splits[0] + "\",\"height\":\"" + splits[1] + "\",\"framerate\": \"15\",\"filepath\": \"" + sfilepath.toString() + "\",\"audio\": \"" + text + "\"," + watermark + "}}";// 
		var url = "http://127.0.0.1:38088/video=record";  

		$.ajax({  
			type: "post",  
			url: url,  
			dataType: "json", 
			data: params,
			success: function(data)
			{				
				if(data.code != 0)
				{
					document.getElementById("result").innerHTML = "视频录制失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message; 	
				}
				else				
				{									
					document.getElementById("result").innerHTML = "开始视频录制<br />返回代码 = " + data.code + "<br />  文件路径 = " + data.filepath; 						
				}  
			}
		});  					
	}
	

	function StartRecordVideo()
	{
		document.getElementById("result").innerHTML = "请求开始视频录制... ...";
		
		var DevIndex = document.getElementById('device').selectedIndex;	
		
		var select_resolution = document.getElementById("resolution");
		var index_resolution = select_resolution.selectedIndex;		
		var text_resolution = select_resolution.options[index_resolution].text
		var splits = text_resolution.split("*");
		
		var select = document.getElementById("audio_list");
		var index = select.selectedIndex;		
		var text = "";
		if(index >= 0)
		{
			text = select.options[index].text;
		}

		var params = "{\"action\": \"start\", \"parameter\": {\"camidx\": \"" + DevIndex + "\",\"width\": \"" + splits[0] + "\",\"height\":\"" + splits[1] + "\",\"framerate\": \"15\",\"audio\": \"" + text + "\"}}";// 
		var url = "http://127.0.0.1:38088/video=record";  

		$.ajax({  
			type: "post",  
			url: url,  
			dataType: "json", 
			data: params,
			success: function(data)
			{				
				if(data.code != 0)
				{
					document.getElementById("result").innerHTML = "视频录制失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message; 	
				}
				else				
				{									
					document.getElementById("result").innerHTML = "开始视频录制<br />返回代码 = " + data.code + "<br />  文件路径 = " + data.filepath; 						
				}  
			}
		});  					
	}
	
	function StopRecordVideo() {
		
		var params = "{\"action\": \"stop\"}";// 
		var url = "http://127.0.0.1:38088/video=record";  

		$.ajax({  
			type: "post",  
			url: url,  
			dataType: "json", 
			data: params,
			success: function(data)
			{				
				if(data.code != 0)
				{
					document.getElementById("result").innerHTML = "停止视频录制失败<br />返回代码 = " + data.code + "<br />  返回信息 = " + data.message; 	
				}
				else				
				{
										
					document.getElementById("result").innerHTML = "停止视频录制成功<br />返回代码 = " + data.code; 						
				}  
			}
		});  					
	}	
	
	
		function AutoScan()
	{
		//var date = new Date().toLocaleString();
		//log(date + '\t' + "自动拍照开始");
		var sListpath = "D://HttpCamera";
		var params = "{\"movedetecflag\":\"" + "1" + "\",\"listpath\":\"" + sListpath.toString() + "\",\"filepath\":\"" + "LT" + "\"}"; 
		//var params = "{\"MoveDetecFlag\":\"" + "1" + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=movedetec";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					//var date = new Date().toLocaleString();
					//log(date + '\t' + "识别数据:" + data.data);
					addImgDiv(data.data);
					AutoScan();
				}
				else if(data.code == 1)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "自动连拍停止");
				}				
	        }
	    });
	}


	function AutoScanStop()
	{
		var date = new Date().toLocaleString();
		log(date + '\t' + "自动拍照关闭");
		
		var params = "{\"movedetecflag\":\"" + "1" + "\",\"listpath\":\"" + sListpath.toString() + "\",\"filepath\":\"" + "LT" + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=movedetec";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "关闭自动连拍成功");				
				}
			}
	    });
	}
	
	
	function OCR()
	{
		var date = new Date().toLocaleString();
		log(date + '\t' + "ocr开始");
		
		var sOcrpath = "D://ocr123.pdf";
		var sPicpath = "D://ocr123.jpg";
		var params = "{\"ocrflag\":\"" + "1" + "\",\"picfilepath\":\"" + sPicpath.toString() + "\",\"savefilepath\":\"" + sOcrpath.toString() + "\"}"; 
	    var url = "http://127.0.0.1:38088/video=ocr";

	    $.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "ocr结束");
					log(date + '\t' + data.data);		
				}
			}
			
	    }).fail(function (data) {
					log(date + '\t' + "ocr失败,仅支持文本文件");
		});
	}
	
	
	//参数说明
	// camidx:摄像头索引值
	
	//mode 0:VideoProc 数据  ; 1:CameraControl数据
	
	//1、当mode = 0 时,表示设置VideoProc 参数,参数prop的意义:
	//prop 视频的各个属性,0x1表示亮度,0x2表示对比度,0x3表示饱和度,0x4表示色调, 0x5表示清晰度,0x6表示伽马,0x7表示白平衡,0x8表示逆光对比,0x9表示启用颜色, 0xA表示增益 
	//2、当mode = 1 时,表示设置CameraControl 参数,参数prop的意义:
	//prop 照相机的各个属性,0x1表示曝光,0x2表示全景,0x3表示倾斜,0x4表示滚动,0x5 表示缩放,0x6表示光圈,0x7表示焦点

	//3.value 要设置的prop对应属性的实际值  
	
	//4.bAuto 是否启用自动
	function SetDeviceAttribute()
	{
		var params;
		//该示例设置曝光值为-7
		params = "{\"camidx\":\"" + "0" + "\",\"mode\":\"" + "1" + "\",\"prop\":\"" + "1" + "\",\"value\": -1,\"bAuto\":\"" + "0" + "\"}"; 

	    var url = "http://127.0.0.1:38088/device=setdeviceattribute";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置成功");
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "设置失败");
				}
	        }
	    });
	}
	
	
	
	//参数说明
	// camidx:摄像头索引值
	//mode 0:VideoProc 数据  ; 1:CameraControl数据
	//1、当mode = 0 时,表示设置VideoProc 参数,参数prop和参数value的意义:
	//prop 视频的各个属性,0x1表示亮度,0x2表示对比度,0x3表示饱和度,0x4表示色调, 0x5表示清晰度,0x6表示伽马,0x7表示白平衡,0x8表示逆光对比,0x9表示启用颜色, 0xA表示增益
	//value  prop对应的值的类型,0x1表示最小值,0x2表示最大值,0x3表示步长,0x4表示默 认值,0x5表示实际值,0x6表示是否自动设置
	//2、当mode = 1 时,表示设置CameraControl 参数,参数prop的意义:
	//3. prop 照相机的各个属性,0x1表示曝光,0x2表示全景,0x3表示倾斜,0x4表示滚动,0x5 表示缩放,0x6表示光圈,0x7表示焦点
	//4.value  prop对应的值的类型,0x1表示最小值,0x2表示最大值,0x3表示步长,0x4表示默 认值,0x5表示实际值,0x6表示是否自动设置
	function GetDeviceAttribute()
	{
		var params;
		//该示例获取设备的最小曝光值
		params = "{\"camidx\":\"" + "0" + "\",\"mode\":\"" + "1" + "\",\"prop\":\"" + "1" + "\",\"value\":\"" + "1" + "\"}"; 

	    var url = "http://127.0.0.1:38088/device=getdeviceattribute";
		
			$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) {
				if(data.code == 0)
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取成功,数值为" + data.data);
				}
				else
				{
					var date = new Date().toLocaleString();
					log(date + '\t' + "获取失败");
				}
	        }
	    });
	}

	//修改
	//预览图片
	function openImage(imageItem) {
	    var url = imageItem.parentNode.id;
	    window.showModalDialog(url, null, "dialogHeight:800px; dialogWidth:1000px; resizable:no");
	    //var top = screen.availHeight - 500;
	    //var left = screen.availWidth - 170;
	   // window.open("./new.html", 'newwindow', 'height=500, width=770, top=' + top + ', left=' + left + ', toolbar=no, menubar=no, scrollbars=yes,resizable=no,location=no, status=no');
	}

	//增加图片缩略图
	function addImgDiv(imgPath) 
    {   
	    var container = document.getElementById('container');
	    var newchild = document.createElement("div");
	    newchild.setAttribute("style", "float:left");
	    imgPathToPdfArray.push(imgPath);
	    //imgPath = "file:///" + imgPath;
	    newchild.setAttribute("id", imgPath);
	    imgPathArray.push(imgPath); ////增加缩略图时默认把路径加入图片数组
	    newchild.innerHTML = "<img width='105' height='85' src='" + "data:image/jpg;base64," + imgPath + "' onclick='openImage(this)' /></img><input type='checkbox' checked='checked' onchange='checkboxClicked(this)' />";
	    container.appendChild(newchild);
	}

	//清空缩略图
	function removeAll() {
	    document.getElementById('container').innerHTML = "";
	    imgPathArray = [];
	    imgPathToPdfArray = [];
	}

	//处理缩略图CheckBox点击事件
	function checkboxClicked(checkboxItem) 
    {
        if (imgPathArray.indexOf(checkboxItem.parentNode.id) < 0)
        {
	        imgPathArray.push(checkboxItem.parentNode.id);
	        imgPathToPdfArray.push(checkboxItem.parentNode.id);
	    }
         else 
        {
	        var index = imgPathArray.indexOf(checkboxItem.parentNode.id);
	        imgPathArray.splice(index, 1);
	        imgPathToPdfArray.splice(index, 1);
	    }
	}


	
	function clean()
	{
		document.getElementById("objLog").value="";
	}
	
	
	function log(s) 
	{
        var oldValue = document.getElementById("objLog").value;
        if (oldValue.length > 0)
        {
            oldValue += "\n";
        }
            
        document.getElementById("objLog").value = s + "\n" + oldValue;
     }
	 
	 
	 

	 
	function CameraFaceComparisonEx()
	{
	
		// 这是传入的数据
		var hu_res = "";
		data = {
			"filepath": "base64",
			"camidx": "1",
			"cutpage": "0",
			"rotate": "0",
		}
		$.post("http://127.0.0.1:38088/video=grabimage", JSON.stringify(data), function(res){
			hu_res = res.photoBase64;
		})
		
		// qingqiu
		//var params = "{\"FaceOne\":\"" + FaceBase64.toString() + "\"}"; 
	//	var params = {
	//		"FaceOne": hu_res
	//	}
	  //  var url = "http://127.0.0.1:38088/cameracomparison=imgdata";
	//	$.post("http://127.0.0.1:38088/cameracomparison=imgdata", JSON.stringify(params), function(res){
		//	if(data.code == 0)
		//		{
		//			var date = new Date().toLocaleString();
		//			log(date + '\t' + "人证比对值一般大于50可以认为是同一个人,比对值为:" + data.data);
		//		}
		//		else if(data.code != 0)
		//		{
		//			var date = new Date().toLocaleString();
		//			log(date + '\t' + "错误原因:" + data.data);
		//		}	
	//	})
	
	
		showVideoOcx.CameraFaceComparsion(hu_res);   
		
	}
	
	function MainCameraDeskew()	 
	 {
		var params = "{\"camidx\":\"" + 0 + "\",\"open\":\"" + "1" +"\"}";				
	    var url = "http://127.0.0.1:38088/dvideo=cameradeskew";
	
		$.ajax({
	        type: "post",
	        url: url,
	        dataType: "json",
	        data: params,
	        success: function (data) 
			{
				var date = new Date().toLocaleString();
				log(date + '\t' + data.data);		
	        }	
	    });
	 
	 }
	 
	 function GrabImageIE()	 
	 {
	 	var  filPath = "D:\\GrabImage_hImage_pBase641111.jpg"
	    var base64;
		base64 = showVideoOcx.GrabImageIE(filPath.toString(), 1);
		alert(base64);
		
	 }
	 
	
	
	
	</script>
  </head>

  <body onload="Load()" onunload="Unload()" onbeforeunload="Release()">
    <div id="sidebar">
      <h1>CameraService Demo Page</h1>	  
	  <h2>Function</h2>
    </div>

	
	<div id="noniediv">
	<p class="xform-p"></p>
	<p id="streamwrap" class="xform-p">
		<img id="ImgMain" class="xform" WIDTH="400" HEIGHT="300" onerror="onerror=null;src='app_stop.jpg'"/>
		
	</p>	
	</div>
	<!-- 如果是ie浏览器,会显示ocx -->	
	<div id="ocxdiv">
		<OBJECT classid="clsid:A4B4E9B5-78E6-4CE3-B8A1-4B36237943F8" id="ocxstreamimage" name="showVideoOcx"  width="360px" height="270px"></OBJECT>
	</div>	
	
   	</br>
	设备列表:<select id="device" style="width: 90px" onchange="selectDevice()"></select> 
	视频模式:<select id="subtype" style="width: 90px" ></select> 
	分辨率:<select id="resolution" style="width: 90px" ></select> 
	<input type="button" onclick="SetResolution()" value="设置分辨率和视频模式(打开摄像头前调用有效)" />
	<input type="button" onclick="OpenCamera()" value="Open(打开摄像头)" style="width:200px" />
	<input type="button" onclick="CloseCamera()" value="Close(关闭摄像头)" style="width:200px" /> 	
	<input type="button" onclick="MainCameraDeskew()" value="开启/关闭主头纠偏" style="width:200px" /> 
	<input type="button" onclick="GetSonixserialNumber()" value="获取设备序列号(打开摄像头前调用有效)" style="width:300px" /> 
	<input type="button" onclick="GetEquipmentType()" value="获取设备型号" style="width:200px" /> 
	<input type="button" onclick="IsDeviceConnect()" value="IsDeviceConnect(判断设备连接)"  style="width:200px"/> 
	<input id="ChangeA3A4" type="checkbox" value="" onclick="SetA3A4Switch(this)" />A3A4切换
	jpg质量:<select id="jpg" style="width: 90px""></select> 
	</br>
	音频设备列表:<select id="audio_list" style="width: 180px">
	<input type="button" onclick="GetAudioList()" value="音频设备列表获取"/> 
	<input type="button" onclick="StartRecordVideo()" value="开始录像"/> 	
	<input type="button" onclick="StartRecordVideo_WM()" value="开始录像(加水印)"/> 	
	<input type="button" onclick="StopRecordVideo()" value="停止录像"/>  			
	<input type="button" onclick="GetRecordVideoStatus()" value="获取录像状态"/> 
	</br>
	<input type="button" onclick="Rotate90()" value="Rotate(左转90)" style="width:200px" /> 
	<input type="button" onclick="Rotate270()" value="Rotate(右转90)" style="width:200px" /> 
	色彩模式:<select id="colorMode" style="width: 90px" ></select>	
	<input type="button" onclick="GrabImage()" value="GrabImage(拍照保存在本地)" style="width:200px" />
	<input type="button" onclick="GrabImageIE()" value="GrabImageIE(拍照保存在本地)" style="width:200px" />
	<input type="button" onclick="SetImageSize()" value="SetImageSize(设置图片宽高)" style="width:200px"/>	
	<input type="button" onclick="ComposeImage()" value="ComposeImage(合成图片)"  style="width:200px"/>	   	
	<input type="button" onclick="GrabImageBase64()" value="GrabImage(获取图片Base64)"  style="width:200px"/> 
	</br>
	<input type="button" onclick="GrabImagebyautoflat()" value="GrabImagebyautoflat(展平拍照)" style="width:200px" />  	
	<input type="button" onclick="AutoScan()" value="AutoScan(自动拍照)"  style="width:200px"/>
	<input type="button" onclick="AutoScanStop()" value="AutoScanStop(关闭自动拍照)"  style="width:200px"/>	

	</br>
	<input type="button" onclick="GetBarcode()" value="GetBarcode(识别条码)"  style="width:200px"/>
	<input type="button" onclick="ReadIDCard()" value="ReadIDCard(读身份证)"  style="width:200px"/>	
	<input type="button" onclick="FaceComparisonEx()" value="FaceComparisonEx(人证比对)"  style="width:200px"/> 
	<input type="button" onclick="FaceLive()" value="FaceLive(活体比对)"  style="width:200px"/>
	<input type="button" onclick="CameraFaceComparisonEx()" value="FaceComparisonEx(实时人证比对)"  style="width:200px"/> 
	<input type="button" onclick="OCR()" value="OCR(OCR识别)"  style="width:200px"/>
	<input type="button" onclick="GetBiokey()" value="GetBiokey(指纹)"  style="width:200px"/>
	</br>
	<input type="button" onclick="GetDeviceAttribute()" value="GetDeviceAttribute(获取属性)"  style="width:200px"/>
	<input type="button" onclick="SetDeviceAttribute()" value="SetDeviceAttribute(设置属性)"  style="width:200px"/>
	</br>
  	<input type="button" onclick="StartSignDlg()" value="StartApp(签名窗口弹出)"  style="width:200px"/> 	
	<input type="button" onclick="GetSignData()" value="GetSignData(签名Base64)"  style="width:200px"/>
	<input type="button" onclick="StopSign()" value="StopSign(关闭签名窗口)"  style="width:200px"/> 	
	<input type="button" onclick="StartAppraiseDlg()" value="StartApp(评价窗口弹出)"  style="width:200px"/> 
	</br>
	<input type="button" onclick="GetPDF()" value="GetPDF(获得PDF)"  style="width:200px"/> 
    <input type="button" onclick="removeAll()" value="removeAll(清空缩略图)"  style="width:200px"/>
	</br>
	</div>	
	</br>
	<div id="result"></div>
	</br>
	<input class="submit_01" type="button" value="清空信息" onclick="clean()" />
    </br>
    </div>	
	<br/>	
	<div id="container" style="float:left;" width="320px" height="200px"> </div>
	</br>
	<img id="snapshot" src="" alt="This is a static snapshot" width="320px" height="200px"/>
	<img id="photo" src="" alt="This is a photo" width="200px" height="240px" />
	</br>
	<textarea cols="185" rows="25" id="objLog" name="objLog" ></textarea> 	
	</br>
	</div>	
    	
  </body>
</html>