You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1258 lines
55 KiB

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control"
content="max-age=0" />
<meta http-equiv="cache-control"
content="no-store" />
<meta http-equiv="expires"
content="-1" />
<meta http-equiv="expires"
content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma"
content="no-cache" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--meta http-equiv="refresh" content="300" />--> <!--Refresh each 5s-->
<meta charset="utf-8" />
<style>
body, html {
font-family: "Arial";
}
* {
box-sizing: border-box;
}
.titlebox {
float: left;
padding: 0 5px;
margin: 5px 0px 0 56px;
background: #fff;
}
.owl-theme .item {
height: 120px;
background: #5C5C5C;
padding: 0rem;
}
.owl-carousel .item h4 {
color: white;
margin-top: 0rem;
margin-bottom: 0rem;
font-size: 15px;
line-height: 15px;
}
/* Create two equal columns that floats next to each other */
.column {
float: left;
overflow: hidden;
/*width: 33%;*/
padding-left: 10px;
/*height: 300px;*/
/*margin: auto;*/
/* Should be removed. Only for demonstration */
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 400px) {
.column {
width: 100%;
}
}
.div-relative {
position: relative;
color: #000000;
width: 480px;
height: 320px;
}
/*
.column {
float: left;
overflow: hidden;
padding-left: 10px;
}
@media screen and (max-width: 400px) {
.column {
width: 100%;
}
}*/
</style>
<!--meta http-equiv="refresh" content="300" />--> <!--Refresh each 5s-->
<title>AI Engine</title>
<script src="jquery_3_2_1.min.js"></script>
<script src="fabric_jquery.easyui.min_compressed_on_nvr.js"></script>
<script src="config.js"></script>
<script>
window.onerror = function (message, url, linenumber) {
if (url.search("fabric_jquery.easyui.min_compressed_on_nvr.js") >= 1) {
loadScript("fabric_jquery.easyui.min_compressed_on_nvr.js", function () {
});
}
else if (url.search("config.js") >= 1) {
loadScript("config.js", function () {
});
}
else if (url.search("owl.carousel.min.js") >= 1) {
loadScript("lib/owl.carousel.min.js", function () {
});
}
else if (url.search("lang.js") >= 1) {
loadScript("lang.js", function () {
});
}
else if (url.search("lang_cookie.js") >= 1) {
loadScript("lang_cookie.js", function () {
});
}
else if (url.search("index.js") >= 1) {
loadScript("index.js", function () {
});
}
else if (url.search("cookie.min.js") >= 1) {
loadScript("cookie.min.js", function () {
});
}
else if (message.search("slider") >= 1) {
loadScript("fabric_jquery.easyui.min_compressed_on_nvr.js", function () {
});
}
else {
//location.reload();
var replaceUrl = 'http://' + window.location.hostname + ':' + GetUrlPort() + '/Aida/anpr_index.html';
//alert(replaceUrl);
window.location.replace(replaceUrl);
}
}
function GetUrlPort() {
var url_href = window.location.href;
var arr_url = url_href.split(":")[2].split("/")[0];
return arr_url;
}
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
</script>
<script src="cookie.min.js"></script>
<script src="index.js"></script>
<script src="lang.js"></script>
<script src="lang_cookie.js"></script>
<script src="lib/owl.carousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="easyui.css">
<link rel="stylesheet" type="text/css" href="css/owl.carousel.min.css">
<link rel="stylesheet" type="text/css" href="css/owl.theme.default.min.css">
<script>
var g_updateboxContent = null;
var g_mouse_status = 0;
/*
function updatebonContent() {
clearInterval(g_updateboxContent);
g_updateboxContent = setInterval(function () {
document.getElementById('LPR_boxContent').innerHTML = get_front_lpr();
}, 100);
}*/
$(document).ready(function () {
});
</script>
</head>
<body onContextMenu="window.event.returnValue=false">
<div class="progress" style="background-color:white">
<div class="progress-bar progress-bar-striped" style="min-width: 20px;visibility:hidden;"></div>
</div>
<div class="titlebox"><nobr id="TITLEBOX_PAGE06"></nobr></div>
<div style="border:1px gray solid;padding:10px;margin:15px 15px 4px 15px">
<br>
<div class="row">
<div class="column" style="width:47%;">
<input id="enable_anpr" type="checkbox" />&nbsp;<nobr id="IDC_CHECK_ENABLE_ANPR"></nobr>
&nbsp;&nbsp;&nbsp;&nbsp;
<input id="enable_show_zone" type="checkbox" name="enable_show_zone" />&nbsp;<nobr id="IDC_STATIC_SHOW_ZONE"></nobr>
<br>
<nobr id="IDC_STATIC_CONFIDENCE"></nobr>&nbsp;<br><br><input class="easyui-slider" id="confidence_plate" style="width:350px" />
<nobr id="IDC_STATIC_MIN_MAX_CHARACTERS"></nobr>&nbsp;<br><br><input class="easyui-slider" id="min_max_characters" style="width:350px" />
<input id="enable_downsized_cropped_roi" type="checkbox" />&nbsp;<nobr id="IDC_STATIC_CROP_PLATE"></nobr>
&nbsp;&nbsp;&nbsp;&nbsp;
<input id="enable_zone_crop_1" type="checkbox" />&nbsp;<nobr id="IDC_STATIC_ZONE_CROP_1"></nobr>
<br>
<div style="display:none">
<input id="enable_ambulance" type="checkbox" />&nbsp;<nobr id="IDC_STATIC_ENABLE_AMBULANCE"></nobr>
<input id="enable_blank_plate" type="checkbox" />&nbsp;<nobr id="IDC_STATIC_ENABLE_BLANK_PLATE"></nobr>
<input id="enable_stop_sign" type="checkbox" />&nbsp;<nobr id="IDC_STATIC_ENABLE_STOP_SIGN"></nobr>
</div>
<nobr id="IDC_STATIC_LEVENSHTEIN_DISTANCE"></nobr>
&nbsp;
<select name="levenshtein_distance" id="levenshtein_distance" onchange="">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br>
<input id="enable_lpr_upon_triggered" type="checkbox" />&nbsp;<nobr id="IDC_CHECK_ENABLE_LPR_UPON_TRIGGERED"></nobr>
<br><br>
<input class="easyui-slider" id="dwell_lpr_upon_triggered" style="width:350px" />
<br>
<img src="images/info-2-32X32.png" style="vertical-align:middle;" />
&nbsp;<nobr id="IDC_STATIC_ENCODER_JPEG_NOTICE"></nobr>
<br>
<nobr id="IDC_STATIC_ENCODER_JPEG_NOTICE2"></nobr>
<br>
<img src="images/info-2-32X32.png" style="vertical-align:middle;" />
&nbsp;<nobr id="IDC_STATIC_NOTICE_LEVENSHTEIN_DISTANCE"></nobr>
</div>
<div class="column" style="width:53%;">
<div class="div-relative">
<canvas id="CanvasTripwire_all"></canvas>
</div>
</div>
</div>
</div>
<div>
<div align="center">
<input align="center" id="IDOK" type="button" value=" Set " onclick="func_setanpr()" style="background-color:#6c87d4;color:white;height:36px;width:300px;" />
&nbsp;
<input align="center" id="IDC_STATIC_CREATE_DIVI_SMARTEVENT_BUTTON" type="button" value=" Create DI/VI SmartEvent " onclick="func_set_DIVI_SmartEvent()" style="background-color:#6c87d4;color:white;height:36px;width:300px;" />
</div>
</div>
<div id="lpr_jpg" class="owl-carousel owl-theme" style="position:absolute;background: #5C5C5C;height:120px;margin-top:5px;left:0px;">
<div id="lpr_jpg_1" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_2" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_3" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_4" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_5" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_6" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_7" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_8" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_9" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_10" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_11" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_12" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_13" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_14" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_15" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_16" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_17" class="item" style="width:170px;border:0px solid white;">
</div>
<div id="lpr_jpg_18" class="item" style="width:170px;border:0px solid white;">
</div>
</div>
<!-- <div>
<textarea style="width: 1700px; height: 500px;" id="test_txtbox"></textarea>
</div> -->
<script>
/*
loadScript("config.js", function () {
loadScript("cookie.min.js", function () {
loadScript("lang.js", function () {
loadScript("lang_cookie.js", function () {
//alert("all load");
});
});
});
});*/
function loadScript(url, callback) {
var script = document.createElement("Script");
script.type = "text/javascript";
//IE 验证脚本是否下载完成
if (script.readyState) {
script.onreadystatechange = function () {
//readyState属性有5种取值
//uninitialized:初始状态
//loading:开始下载
//interactive:数据完成下载但尚不可用
//complete:数据已经准备就绪
//实际使用时,readyState的值并不像我们预想的那样有规律,实践发现使用readyState
//最靠谱的方式是同时检查以下2个状态,只要其中1个触发,就认为脚本下载完成。
if (script.readyState == "loaded" || script.readyState == "complete") {
//移除事件处理器,确保事件不会处理2次
script.onreadystatechange = null;
callback();
}
};
}
//其他浏览器
else {
script.onload = function () {
callback();
};
}
script.src = url;
//把新建的<Script>添加到<head>里比添加到<body>里更保险。
document.getElementsByTagName("head")[0].appendChild(script);
}
//UI Interface
func_get_lang_cookie();
document.getElementById("IDC_STATIC_SHOW_ZONE").innerHTML = IDC_STATIC_SHOW_ZONE;
document.getElementById("IDC_CHECK_ENABLE_ANPR").innerHTML = IDC_CHECK_ENABLE_ANPR;
document.getElementById("IDC_STATIC_MIN_MAX_CHARACTERS").innerHTML = IDC_STATIC_MIN_MAX_CHARACTERS;
document.getElementById("IDC_STATIC_LEVENSHTEIN_DISTANCE").innerHTML = IDC_STATIC_LEVENSHTEIN_DISTANCE;
document.getElementById("IDC_STATIC_ENCODER_JPEG_NOTICE").innerHTML = IDC_STATIC_ENCODER_JPEG_NOTICE;
document.getElementById("IDC_STATIC_ENCODER_JPEG_NOTICE2").innerHTML = IDC_STATIC_ENCODER_JPEG_NOTICE2;
document.getElementById("IDC_STATIC_NOTICE_LEVENSHTEIN_DISTANCE").innerHTML = IDC_STATIC_NOTICE_LEVENSHTEIN_DISTANCE;
document.getElementById("IDC_STATIC_CONFIDENCE").innerHTML = IDC_STATIC_CONFIDENCE;
$('#IDOK').val(IDOK);
$('#IDC_STATIC_CREATE_DIVI_SMARTEVENT_BUTTON').val(IDC_STATIC_CREATE_DIVI_SMARTEVENT_BUTTON);
document.getElementById("TITLEBOX_PAGE06").innerHTML = TITLEBOX_PAGE06;
document.getElementById("IDC_STATIC_CROP_PLATE").innerHTML = IDC_STATIC_CROP_PLATE;
document.getElementById("IDC_STATIC_ZONE_CROP_1").innerHTML = IDC_STATIC_ZONE_CROP_1;
document.getElementById("IDC_STATIC_ENABLE_AMBULANCE").innerHTML = IDC_STATIC_ENABLE_AMBULANCE;
document.getElementById("IDC_STATIC_ENABLE_BLANK_PLATE").innerHTML = IDC_STATIC_ENABLE_BLANK_PLATE;
document.getElementById("IDC_STATIC_ENABLE_STOP_SIGN").innerHTML = IDC_STATIC_ENABLE_STOP_SIGN;
document.getElementById("IDC_CHECK_ENABLE_LPR_UPON_TRIGGERED").innerHTML = IDC_CHECK_ENABLE_LPR_UPON_TRIGGERED;
//document.getElementById("IDC_STATIC_LPR_RECORDS").innerHTML = IDC_STATIC_LPR_RECORDS;
var message_alert = IDC_STATIC_TEXT_CHANGE_SMART_EVENT;
var count_zone = 0;
var points_x_config = new Array(MAX_DETECTION_ZONE);
var points_y_config = new Array(MAX_DETECTION_ZONE);
var enable_ambulance = "No";
var enable_blank_plate = "No";
var enable_stop_sign = "No";
var enable_lpr_upon_triggered = "No";
var levenshtein_distance = "0";
var enable_cloud = "No";
var tab_view_size = new Array(2);
{
for (var i = 0; i < MAX_DETECTION_ZONE; i++) {
points_x_config[i] = new Array(MAX_SIZE_POINTS);
points_y_config[i] = new Array(MAX_SIZE_POINTS);
}
}
var image_width = GetMaxWidth();
var image_height = GetMaxHeight();
$(".owl-carousel").owlCarousel({
loop: false, // 循環播放
margin: 1, // 外距 10px
nav: false, // 顯示點點
dots: true,
//autoWidth: true,
items: 9 // 螢幕大小為 1000 以上 顯示 5 個項目
});
var checkbox_enable_show_zone = document.querySelector("input[name=enable_show_zone]");
checkbox_enable_show_zone.addEventListener('change', function () {
if ($('#enable_show_zone').is(":checked")) {
func_getZoneData();
}
else {
if (typeof canvasTripwire_all !== 'undefined') {
//Clear all objects
while (canvasTripwire_all.getObjects().length > 0) {
var items = canvasTripwire_all.getObjects();
if (items[canvasTripwire_all.getObjects().length - 1]) {
canvasTripwire_all.remove(items[canvasTripwire_all.getObjects().length - 1]);
}
}
}
click_canvas_all = 0;
canvasTripwire_all.requestRenderAll();
}
});
//updatebonContent();
$("#confidence_plate").slider({
//width: 300,
//height: 300,
//value: 12,
mode: 'h',//v,h
showTip: true,
//将最大最小值对调
// reversed:true,
// disabled:true,
min: 0,
max: 100,
// step:2.5,
//提示格式函数
tipFormatter: function (value) {
// return '['+value+']';
return value;
},
onChange: function (newValue, oldValue) {
// alert(newValue+" | "+oldValue);
},
onSlideStart: function (value) {
// alert(value);
},
onSlideEnd: function (value) {
// alert(value);
}
});
$("#dwell_lpr_upon_triggered").slider({
//width: 300,
//height: 300,
//value: 12,
mode: 'h',//v,h
showTip: true,
//将最大最小值对调
// reversed:true,
// disabled:true,
min: 1,
max: 30,
// step:2.5,
//提示格式函数
tipFormatter: function (value) {
// return '['+value+']';
return value;
},
onChange: function (newValue, oldValue) {
// alert(newValue+" | "+oldValue);
},
onSlideStart: function (value) {
// alert(value);
},
onSlideEnd: function (value) {
// alert(value);
}
});
$("#min_max_characters").slider({
//width: 300,
//height: 300,
//value: [1, 30],
mode: 'h',//v,h
showTip: true,
range: true,
//将最大最小值对调
// reversed:true,
// disabled:true,
min: 1,
max: 24,
// step:2.5,
//提示格式函数
tipFormatter: function (value) {
// return '['+value+']';
return value;
},
onChange: function (newValue, oldValue) {
// alert(newValue+" | "+oldValue);
},
onSlideStart: function (value) {
// alert(value);
},
onSlideEnd: function (value) {
// alert(value);
}
});
func_getZoneData();
func_get_cropped_roi();
setup_lprimg_in_anprindex();
//func_show_all_zone();
/*
setInputFilter(document.getElementById("min_characters"), function (value) {
return /^\d*$/.test(value) && (parseInt(value) >= MIN_RANGE_MIN_CHARACTERS && parseInt(value) <= MAX_RANGE_MIN_CHARACTERS);
});
setInputFilter(document.getElementById("max_characters"), function (value) {
return /^\d*$/.test(value) && (parseInt(value) >= MIN_RANGE_MAX_CHARACTERS && parseInt(value) <= MAX_RANGE_MAX_CHARACTERS);
});*/
/*
setInputFilter(document.getElementById("confidence_plate"), function (value) {
return /^\d*$/.test(value) && (parseInt(value) >= MIN_RANGE_CONFIDENCE && parseInt(value) <= MAX_RANGE_CONFIDENCE);
});*/
// Install input filters.
/*
setInputFilter(document.getElementById("intTextBox"), function (value) {
return /^-?\d*$/.test(value);
});
setInputFilter(document.getElementById("uintTextBox"), function (value) {
return /^\d*$/.test(value);
});
setInputFilter(document.getElementById("intLimitTextBox"), function (value) {
return /^\d*$/.test(value) && (value === "" || parseInt(value) <= 500);
});
setInputFilter(document.getElementById("floatTextBox"), function (value) {
return /^-?\d*[.,]?\d*$/.test(value);
});
setInputFilter(document.getElementById("currencyTextBox"), function (value) {
return /^-?\d*[.,]?\d{0,2}$/.test(value);
});
setInputFilter(document.getElementById("latinTextBox"), function (value) {
return /^[a-z]*$/i.test(value);
});
setInputFilter(document.getElementById("hexTextBox"), function (value) {
return /^[0-9a-f]*$/i.test(value);
});*/
/*
function change_enable_downsized_cropped_roi() {
if (document.getElementById('enable_downsized_cropped_roi').checked) {
func_get_enable_downsized_cropped_roi();
} else {
func_get_disable_downsized_cropped_roi();
}
}
function func_get_enable_downsized_cropped_roi() {
$.ajax({
url: "/enable_downsized_cropped_roi",
type: "GET",
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function (retdata) {
//console.info(retdata);
},
error: function (retdata) {
console.warn(retdata);
}
});
return false;
}
function func_get_disable_downsized_cropped_roi() {
$.ajax({
url: "/disable_downsized_cropped_roi",
type: "GET",
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function (retdata) {
//console.info(retdata);
},
error: function (retdata) {
console.warn(retdata);
}
});
return false;
}*/
function func_show_all_zone() {
//func_set_zone_data();
//func_set_zone_cookie4();
//func_set_zone_cookie3();
//func_set_zone_cookie2();
//func_set_zone_cookie1();
//show_all_zone = 1;
if (typeof canvasTripwire_all !== 'undefined') {
//Clear all objects
while (canvasTripwire_all.getObjects().length > 0) {
var items = canvasTripwire_all.getObjects();
if (items[canvasTripwire_all.getObjects().length - 1]) {
canvasTripwire_all.remove(items[canvasTripwire_all.getObjects().length - 1]);
}
}
}
if (get_check_edit1() === 1) {
disabelIteraction(canvasTripwire1.getObjects()[0]);
Edit1();
}
if (get_check_edit2() === 1) {
disabelIteraction(canvasTripwire2.getObjects()[0]);
Edit2();
}
if (get_check_edit3() === 1) {
disabelIteraction(canvasTripwire3.getObjects()[0]);
Edit3();
}
if (get_check_edit4() === 1) {
disabelIteraction(canvasTripwire4.getObjects()[0]);
Edit4();
}
if (get_check_edit5() === 1) {
disabelIteraction(canvasTripwire5.getObjects()[0]);
Edit5();
}
if (get_check_edit6() === 1) {
disabelIteraction(canvasTripwire6.getObjects()[0]);
Edit6();
}
if (get_check_edit7() === 1) {
disabelIteraction(canvasTripwire7.getObjects()[0]);
Edit7();
}
if (get_check_edit8() === 1) {
disabelIteraction(canvasTripwire8.getObjects()[0]);
Edit8();
}
var object1 = fabric.util.object.clone(canvasTripwire1.getObjects()[0]);
var object2 = fabric.util.object.clone(canvasTripwire2.getObjects()[0]);
var object3 = fabric.util.object.clone(canvasTripwire3.getObjects()[0]);
var object4 = fabric.util.object.clone(canvasTripwire4.getObjects()[0]);
var object5 = fabric.util.object.clone(canvasTripwire5.getObjects()[0]);
var object6 = fabric.util.object.clone(canvasTripwire6.getObjects()[0]);
var object7 = fabric.util.object.clone(canvasTripwire7.getObjects()[0]);
var object8 = fabric.util.object.clone(canvasTripwire8.getObjects()[0]);
if (count_zone >= 1) {
canvasTripwire_all.add(object1);
if (count_zone >= 2) {
canvasTripwire_all.add(object2);
if (count_zone >= 3) {
canvasTripwire_all.add(object3);
if (count_zone >= 4) {
canvasTripwire_all.add(object4);
if (count_zone >= 5) {
canvasTripwire_all.add(object5);
if (count_zone >= 6) {
canvasTripwire_all.add(object6);
if (count_zone >= 7) {
canvasTripwire_all.add(object7);
if (count_zone == 8) {
canvasTripwire_all.add(object8);
}
}
}
}
}
}
}
}
click_canvas_all = count_zone;
canvasTripwire_all.requestRenderAll();
}
var checkbox_enable_downsized_cropped_roi = document.querySelector("input[id=enable_downsized_cropped_roi]");
checkbox_enable_downsized_cropped_roi.addEventListener('change', function () {
if (this.checked) {
$('#enable_zone_crop_1').prop("checked", false);
}
});
var checkbox_enable_zone_crop_1 = document.querySelector("input[id=enable_zone_crop_1]");
checkbox_enable_zone_crop_1.addEventListener('change', function () {
if (this.checked) {
$('#enable_downsized_cropped_roi').prop("checked", false);
}
});
function func_get_cropped_roi() {
$.ajax({
url: "/get_cropped_roi",
type: "GET",
async:true,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function (retdata) {
var jsonbuf = JSON.parse(retdata);
if (jsonbuf["CROPPED_ROI"] == "1")
$('#enable_downsized_cropped_roi').prop("checked", true);
else
$('#enable_downsized_cropped_roi').prop("checked", false);
if (jsonbuf["CROPPED_ZONE_1"] == "1")
$('#enable_zone_crop_1').prop("checked", true);
else
$('#enable_zone_crop_1').prop("checked", false);
//console.info(retdata);
},
error: function (retdata) {
console.warn(retdata);
setTimeout(func_get_cropped_roi(),2000);
}
});
return false;
}
function validatingJSON(json) {
var checkedjson;
try {
checkedjson = JSON.parse(json); //JSON parse only for try catch
//console.log("json OK");
//console.log(json);
} catch (e) {
checkedjson = null;
console.log(e);//the character would be drop sometimes, for example the label "class_id" may be "clas_id".
//console.log(json);
}
return checkedjson;
}
function func_getZoneData() {
if (localStorage.getItem("barcode_qr") == "Yes") {
$('#min_max_characters').slider({ max: 50 });
}
else {
$('#min_max_characters').slider({ max: 24 });
}
$.ajax({
url: "/getconfigfile?ch=all",
type: "GET",
async: true,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function (retdata) {
//var jsonbuf = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
var jsonbuf = validatingJSON(retdata);
enable_cloud = jsonbuf["system_setting"]["enable_cloud"];
tab_view_size = jsonbuf["view_setting"]["camera01"]["tab_view_size"].split("x");
tab_view_size[0] = parseInt(tab_view_size[0], 10);
tab_view_size[1] = parseInt(tab_view_size[1], 10);
count_zone = jsonbuf["view_setting"]["camera01"]["count_zone"];
enable_ambulance = jsonbuf["view_setting"]["camera01"]["enable_ambulance"];
enable_blank_plate = jsonbuf["view_setting"]["camera01"]["enable_blank_plate"];
enable_stop_sign = jsonbuf["view_setting"]["camera01"]["enable_stop_sign"];
enable_lpr_upon_triggered = jsonbuf["view_setting"]["camera01"]["enable_lpr_upon_triggered"];
levenshtein_distance = jsonbuf["view_setting"]["camera01"]["levenshtein_distance"];
if (jsonbuf != null) {
for (var i = 0; i < MAX_DETECTION_ZONE; i++) {
for (var j = 0; j < MAX_SIZE_POINTS; j++) {
points_x_config[i][j] = jsonbuf["view_setting"]["camera01"]["detection_zone"][i]["x" + (j + 1).toString()];
points_y_config[i][j] = jsonbuf["view_setting"]["camera01"]["detection_zone"][i]["y" + (j + 1).toString()];
}
}
}
if (jsonbuf["view_setting"]["camera01"]["enable_anpr"] == 'Yes')
$('#enable_anpr').prop("checked", true);
else
$('#enable_anpr').prop("checked", false);
//$('#confidence_plate').val(jsonbuf["confidence"]);
$('#confidence_plate').slider('setValue', jsonbuf["view_setting"]["camera01"]["confidence"]);
$('#dwell_lpr_upon_triggered').slider('setValue', jsonbuf["view_setting"]["camera01"]["dwell_lpr_upon_triggered"]);
//$('#min_characters').val(jsonbuf["min_characters"]);
//$('#max_characters').val(jsonbuf["max_characters"]);
$('#min_max_characters').slider('setValues', [jsonbuf["view_setting"]["camera01"]["min_characters"], jsonbuf["view_setting"]["camera01"]["max_characters"]]);
if (enable_ambulance == "Yes")
$('#enable_ambulance').prop("checked", true);
else
$('#enable_ambulance').prop("checked", false);
if (enable_blank_plate == "Yes")
$('#enable_blank_plate').prop("checked", true);
else
$('#enable_blank_plate').prop("checked", false);
if (enable_stop_sign == "Yes")
$('#enable_stop_sign').prop("checked", true);
else
$('#enable_stop_sign').prop("checked", false);
if (enable_lpr_upon_triggered == "Yes")
$('#enable_lpr_upon_triggered').prop("checked", true);
else
$('#enable_lpr_upon_triggered').prop("checked", false);
$('#levenshtein_distance').val(levenshtein_distance);
createCanvasTrafficLight_anpr([{
x: Math.round(points_x_config[0][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[0][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[0][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[0][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[0][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[0][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[0][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[1][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[1][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[1][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[1][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[1][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[1][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[1][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[2][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[2][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[2][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[2][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[2][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[2][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[2][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[3][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[3][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[3][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[3][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[3][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[3][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[3][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[4][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[4][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[4][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[4][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[4][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[4][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[4][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[5][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[5][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[5][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[5][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[5][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[5][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[5][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[6][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[6][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[6][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[6][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[6][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[6][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[6][5] * image_height / tab_view_size[1])
}],
[{
x: Math.round(points_x_config[7][0] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][0] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[7][1] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][1] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[7][2] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][2] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[7][3] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][3] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[7][4] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][4] * image_height / tab_view_size[1])
}, {
x: Math.round(points_x_config[7][5] * image_width / tab_view_size[0]), y: Math.round(points_y_config[7][5] * image_height / tab_view_size[1])
}]);
createCanvasTrafficLight();
//console.info(retdata);
if ($('#enable_show_zone').is(":checked")) {
func_show_all_zone();
}
},
error: function (retdata) {
setTimeout(func_getZoneData(), 2000);
console.warn(retdata);
}
});
}
var g_set_divi_SmartEvent = 0;
function func_set_DIVI_SmartEvent() {
var r = confirm(message_alert);
if (r == true) {
k_index = 0;
g_set_divi_SmartEvent = 1;
makeProgress();
//makeProgress2();
} else {
}
}
function func_setanpr() {
k_index = 0;
makeProgress();
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) {
break;
}
}
}
function func_setconfigfile(json_data) {
$.ajax({
url: "/setconfigfile",
method: "POST",
async: false,
data: json_data,
contentType: false,
processData: false,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function () {
//console.info();
},
error: function () {
console.warn();
k_index++;
if (k_index <= 94) {
waitSeconds(500);
func_setconfigfile(json_data);
}
}
});
return false;
}
function func_run_osd_server() {
$.ajax({
url: "/run_osd_server",
method: "GET",
async: false,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function () {
//console.info();
},
error: function () {
setTimeout(func_run_osd_server(), 2000);
console.warn();
}
});
return false;
}
function func_setelement(name_, value_) {
$.ajax({
url: "/setconfig?ch=1&" + name_ + "=" + value_,
method: "GET",
async: false,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function () {
//console.info();
},
error: function () {
console.warn();
}
});
return false;
}
var count_reload = 0;
function func_getreload() {
$.ajax({
url: "/getconfig?reload=1",
method: "GET",
async: false,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
//data : JSON.stringify(data),
success: function (retdata) {
count_reload++;
if (retdata === "Reload OK.") {
count_reload = 0;
//console.log("Reload OK.");
}
else {
if (count_reload <= 3) {
setTimeout(func_getreload(), 2000);
}
else {
count_reload = 0;
}
}
//console.info();
},
error: function () {
console.warn();
}
});
return false;
}
function waitSeconds(iMilliSeconds) {
var counter = 0
, start = new Date().getTime()
, end = 0;
while (counter < iMilliSeconds) {
end = new Date().getTime();
counter = end - start;
}
}
function func_set_divi_smartevent() {
$.ajax({
url: "/set_divi_smartevent",
method: "GET",
async: true,
beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("If-Modified-Since", "0");
xmlHttp.setRequestHeader("Cache-Control", "no-cache");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function () {
//alert("Success to create smart event.");
//console.info();
},
error: function () {
//alert("[Error]create error event.");
console.warn();
}
});
//var replaceUrl = 'http://' + window.location.hostname + ':' + GetUrlPort() + '/Aida/countdown_output.html';
//window.location.replace(replaceUrl);
return false;
}
var k_index = -1;
$(".progress-bar").css("visibility", "hidden");
function makeProgress() {
if (k_index < 100 && k_index >= 0) {
k_index = k_index + 1;
$(".progress-bar").css("visibility", "visible");
//$(".progress-bar").css("width", k_index + "%").text(k_index + " %");
$(".progress-bar").css("width", k_index + "%");
console.log("k_index:" + k_index.toString());
if (k_index == 1) {
$('html, body').scrollTop(0);
var enable_anpr_temp = "";
if ($('#enable_anpr').is(":checked"))
enable_anpr_temp = "Yes";
else
enable_anpr_temp = "No";
var enable_downsized_cropped_roi_temp = 0;
if ($('#enable_downsized_cropped_roi').is(":checked"))
enable_downsized_cropped_roi_temp = 1;
else
enable_downsized_cropped_roi_temp = 0;
var enable_zone_crop_1_temp = 0;
if ($('#enable_zone_crop_1').is(":checked"))
enable_zone_crop_1_temp = 1;
else
enable_zone_crop_1_temp = 0;
if ($('#enable_ambulance').is(":checked"))
enable_ambulance = "Yes";
else
enable_ambulance = "No";
if ($('#enable_blank_plate').is(":checked"))
enable_blank_plate = "Yes";
else
enable_blank_plate = "No";
if ($('#enable_stop_sign').is(":checked"))
enable_stop_sign = "Yes";
else
enable_stop_sign = "No";
if ($('#enable_lpr_upon_triggered').is(":checked"))
enable_lpr_upon_triggered = "Yes";
else
enable_lpr_upon_triggered = "No";
levenshtein_distance = $('#levenshtein_distance').val();
var json_data = '{"view_setting":{"camera01":{';
json_data += '"max_characters": "' + $('#min_max_characters').slider('getValues')[1] + '",';
json_data += '"min_characters": "' + $('#min_max_characters').slider('getValues')[0] + '",';
json_data += '"enable_anpr": "' + enable_anpr_temp + '",';
json_data += '"confidence": "' + $('#confidence_plate').slider('getValue') + '",';
json_data += '"dwell_lpr_upon_triggered": "' + $('#dwell_lpr_upon_triggered').slider('getValue') + '",';
json_data += '"enable_downsized_cropped_roi": ' + enable_downsized_cropped_roi_temp.toString() + ',';
json_data += '"enable_ambulance": "' + enable_ambulance + '",';
json_data += '"enable_blank_plate": "' + enable_blank_plate + '",';
json_data += '"enable_stop_sign": "' + enable_stop_sign + '",';
json_data += '"enable_lpr_upon_triggered": "' + enable_lpr_upon_triggered + '",';
json_data += '"levenshtein_distance": "' + levenshtein_distance + '",';
json_data += '"enable_zone_crop_1": ' + enable_zone_crop_1_temp.toString();
json_data += '}}}';
func_setconfigfile(json_data);
k_index = 94;
}
else if (k_index == 95) {
//waitSeconds(500);
}
else if (k_index == 100) {
if (g_set_divi_SmartEvent == 1) {
g_set_divi_SmartEvent = 0;
func_set_divi_smartevent();
}
func_run_osd_server();
$(".progress-bar").css("visibility", "hidden");
//$(".progress-bar").css("width", "0%").text("0 %");
$(".progress-bar").css("width", "0%");
k_index = -1;
}
// Wait for sometime before running this script again
setTimeout("makeProgress()", 200);
}
}
getValue();
localStorage.setItem('anpr_index_success', 'OK');
</script>
</body>
</html>