<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=8" >
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >
<title>SDK2.0测试</title>
<script language="javascript" type="text/javascript">
var DeviceMain;//主头
var DeviceAssist;//副头
var VideoMain;//主头
var VideoAssist;//副头
var videoCapMain;
var videoCapAssist;
var PicPath;
var initFaceDetectSuccess;
var readIDcard = false;
function plugin()
{
return document.getElementById('view1');
}
function MainView()
{
return document.getElementById('view1');
}
function AssistView()
{
return document.getElementById('view2');
}
function thumb1()
{
return document.getElementById('thumb1');
}
function addEvent(obj, name, func)
{
if (obj.attachEvent) {
obj.attachEvent("on"+name, func);
} else {
obj.addEventListener(name, func, false);
}
}
function OpenVideo()
{
OpenVideoMain();
OpenVideoAssist();
}
function CloseVideo()
{
CloseVideoMain();
CloseVideoAssist();
}
function CloseVideoMain()
{
if (VideoMain)
{
plugin().Video_Release(VideoMain);
VideoMain = null;
MainView().View_SetText("", 0);
}
}
function CloseVideoAssist()
{
if (VideoAssist)
{
plugin().Video_Release(VideoAssist);
VideoAssist = null;
AssistView().View_SetText("", 0);
}
}
function OpenVideoMain()
{
CloseVideoMain();
if (!DeviceMain)
return;
var sSubType = document.getElementById('subType1');
var sResolution = document.getElementById('selRes1');
var SelectType = 0;
var txt;
if(sSubType.options.selectedIndex != -1)
{
txt = sSubType.options[sSubType.options.selectedIndex].text;
if(txt == "YUY2")
{
SelectType = 1;
}
else if(txt == "MJPG")
{
SelectType = 2;
}
else if(txt == "UYVY")
{
SelectType = 4;
}
}
var nResolution = sResolution.selectedIndex;
VideoMain = plugin().Device_CreateVideo(DeviceMain, nResolution, SelectType);
if (VideoMain)
{
MainView().View_SelectVideo(VideoMain);
MainView().View_SetText("打开视频中,请等待...", 0);
}
}
function OpenVideoAssist()
{
CloseVideoAssist();
if (!DeviceAssist)
return;
var sSubType = document.getElementById('subType2');
var sResolution = document.getElementById('selRes2');
var SelectType = 0;
var txt;
if(sSubType.options.selectedIndex != -1)
{
txt = sSubType.options[sSubType.options.selectedIndex].text;
if(txt == "YUY2")
{
SelectType = 1;
}
else if(txt == "MJPG")
{
SelectType = 2;
}
else if(txt == "UYVY")
{
SelectType = 4;
}
}
var nResolution = sResolution.selectedIndex;
VideoAssist = plugin().Device_CreateVideo(DeviceAssist, nResolution, SelectType);
if (VideoAssist)
{
AssistView().View_SelectVideo(VideoAssist);
AssistView().View_SetText("打开视频中,请等待...", 0);
}
}
function changesubTypeMain()
{
if (DeviceMain)
{
var sSubType = document.getElementById('subType1');
var sResolution = document.getElementById('selRes1');
var SelectType = 0;
var txt;
if(sSubType.options.selectedIndex != -1)
{
var txt = sSubType.options[sSubType.options.selectedIndex].text;
if(txt == "YUY2")
{
SelectType = 1;
}
else if(txt == "MJPG")
{
SelectType = 2;
}
else if(txt == "UYVY")
{
SelectType = 4;
}
}
var nResolution = plugin().Device_GetResolutionCountEx(DeviceMain, SelectType);
sResolution.options.length = 0;
for(var i = 0; i < nResolution; i++)
{
var width = plugin().Device_GetResolutionWidthEx(DeviceMain, SelectType, i);
var heigth = plugin().Device_GetResolutionHeightEx(DeviceMain, SelectType, i);
sResolution.add(new Option(width.toString() + "*" + heigth.toString()));
}
sResolution.selectedIndex = 0;
}
}
function changesubTypeAssist()
{
if (DeviceAssist)
{
var sSubType = document.getElementById('subType2');
var sResolution = document.getElementById('selRes2');
var SelectType = 0;
var txt;
if(sSubType.options.selectedIndex != -1)
{
var txt = sSubType.options[sSubType.options.selectedIndex].text;
if(txt == "YUY2")
{
SelectType = 1;
}
else if(txt == "MJPG")
{
SelectType = 2;
}
else if(txt == "UYVY")
{
SelectType = 4;
}
}
var nResolution = plugin().Device_GetResolutionCountEx(DeviceAssist, SelectType);
sResolution.options.length = 0;
for(var i = 0; i < nResolution; i++)
{
var width = plugin().Device_GetResolutionWidthEx(DeviceAssist, SelectType, i);
var heigth = plugin().Device_GetResolutionHeightEx(DeviceAssist, SelectType, i);
sResolution.add(new Option(width.toString() + "*" + heigth.toString()));
}
sResolution.selectedIndex = 0;
}
}
function Load()
{
//设备接入和丢失
//type设备类型, 1 表示视频设备, 2 表示音频设备
//idx设备索引
//dbt 1 表示设备到达, 2 表示设备丢失
addEvent(plugin(), 'DevChange', function (type, idx, dbt)
{
if(1 == type)//视频设备
{
if(1 == dbt)//设备到达
{
var deviceType = plugin().Global_GetEloamType(1, idx);
if(1 == deviceType)//主摄像头
{
if(null == DeviceMain)
{
DeviceMain = plugin
评论0