|
|
|
|
|
var canvasTripwire1; |
|
|
|
|
|
var G_VIEW_CANVAS_X = 640;//480 |
|
|
var G_VIEW_CANVAS_Y = 480;//320 |
|
|
var G_CAM_VIDEO_RES_WIDTH = 1920; |
|
|
var G_CAM_VIDEO_RES_HEIGHT = 1080; |
|
|
var MAX_MOVE_RADIUS = 30; |
|
|
|
|
|
var MAX_HEIGHT = G_VIEW_CANVAS_Y; |
|
|
var MAX_WIDTH = G_VIEW_CANVAS_X; |
|
|
|
|
|
var g_max_protected_objects = 0; |
|
|
|
|
|
var current_state_hide_or_open_label = 0; |
|
|
var current_state_hide_or_open_direction = 0; |
|
|
var current_state_hide_or_open_speed = 0; |
|
|
|
|
|
var MAX_SIZE_COUNTERS = 8; |
|
|
var MAX_DETECTION_ZONE = 8; |
|
|
var counter_value = new Array(MAX_SIZE_COUNTERS); |
|
|
var last_counter_value = new Array(MAX_SIZE_COUNTERS); |
|
|
var switch_run_counter = 0; |
|
|
//var trigger_zone_happened = new Array(MAX_DETECTION_ZONE); |
|
|
|
|
|
{ |
|
|
for (var i = 0; i < MAX_SIZE_COUNTERS; i++) { |
|
|
counter_value[i] = 0; |
|
|
last_counter_value[i] = -1; |
|
|
} |
|
|
|
|
|
/* |
|
|
for (var i = 0; i < MAX_DETECTION_ZONE; i++) { |
|
|
trigger_zone_happened[i] = 0; |
|
|
}*/ |
|
|
} |
|
|
|
|
|
function insertTrafficLightRectangle(r_left, r_top, r_width, r_height, r_direct, r_tlight, r_name, r_number_row) { |
|
|
var rectangle; |
|
|
|
|
|
var color_type = '#00FF00'; |
|
|
|
|
|
if (r_name != "object" && |
|
|
r_name != "L._Plate_USA" && |
|
|
r_name != "L._Plate_MAC/MYS" && |
|
|
r_name != "L._Plate_VNM" && |
|
|
r_name != "L._Plate_EUR" && |
|
|
r_name != "L._Plate_GBR" && |
|
|
r_name != "L._Plate_JPN" && |
|
|
r_name != "L._Plate_THA" && |
|
|
r_name != "L._Plate_IDN" && |
|
|
r_name != "L._Plate_IDN2" && |
|
|
r_name != "L._Plate_BGD" && |
|
|
r_name != "L._Plate_MEA" && |
|
|
r_name != "L._Plate_PHL" && |
|
|
r_name != "L._Plate_AUS" && |
|
|
r_name != "L._Plate_CNT_1LINE" && |
|
|
r_name != "L._Plate_CNT_2LINES" && |
|
|
r_name != "L._Plate_CNT_3LINES" && |
|
|
r_name != "L._Plate_CNT_VERTICAL" && |
|
|
r_name != "L._Plate_CNT_USDOT" && |
|
|
r_name != "ambulance" && |
|
|
r_name != "face" && |
|
|
r_name != "blank" && |
|
|
r_name != "stop_sign" && |
|
|
r_name != "qrcode" && |
|
|
r_name != "barcode" && |
|
|
r_name != "L._Plate_TWN" && |
|
|
r_name != "") { |
|
|
if (r_name == "person") { |
|
|
color_type = '#FF8C00'; |
|
|
} |
|
|
else { |
|
|
color_type = '#800080'; |
|
|
} |
|
|
} |
|
|
else if (r_number_row == 2) { |
|
|
color_type = '#FFFF00'; |
|
|
} |
|
|
|
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
|
|
|
if (r_name != "object" && |
|
|
r_name != "L._Plate_USA" && |
|
|
r_name != "L._Plate_MAC/MYS" && |
|
|
r_name != "L._Plate_VNM" && |
|
|
r_name != "L._Plate_EUR" && |
|
|
r_name != "L._Plate_GBR" && |
|
|
r_name != "L._Plate_JPN" && |
|
|
r_name != "L._Plate_THA" && |
|
|
r_name != "L._Plate_IDN" && |
|
|
r_name != "L._Plate_IDN2" && |
|
|
r_name != "L._Plate_BGD" && |
|
|
r_name != "L._Plate_MEA" && |
|
|
r_name != "L._Plate_PHL" && |
|
|
r_name != "L._Plate_AUS" && |
|
|
r_name != "L._Plate_CNT_1LINE" && |
|
|
r_name != "L._Plate_CNT_2LINES" && |
|
|
r_name != "L._Plate_CNT_3LINES" && |
|
|
r_name != "L._Plate_CNT_VERTICAL" && |
|
|
r_name != "L._Plate_CNT_USDOT" && |
|
|
r_name != "ambulance" && |
|
|
r_name != "face" && |
|
|
r_name != "blank" && |
|
|
r_name != "stop_sign" && |
|
|
r_name != "qrcode" && |
|
|
r_name != "barcode" && |
|
|
r_name != "L._Plate_TWN" && |
|
|
r_name != "") { |
|
|
|
|
|
var temp_width = r_width; |
|
|
var temp_height = r_height; |
|
|
r_width = r_width * 1.095; |
|
|
r_height = r_height * 1.095; |
|
|
r_left = r_left - (r_width - temp_width) / 2; |
|
|
r_top = r_top - (r_height - temp_height) / 2; |
|
|
} |
|
|
|
|
|
rectangle = new fabric.Rect({ objectCaching: false, trafficlight: r_tlight, direction: r_direct, left: r_left, top: r_top, stroke: color_type, strokeWidth: 1.5, fill: 'transparent', width: r_width, height: r_height, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
|
|
|
} |
|
|
else { |
|
|
rectangle = new fabric.Rect({ objectCaching: false, trafficlight: 1, direction: 1, left: G_VIEW_CANVAS_X * 0.104, top: G_VIEW_CANVAS_X * 0.104, stroke: color_type, strokeWidth: 1.5, fill: 'transparent', width: 30, height: 30, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
} |
|
|
|
|
|
rectangle.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(rectangle); |
|
|
|
|
|
return rectangle; |
|
|
} |
|
|
|
|
|
function insertTrafficLightRectangle_Red(r_left, r_top, r_width, r_height, r_direct, r_tlight, r_name) { |
|
|
var rectangle2; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
|
|
|
if (r_name != "object" && |
|
|
r_name != "L._Plate_USA" && |
|
|
r_name != "L._Plate_MAC/MYS" && |
|
|
r_name != "L._Plate_VNM" && |
|
|
r_name != "L._Plate_EUR" && |
|
|
r_name != "L._Plate_GBR" && |
|
|
r_name != "L._Plate_JPN" && |
|
|
r_name != "L._Plate_THA" && |
|
|
r_name != "L._Plate_IDN" && |
|
|
r_name != "L._Plate_IDN2" && |
|
|
r_name != "L._Plate_BGD" && |
|
|
r_name != "L._Plate_MEA" && |
|
|
r_name != "L._Plate_PHL" && |
|
|
r_name != "L._Plate_AUS" && |
|
|
r_name != "L._Plate_CNT_1LINE" && |
|
|
r_name != "L._Plate_CNT_2LINES" && |
|
|
r_name != "L._Plate_CNT_3LINES" && |
|
|
r_name != "L._Plate_CNT_VERTICAL" && |
|
|
r_name != "L._Plate_CNT_USDOT" && |
|
|
r_name != "ambulance" && |
|
|
r_name != "face" && |
|
|
r_name != "blank" && |
|
|
r_name != "stop_sign" && |
|
|
r_name != "qrcode" && |
|
|
r_name != "barcode" && |
|
|
r_name != "L._Plate_TWN" && |
|
|
r_name != "") { |
|
|
|
|
|
var temp_width = r_width; |
|
|
var temp_height = r_height; |
|
|
r_width = r_width * 1.095; |
|
|
r_height = r_height * 1.095; |
|
|
r_left = r_left - (r_width - temp_width) / 2; |
|
|
r_top = r_top - (r_height - temp_height) / 2; |
|
|
} |
|
|
|
|
|
rectangle2 = new fabric.Rect({ objectCaching: false, trafficlight: r_tlight, direction: r_direct, left: r_left, top: r_top, stroke: '#FF0000', strokeWidth: 1.5, fill: 'transparent', width: r_width, height: r_height, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
|
|
|
} |
|
|
else { |
|
|
rectangle2 = new fabric.Rect({ objectCaching: false, trafficlight: 1, direction: 1, left: G_VIEW_CANVAS_X*0.104, top: G_VIEW_CANVAS_X*0.104, stroke: '#FF0000', strokeWidth: 1.5, fill: 'transparent', width: 30, height: 30, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
} |
|
|
|
|
|
rectangle2.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(rectangle2); |
|
|
|
|
|
return rectangle2; |
|
|
} |
|
|
|
|
|
function insertTrafficLightRectangle_Blue(r_left, r_top, r_width, r_height, r_direct, r_tlight) { |
|
|
var rectangle3; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
rectangle3 = new fabric.Rect({ objectCaching: false, trafficlight: r_tlight, direction: r_direct, left: r_left, top: r_top, stroke: '#0000ff', strokeWidth: 1.5, fill: 'transparent', width: r_width, height: r_height, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
|
|
|
} |
|
|
else { |
|
|
rectangle3 = new fabric.Rect({ objectCaching: false, trafficlight: 1, direction: 1, left: G_VIEW_CANVAS_X*0.104, top: G_VIEW_CANVAS_X*0.104, stroke: '#0000ff', strokeWidth: 1.5, fill: 'transparent', width: 30, height: 30, opacity: 1, hasRotatingPoint: false, transparentCorners: false, cornerStyle: 'circle', cornerSize: 10, cornerColor: '#BDB76B' }); |
|
|
} |
|
|
|
|
|
rectangle3.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(rectangle3); |
|
|
|
|
|
return rectangle3; |
|
|
} |
|
|
|
|
|
/** |
|
|
* @ create a text object |
|
|
* |
|
|
* @ Input : |
|
|
* :1.r_left:left |
|
|
* :2.r_top:top |
|
|
* :3.r_width:width |
|
|
* :4.r_height:height |
|
|
* :5.r_direct:direction |
|
|
* :6.trafficlight:trafficlight |
|
|
* @ Return : text object |
|
|
*/ |
|
|
function insertTextLabel(r_left, r_top, r_width, r_height, showtext) { |
|
|
var textcontent; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: r_left, |
|
|
top: r_top, |
|
|
width: r_width, |
|
|
height: r_height, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#CCFF33' |
|
|
}); |
|
|
|
|
|
} |
|
|
else { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
width: G_VIEW_CANVAS_X*0.104, |
|
|
height: G_VIEW_CANVAS_X*0.104, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#CCFF33' |
|
|
}); |
|
|
} |
|
|
//const text = new fabric.Text('Day 7 fabricjs') |
|
|
//canvas.add(text) |
|
|
/* |
|
|
{ |
|
|
trafficlight: 1, |
|
|
direction:1, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
stroke: '#00FF00', |
|
|
strokeWidth: 1.5, |
|
|
fill: 'transparent', |
|
|
width: 30, |
|
|
height: 30, |
|
|
opacity: 1, |
|
|
hasRotatingPoint: false, |
|
|
transparentCorners: false, |
|
|
cornerStyle: 'circle', |
|
|
cornerSize: 10, |
|
|
cornerColor: '#BDB76B' |
|
|
} |
|
|
*/ |
|
|
textcontent.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(textcontent); |
|
|
|
|
|
return textcontent; |
|
|
} |
|
|
|
|
|
function insertTextLabel_Orange(r_left, r_top, r_width, r_height, showtext) { |
|
|
var textcontent; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: r_left, |
|
|
top: r_top, |
|
|
width: r_width, |
|
|
height: r_height, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 22, // 字体大小 |
|
|
fontWeight: '900', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#ff8c00' |
|
|
}); |
|
|
|
|
|
} |
|
|
else { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
width: G_VIEW_CANVAS_X*0.104, |
|
|
height: G_VIEW_CANVAS_X*0.104, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 22, // 字体大小 |
|
|
fontWeight: '900', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#ff8c00' |
|
|
}); |
|
|
} |
|
|
//const text = new fabric.Text('Day 7 fabricjs') |
|
|
//canvas.add(text) |
|
|
/* |
|
|
{ |
|
|
trafficlight: 1, |
|
|
direction:1, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
stroke: '#00FF00', |
|
|
strokeWidth: 1.5, |
|
|
fill: 'transparent', |
|
|
width: 30, |
|
|
height: 30, |
|
|
opacity: 1, |
|
|
hasRotatingPoint: false, |
|
|
transparentCorners: false, |
|
|
cornerStyle: 'circle', |
|
|
cornerSize: 10, |
|
|
cornerColor: '#BDB76B' |
|
|
} |
|
|
*/ |
|
|
textcontent.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(textcontent); |
|
|
|
|
|
return textcontent; |
|
|
} |
|
|
|
|
|
function insertTextLabel_Red(r_left, r_top, r_width, r_height, showtext) { |
|
|
var textcontent; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: r_left, |
|
|
top: r_top, |
|
|
width: r_width, |
|
|
height: r_height, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#ff0000' |
|
|
}); |
|
|
|
|
|
} |
|
|
else { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
width: G_VIEW_CANVAS_X*0.104, |
|
|
height: G_VIEW_CANVAS_X*0.104, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#ff0000' |
|
|
}); |
|
|
} |
|
|
//const text = new fabric.Text('Day 7 fabricjs') |
|
|
//canvas.add(text) |
|
|
/* |
|
|
{ |
|
|
trafficlight: 1, |
|
|
direction:1, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
stroke: '#00FF00', |
|
|
strokeWidth: 1.5, |
|
|
fill: 'transparent', |
|
|
width: 30, |
|
|
height: 30, |
|
|
opacity: 1, |
|
|
hasRotatingPoint: false, |
|
|
transparentCorners: false, |
|
|
cornerStyle: 'circle', |
|
|
cornerSize: 10, |
|
|
cornerColor: '#BDB76B' |
|
|
} |
|
|
*/ |
|
|
textcontent.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(textcontent); |
|
|
|
|
|
return textcontent; |
|
|
} |
|
|
|
|
|
function insertTextLabel_Blue(r_left, r_top, r_width, r_height, showtext) { |
|
|
var textcontent; |
|
|
if ((r_left != null) && (r_top != null) && (r_width != null) && (r_height != null)) { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: r_left, |
|
|
top: r_top, |
|
|
width: r_width, |
|
|
height: r_height, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#0000ff' |
|
|
}); |
|
|
|
|
|
} |
|
|
else { |
|
|
textcontent = new fabric.Text(showtext, { |
|
|
objectCaching: false, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
width: G_VIEW_CANVAS_X*0.104, |
|
|
height: G_VIEW_CANVAS_X*0.104, |
|
|
fontFamily: 'helvetica', // 字型 |
|
|
fontSize: 15, // 字体大小 |
|
|
fontWeight: '', // 字体粗细 |
|
|
shadow: { color: 'black', blur: 5 }, |
|
|
fill: '#0000ff' |
|
|
}); |
|
|
} |
|
|
//const text = new fabric.Text('Day 7 fabricjs') |
|
|
//canvas.add(text) |
|
|
/* |
|
|
{ |
|
|
trafficlight: 1, |
|
|
direction:1, |
|
|
left: G_VIEW_CANVAS_X*0.104, |
|
|
top: G_VIEW_CANVAS_X*0.104, |
|
|
stroke: '#00FF00', |
|
|
strokeWidth: 1.5, |
|
|
fill: 'transparent', |
|
|
width: 30, |
|
|
height: 30, |
|
|
opacity: 1, |
|
|
hasRotatingPoint: false, |
|
|
transparentCorners: false, |
|
|
cornerStyle: 'circle', |
|
|
cornerSize: 10, |
|
|
cornerColor: '#BDB76B' |
|
|
} |
|
|
*/ |
|
|
textcontent.setControlsVisibility({ |
|
|
bl: true, |
|
|
br: true, |
|
|
tl: true, |
|
|
tr: true, |
|
|
mt: true, |
|
|
mb: true, |
|
|
ml: true, |
|
|
mr: true, |
|
|
}); |
|
|
|
|
|
disabelIteraction(textcontent); |
|
|
|
|
|
return textcontent; |
|
|
} |
|
|
|
|
|
function disabelIteraction(element) { |
|
|
//https://github.com/fabricjs/fabric.js/wiki/Preventing-object-modification |
|
|
element.lockMovementX = true; //Prevents horizontal movement |
|
|
element.lockMovementY = true; //Prevents vertical movement |
|
|
element.lockScalingX = true; //Prevents horizontal scaling |
|
|
element.lockScalingY = true; //Prevents vertical scaling |
|
|
element.lockUniScaling = true; //Prevents scaling in either X or Y direction but not in both. In other words, prevents non-proportional scaling of an object. |
|
|
element.lockRotation = true; //Prevents rotation |
|
|
element.selectable = false; |
|
|
element.evented = false; |
|
|
} |
|
|
|
|
|
function enableIteraction(element) { |
|
|
element.lockScalingX = false; //Prevents horizontal scaling |
|
|
element.lockScalingY = false; //Prevents vertical scaling |
|
|
element.lockUniScaling = false; //Prevents scaling in either X or Y direction but not in both. In other words, prevents non-proportional scaling of an object. |
|
|
element.lockRotation = false; //Prevents rotation |
|
|
element.evented = true; |
|
|
element.selectable = true; |
|
|
} |
|
|
|
|
|
function createCanvasTrafficLight_counter() { |
|
|
canvasTripwire1 = new fabric.Canvas('CanvasTripwire1', { |
|
|
height: G_VIEW_CANVAS_Y,//window.innerHeight |
|
|
width: G_VIEW_CANVAS_X//window.innerWidth |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
var request_live = null; |
|
|
function getalarmmotion_value() { |
|
|
|
|
|
var ipStr = '/getalarmmotion'; |
|
|
|
|
|
if (this.status == 404) { |
|
|
//request_live = setInterval(function () { |
|
|
/* |
|
|
if (navigator.userAgent.match("MSIE") || (!!window.ActiveXObject || "ActiveXObject" in window)) |
|
|
GetRequest_Http(); |
|
|
else*/ |
|
|
// GetRequest_WebSocket(); |
|
|
var replaceUrl = 'http://' + window.location.hostname + ':' + GetUrlPort() + '/Aida/cool_counter.html'; |
|
|
//alert(replaceUrl); |
|
|
parent.window.location.replace(replaceUrl); |
|
|
//}, 5000); |
|
|
} |
|
|
else { |
|
|
/* |
|
|
if (navigator.userAgent.match("MSIE") || (!!window.ActiveXObject || "ActiveXObject" in window)) |
|
|
GetRequest_Http(); |
|
|
else*/ |
|
|
GetRequest_WebSocket(); |
|
|
} |
|
|
} |
|
|
|
|
|
var ws = null; |
|
|
var wait_data = 0; |
|
|
function GetRequest_WebSocket() { |
|
|
// sessionStorage.setItem('getalarmmotion_data', ""); |
|
|
var data_temp = ""; |
|
|
wait_data = 0; |
|
|
console.log("GetRequest_WebSocket"); |
|
|
if ("WebSocket" in window) { |
|
|
//console.log("WebSocket is supported by your Browser!"); |
|
|
|
|
|
// Let us open a web socket |
|
|
if ( navigator.userAgent.indexOf( "nvr_auth=" ) != -1 ) |
|
|
ws = new WebSocket("ws://" + window.location.hostname + ":" + GetUrlPort() + "/getalarmmotion?" + navigator.userAgent ); |
|
|
else |
|
|
ws = new WebSocket("ws://" + window.location.hostname + ":" + GetUrlPort() + "/getalarmmotion"); |
|
|
|
|
|
keepAlive(); |
|
|
|
|
|
ws.onopen = function () { |
|
|
|
|
|
// Web Socket is connected, send data using send() |
|
|
//ws.send("Message to send"); |
|
|
console.log("ws.onopen..."); |
|
|
clearInterval(request_live); |
|
|
|
|
|
|
|
|
//clearInterval(reconnect_websocket); |
|
|
//websocket_reconnect_flag = 0; |
|
|
}; |
|
|
|
|
|
ws.onmessage = function (evt) { |
|
|
|
|
|
var received_msg = evt.data; |
|
|
//console.log("websocket:"); |
|
|
//console.log(received_msg); |
|
|
|
|
|
/* |
|
|
clearInterval(request_live); |
|
|
clearInterval(reconnect_websocket); |
|
|
websocket_reconnect_flag = 0;*/ |
|
|
data_temp = ""; |
|
|
data_temp = received_msg; |
|
|
//console.log("this.responseText.length: " + this.responseText.length.toString()); |
|
|
//console.log("readyState " + this.readyState.toString()); |
|
|
//sessionStorage.setItem('getalarmmotion_data', data_temp); |
|
|
GetAlarm(data_temp); |
|
|
//console.log("websocket here"); |
|
|
wait_data = 0; |
|
|
}; |
|
|
|
|
|
ws.onclose = function () { |
|
|
// websocket is closed. |
|
|
console.log("Connection is closed..."); |
|
|
|
|
|
cancelKeepAlive(); |
|
|
|
|
|
ws = null; |
|
|
setTimeout(function () { |
|
|
GetRequest_WebSocket(); |
|
|
}, 1000); |
|
|
|
|
|
//websocket_reconnect_flag = 1; |
|
|
//reConnect(); |
|
|
}; |
|
|
|
|
|
ws.onerror = function (e) { |
|
|
// websocket is error. |
|
|
console.log("Connection is error"); |
|
|
console.log(e); |
|
|
|
|
|
//cancelKeepAlive(); |
|
|
//websocket_reconnect_flag = 1; |
|
|
//reConnect(); |
|
|
ws.close(); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
// The browser doesn't support WebSocket |
|
|
//console.log("WebSocket NOT supported by your Browser!"); |
|
|
} |
|
|
} |
|
|
|
|
|
var timerID = 0; |
|
|
function keepAlive() { |
|
|
var timeout = 5000; |
|
|
//console.log("keepAlive:" + ws.readyState); |
|
|
//console.log("wait_data:" + wait_data.toString()); |
|
|
if (ws.readyState != 2)//fail receive |
|
|
wait_data++; |
|
|
if (wait_data >= 20) |
|
|
ws.close(); |
|
|
else |
|
|
timerID = setTimeout(keepAlive, timeout); |
|
|
} |
|
|
function cancelKeepAlive() { |
|
|
if (timerID) { |
|
|
clearTimeout(timerID); |
|
|
} |
|
|
} |
|
|
|
|
|
function GetAlarm(alarm_data) { |
|
|
if (!!alarm_data) { |
|
|
var datas; |
|
|
var ai_json; |
|
|
var complete_data = ""; |
|
|
var n1 = -1, n2 = -1, n2_temp = -1; |
|
|
|
|
|
var max_protected_objects = g_max_protected_objects; |
|
|
|
|
|
complete_data = complete_data.concat(alarm_data); |
|
|
n1 = complete_data.indexOf('{"AiEngine"'); |
|
|
|
|
|
n2_temp = complete_data.indexOf('"Count"'); |
|
|
|
|
|
n2 = complete_data.indexOf('}', n2_temp); |
|
|
|
|
|
if (n1 > 0 && n2_temp > 0 && n2 > 0 && (n1 + 7) < n2_temp && n2_temp < n2) { |
|
|
wait_count = 0; |
|
|
clear_count = 0; |
|
|
datas = complete_data.split(/\r\n|\r/); |
|
|
complete_data = ""; |
|
|
|
|
|
for (var i = datas.length - 1; i >= 0; i--) { |
|
|
if (datas[i].length > 12 && datas[i].substring(0, 12) == '{"AiEngine":' && datas[i].length < 8192 * 8) { |
|
|
|
|
|
var temp = null; |
|
|
temp = datas[i].slice(); |
|
|
|
|
|
ai_json = JSON.parse(temp); |
|
|
//ai_json = validatingJSON(temp); |
|
|
|
|
|
datas[i] = null; |
|
|
//check_cam_time = 1; |
|
|
break; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var AI_fps = ai_json.AI_fps; |
|
|
localStorage.setItem('AI_fps', AI_fps); |
|
|
var red_light = ai_json.red_light; |
|
|
if (ai_json != null) { |
|
|
bbox_count = ai_json.Count; |
|
|
} |
|
|
else { |
|
|
bbox_count = 0; |
|
|
} |
|
|
|
|
|
plate_count = 0; |
|
|
plate_idx = 0; |
|
|
|
|
|
RefreshCanvasObject(max_protected_objects); |
|
|
|
|
|
if (ai_json != null) { |
|
|
if (switch_run_counter == 0) { |
|
|
for (var j = 0; j < 8; j++) { |
|
|
if (ai_json.counter_count[j] != null) { |
|
|
if (last_counter_value[j] != -1) |
|
|
last_counter_value[j] = counter_value[j]; |
|
|
else |
|
|
last_counter_value[j] = ai_json.counter_count[j]; |
|
|
counter_value[j] = ai_json.counter_count[j]; |
|
|
} |
|
|
} |
|
|
switch_run_counter = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
if (canvasTripwire1) { |
|
|
if (red_light == 1) |
|
|
canvasTripwire1.add(insertTextLabel_Red(10, parseInt(window.innerHeight * 0.45) - 25, G_VIEW_CANVAS_X * 0.104, G_VIEW_CANVAS_X * 0.104, "FPS:" + AI_fps.toString() + ",Red:" + red_light.toString())); |
|
|
else |
|
|
canvasTripwire1.add(insertTextLabel_Red(10, parseInt(window.innerHeight * 0.45) - 25, G_VIEW_CANVAS_X * 0.104, G_VIEW_CANVAS_X * 0.104, "FPS:" + AI_fps.toString())); |
|
|
} |
|
|
|
|
|
for (var i = 0; i < bbox_count ; i++) { |
|
|
if (ai_json.AiEngine[i]) { |
|
|
|
|
|
if (ai_json.AiEngine[i].parent_idx == -1) { |
|
|
|
|
|
if (ai_json.AiEngine[i].label_name == "L._Plate_USA" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_MAC/MYS" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_VNM" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_EUR" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_GBR" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_JPN" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_THA" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_IDN" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_IDN2" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_BGD" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_MEA" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_PHL" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_AUS" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_CNT_1LINE" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_CNT_2LINES" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_CNT_3LINES" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_CNT_VERTICAL" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_CNT_USDOT" || |
|
|
ai_json.AiEngine[i].label_name == "ambulance" || |
|
|
ai_json.AiEngine[i].label_name == "face" || |
|
|
ai_json.AiEngine[i].label_name == "blank" || |
|
|
ai_json.AiEngine[i].label_name == "stop_sign" || |
|
|
ai_json.AiEngine[i].label_name == "qrcode" || |
|
|
ai_json.AiEngine[i].label_name == "barcode" || |
|
|
ai_json.AiEngine[i].label_name == "L._Plate_TWN") { |
|
|
|
|
|
if (ai_json.AiEngine[i].properties) { |
|
|
if (ai_json.AiEngine[i].properties.plate) { |
|
|
var plate_name = ""; |
|
|
if (ai_json.AiEngine[i].label_name == "ambulance") |
|
|
plate_name = plate_name.concat(ai_json.AiEngine[i].label_name); |
|
|
else if (ai_json.AiEngine[i].label_name == "blank") |
|
|
plate_name = plate_name.concat(ai_json.AiEngine[i].label_name); |
|
|
else if (ai_json.AiEngine[i].label_name == "stop_sign") |
|
|
plate_name = plate_name.concat(ai_json.AiEngine[i].label_name); |
|
|
else |
|
|
plate_name = plate_name.concat(ai_json.AiEngine[i].properties.plate); |
|
|
|
|
|
|
|
|
AssignPlateObject(ai_json, i, plate_name); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
else { |
|
|
var x = parseInt(ai_json.AiEngine[i].x, 10); |
|
|
var y = parseInt(ai_json.AiEngine[i].y, 10); |
|
|
var w = parseInt(ai_json.AiEngine[i].w, 10); |
|
|
var h = parseInt(ai_json.AiEngine[i].h, 10); |
|
|
var obj_tracking_id = parseInt(ai_json.AiEngine[i].obj_tracking_id, 10); |
|
|
var number_row = ai_json.AiEngine[i].number_row; |
|
|
|
|
|
var text_y = parseInt((ai_json.AiEngine[i].y + ai_json.AiEngine[i].h), 10); |
|
|
|
|
|
if (x == 0 || y == 0 || w == 0 || h == 0 || text_y == 0) |
|
|
continue; |
|
|
|
|
|
var plate_name = ""; |
|
|
plate_name = plate_name.concat(ai_json.AiEngine[i].label_name); |
|
|
plate_name = plate_name.replace(/[「」‘’']/g, ''); |
|
|
|
|
|
if (plate_name === '' || plate_name === '0') { |
|
|
continue; |
|
|
} |
|
|
|
|
|
if (canvasTripwire1) { |
|
|
|
|
|
var translate_name = func_translate_name(plate_name); |
|
|
|
|
|
var behavior_id = ai_json.AiEngine[i].behavior_id; |
|
|
var detection_zone_id = ai_json.AiEngine[i].detection_zone_id; |
|
|
var obj_dwell_time = ai_json.AiEngine[i].obj_dwell_time; |
|
|
var color = ai_json.AiEngine[i].color; |
|
|
var center_direction = ai_json.AiEngine[i].center_direction; |
|
|
var center_stability = ai_json.AiEngine[i].center_stability; |
|
|
var center_speed = ai_json.AiEngine[i].center_speed; |
|
|
var progress_bar = ai_json.AiEngine[i].progress_bar; |
|
|
|
|
|
var tof_distance = ai_json.AiEngine[i].tof_distance; |
|
|
var tof_height = ai_json.AiEngine[i].tof_height; |
|
|
|
|
|
var code_content = ai_json.AiEngine[i].code_content; |
|
|
|
|
|
var label_word = ""; |
|
|
|
|
|
if (localStorage.getItem('current_state_hide_or_open_label') != null && current_state_hide_or_open_label != localStorage.getItem('current_state_hide_or_open_label')) { |
|
|
current_state_hide_or_open_label = localStorage.getItem('current_state_hide_or_open_label'); |
|
|
} |
|
|
|
|
|
if (localStorage.getItem('current_state_hide_or_open_direction') != null && current_state_hide_or_open_direction != localStorage.getItem('current_state_hide_or_open_direction')) { |
|
|
current_state_hide_or_open_direction = localStorage.getItem('current_state_hide_or_open_direction'); |
|
|
} |
|
|
|
|
|
if (localStorage.getItem('current_state_hide_or_open_speed') != null && current_state_hide_or_open_speed != localStorage.getItem('current_state_hide_or_open_speed')) { |
|
|
current_state_hide_or_open_speed = localStorage.getItem('current_state_hide_or_open_speed'); |
|
|
} |
|
|
|
|
|
if (plate_name == "bg_learning") { |
|
|
if (current_state_hide_or_open_label == 1) { |
|
|
label_word = "Bg_learning, prg: " + progress_bar.toString() + "%" + ", ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time); |
|
|
} |
|
|
} |
|
|
else if (plate_name == "tof_point") { |
|
|
//if (current_state_hide_or_open_label == 1) |
|
|
{ |
|
|
if (ai_json.AiEngine[i].max_distance != 0 && ai_json.AiEngine[i].max_height != 0) { |
|
|
label_word = "Max"; |
|
|
|
|
|
var meterToft = 3.2808 |
|
|
var maxmeter = Math.floor((ai_json.AiEngine[i].max_distance / 1000) * 1000) / 1000; |
|
|
var maxft = Math.floor((ai_json.AiEngine[i].max_distance / 1000) * meterToft * 1000) / 1000; |
|
|
|
|
|
var maxmeter_h = Math.floor((ai_json.AiEngine[i].max_height / 1000) * 1000) / 1000; |
|
|
var maxft_h = Math.floor((ai_json.AiEngine[i].max_height / 1000) * meterToft * 1000) / 1000; |
|
|
|
|
|
insert_red_text_max = "Max,"; |
|
|
if (g_tof_enable_show_distance == 1) |
|
|
insert_red_text_max += "Dist: " + maxmeter.toString() + "M " + maxft.toString() + "Ft,"; |
|
|
if (g_tof_enable_show_height == 1) |
|
|
insert_red_text_max += "Ht: " + maxmeter_h.toString() + "M " + maxft_h.toString() + "Ft,"; |
|
|
if (g_tof_enable_show_distance == 0 && g_tof_enable_show_height == 0) { |
|
|
insert_red_text_max += "Dist: " + maxmeter.toString() + "M " + maxft.toString() + "Ft,"; |
|
|
insert_red_text_max += "Ht: " + maxmeter_h.toString() + "M " + maxft_h.toString() + "Ft,"; |
|
|
} |
|
|
} |
|
|
else if (ai_json.AiEngine[i].min_distance != 0 && ai_json.AiEngine[i].min_height != 0) { |
|
|
label_word = "Min"; |
|
|
|
|
|
var meterToft = 3.2808 |
|
|
var minmeter = Math.floor((ai_json.AiEngine[i].min_distance / 1000) * 1000) / 1000; |
|
|
var minft = Math.floor((ai_json.AiEngine[i].min_distance / 1000) * meterToft * 1000) / 1000; |
|
|
|
|
|
var minmeter_h = Math.floor((ai_json.AiEngine[i].min_height / 1000) * 1000) / 1000; |
|
|
var minft_h = Math.floor((ai_json.AiEngine[i].min_height / 1000) * meterToft * 1000) / 1000; |
|
|
|
|
|
insert_red_text_min = "Min,"; |
|
|
if (g_tof_enable_show_distance == 1) |
|
|
insert_red_text_min += "Dist: " + minmeter.toString() + "M " + minft.toString() + "Ft,"; |
|
|
if (g_tof_enable_show_height == 1) |
|
|
insert_red_text_min += "Ht: " + minmeter_h.toString() + "M " + minft_h.toString() + "Ft,"; |
|
|
if (g_tof_enable_show_distance == 0 && g_tof_enable_show_height == 0) { |
|
|
insert_red_text_min += "Dist: " + minmeter.toString() + "M " + minft.toString() + "Ft,"; |
|
|
insert_red_text_min += "Ht: " + minmeter_h.toString() + "M " + minft_h.toString() + "Ft,"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (plate_name == "object") { |
|
|
if (current_state_hide_or_open_direction == 1) { |
|
|
label_word = translate_name + ", N:" + ai_json.AiEngine[i].confidence.toString() + "%" + ", L:" + ai_json.AiEngine[i].confidence2.toString() + "%"; |
|
|
} |
|
|
|
|
|
if (current_state_hide_or_open_speed == 1) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time); |
|
|
} |
|
|
else { |
|
|
label_word = "ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time); |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (current_state_hide_or_open_label == 1) { |
|
|
if (code_content.length == 0) { |
|
|
if (localStorage.getItem("events_default_version") != null && localStorage.getItem("events_default_version") == "4") { |
|
|
label_word = translate_name; |
|
|
} |
|
|
else { |
|
|
label_word = translate_name + ", " + ai_json.AiEngine[i].confidence.toString() + "%"; |
|
|
} |
|
|
} |
|
|
else |
|
|
label_word = translate_name + ", " + code_content; |
|
|
} |
|
|
if (current_state_hide_or_open_direction == 1) { |
|
|
|
|
|
if (center_direction.length == 0) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time); |
|
|
} |
|
|
else { |
|
|
label_word = "ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time); |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time) + ", D:" + center_direction; |
|
|
} |
|
|
else { |
|
|
label_word = "ID: " + obj_tracking_id + Concat_obj_dwell_time(obj_dwell_time) + ", D:" + center_direction; |
|
|
} |
|
|
} |
|
|
|
|
|
if (typeof center_stability !== 'undefined') { |
|
|
if (center_stability.length == 0) { |
|
|
|
|
|
} |
|
|
else { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", St:" + center_stability; |
|
|
} |
|
|
else { |
|
|
label_word = "St:" + center_stability; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (current_state_hide_or_open_speed == 1 && center_speed.length >= 1) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", S:" + center_speed; |
|
|
} |
|
|
else { |
|
|
label_word = "S:" + center_speed; |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("events_default_version") != null && localStorage.getItem("events_default_version") == "4") { |
|
|
if (current_state_hide_or_open_speed == 1) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", " + ai_json.AiEngine[i].confidence.toString() + "%"; |
|
|
} |
|
|
else { |
|
|
label_word = ai_json.AiEngine[i].confidence.toString() + "%"; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
var tof_distance = ai_json.AiEngine[i].tof_distance; |
|
|
var tof_height = ai_json.AiEngine[i].tof_height; |
|
|
|
|
|
if (tof_distance && tof_height) { |
|
|
|
|
|
var meterToft = 3.2808 |
|
|
var tof_meter = roundDown(tof_distance, 3); |
|
|
var tof_ft = roundDown(Math.floor(tof_distance * meterToft * 1000) / 1000, 3); |
|
|
|
|
|
var tof_meter_h = roundDown(tof_height, 3); |
|
|
var tof_ft_h = roundDown(Math.floor(tof_height * meterToft * 1000) / 1000, 3); |
|
|
|
|
|
if (g_tof_enable_show_distance == 1) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", Dist: " + tof_meter.toString() + "M " + tof_ft.toString() + "Ft,"; |
|
|
} |
|
|
else { |
|
|
label_word = "Dist: " + tof_meter.toString() + "M " + tof_ft.toString() + "Ft,"; |
|
|
} |
|
|
} |
|
|
|
|
|
if (g_tof_enable_show_height == 1) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", Ht: " + tof_meter_h.toString() + "M " + tof_ft_h.toString() + "Ft,"; |
|
|
} |
|
|
else { |
|
|
label_word = "Ht: " + tof_meter_h.toString() + "M " + tof_ft_h.toString() + "Ft,"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (g_tof_enable_show_distance == 0 && g_tof_enable_show_height == 0) { |
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", Dist: " + tof_meter.toString() + "M " + tof_ft.toString() + "Ft,"; |
|
|
label_word += "Ht: " + tof_meter_h.toString() + "M " + tof_ft_h.toString() + "Ft,"; |
|
|
} |
|
|
else { |
|
|
label_word = "Dist: " + tof_meter.toString() + "M " + tof_ft.toString() + "Ft,"; |
|
|
label_word += "Ht: " + tof_meter_h.toString() + "M " + tof_ft_h.toString() + "Ft,"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (label_word.length >= 1) { |
|
|
label_word += ", " + color; |
|
|
} |
|
|
else { |
|
|
label_word = color; |
|
|
} |
|
|
|
|
|
if (behavior_id <= 0) { |
|
|
canvasTripwire1.add(insertTrafficLightRectangle(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, w * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, h * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, 1, 1, plate_name, number_row)); |
|
|
} |
|
|
else { |
|
|
canvasTripwire1.add(insertTrafficLightRectangle_Red(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, w * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, h * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, 1, 1, plate_name)); |
|
|
} |
|
|
|
|
|
if (behavior_id >= 1) { |
|
|
//if (current_state_hide_or_open_label) |
|
|
{ |
|
|
//console.log("Behavior occured: " + behavior_id.toString() + "; ID: " + obj_tracking_id.toString() + "; zone: " + detection_zone_id.toString()); |
|
|
canvasTripwire1.add(insertTextLabel_Red(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, label_word)); |
|
|
} |
|
|
} |
|
|
else { |
|
|
//if (current_state_hide_or_open_label) |
|
|
{ |
|
|
canvasTripwire1.add(insertTextLabel(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, label_word)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
plate_count++; |
|
|
plate_idx++; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
RenderAllCanvas(); |
|
|
ai_json = null; |
|
|
} |
|
|
else { |
|
|
wait_count++; |
|
|
if (wait_count >= 3) { |
|
|
wait_count = 0; |
|
|
complete_data = ""; |
|
|
} |
|
|
|
|
|
clear_count++; |
|
|
if (clear_count >= 3) { |
|
|
clear_count = 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
function Concat_obj_dwell_time(obj_dwell_time) { |
|
|
if (parseInt(obj_dwell_time, 10) >= 1) { |
|
|
return "; dwell: " + obj_dwell_time; |
|
|
} |
|
|
else |
|
|
return ""; |
|
|
} |
|
|
|
|
|
function AssignPlateObject(ai_json, i_index, plate_name) { |
|
|
var x = parseInt(ai_json.AiEngine[i_index].x, 10); |
|
|
var y = parseInt(ai_json.AiEngine[i_index].y, 10); |
|
|
var w = parseInt(ai_json.AiEngine[i_index].w, 10); |
|
|
var h = parseInt(ai_json.AiEngine[i_index].h, 10); |
|
|
var text_y = parseInt((ai_json.AiEngine[i_index].y + ai_json.AiEngine[i_index].h), 10); |
|
|
//console.log(text_y); |
|
|
if (x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH <= G_VIEW_CANVAS_X * 0.041) { |
|
|
x = G_CAM_VIDEO_RES_WIDTH*0.041; |
|
|
} |
|
|
else if (x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH >= G_VIEW_CANVAS_X*0.958) { |
|
|
x = G_CAM_VIDEO_RES_WIDTH*0.958; |
|
|
} |
|
|
|
|
|
if (y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT <= G_VIEW_CANVAS_Y*0.062) { |
|
|
y = G_CAM_VIDEO_RES_HEIGHT*0.062; |
|
|
} |
|
|
else if (y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT >= G_VIEW_CANVAS_Y*0.937) { |
|
|
y = G_CAM_VIDEO_RES_HEIGHT*0.937; |
|
|
} |
|
|
|
|
|
if (x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH + w * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH >= G_VIEW_CANVAS_X*0.958) { |
|
|
w = parseInt((G_VIEW_CANVAS_X*0.958 - x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH) * 4, 10); |
|
|
} |
|
|
|
|
|
if (y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT + h * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT >= G_VIEW_CANVAS_Y * 0.937) { |
|
|
h = parseInt((G_VIEW_CANVAS_Y * 0.937 - y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT) * 3.33, 10); |
|
|
} |
|
|
|
|
|
text_y = y - 66; |
|
|
|
|
|
var area_name = ""; |
|
|
var country_name = ""; |
|
|
var out_label = ""; |
|
|
|
|
|
if (ai_json.AiEngine[i_index].label_name == "L._Plate_USA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_THA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_BGD" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_MEA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_AUS" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_EUR" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_JPN") { |
|
|
area_name = area_name.concat(ai_json.AiEngine[i_index].properties.area); |
|
|
country_name = country_name.concat(ai_json.AiEngine[i_index].properties.country); |
|
|
|
|
|
var obj_dwell_time = ai_json.AiEngine[i_index].obj_dwell_time; |
|
|
var obj_tracking_id = parseInt(ai_json.AiEngine[i_index].obj_tracking_id, 10); |
|
|
|
|
|
|
|
|
out_label = out_label.concat(plate_name, ", ", area_name, " ", country_name, ", ", ai_json.AiEngine[i_index].confidence.toString(), "%", |
|
|
", ID: ", obj_tracking_id, Concat_obj_dwell_time(obj_dwell_time)); |
|
|
} |
|
|
else { |
|
|
var obj_dwell_time = ai_json.AiEngine[i_index].obj_dwell_time; |
|
|
var obj_tracking_id = parseInt(ai_json.AiEngine[i_index].obj_tracking_id, 10); |
|
|
|
|
|
out_label = out_label.concat(plate_name, ", ", ai_json.AiEngine[i_index].confidence.toString(), "%", |
|
|
", ID: ", obj_tracking_id, Concat_obj_dwell_time(obj_dwell_time)); |
|
|
} |
|
|
|
|
|
if (canvasTripwire1) { |
|
|
canvasTripwire1.add(insertTrafficLightRectangle(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, w * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, h * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, 1, 1, "", 1)); |
|
|
|
|
|
var behavior_id = ai_json.AiEngine[i_index].behavior_id; |
|
|
if (ai_json.AiEngine[i_index].label_name == "L._Plate_USA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_THA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_BGD" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_MEA" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_AUS" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_EUR" || |
|
|
ai_json.AiEngine[i_index].label_name == "L._Plate_JPN") { |
|
|
if (behavior_id >= 1) { |
|
|
canvasTripwire1.add(insertTextLabel_Red(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, out_label)); |
|
|
} |
|
|
else { |
|
|
canvasTripwire1.add(insertTextLabel(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, out_label)); |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (behavior_id >= 1) { |
|
|
canvasTripwire1.add(insertTextLabel_Red(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, out_label)); |
|
|
} |
|
|
else { |
|
|
canvasTripwire1.add(insertTextLabel(x * G_VIEW_CANVAS_X / G_CAM_VIDEO_RES_WIDTH, text_y * G_VIEW_CANVAS_Y / G_CAM_VIDEO_RES_HEIGHT, G_VIEW_CANVAS_X*0.104, G_VIEW_CANVAS_X*0.104, out_label)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
function RenderAllCanvas() { |
|
|
|
|
|
if (canvasTripwire1) { |
|
|
canvasTripwire1.renderAll(); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
function RefreshCanvasObject(max_protected_objects) { |
|
|
|
|
|
if (typeof canvasTripwire1 !== 'undefined') { |
|
|
//Clear all objects |
|
|
while (canvasTripwire1.getObjects().length > max_protected_objects) { |
|
|
var items = canvasTripwire1.getObjects(); |
|
|
if (items[canvasTripwire1.getObjects().length - 1]) { |
|
|
canvasTripwire1.remove(items[canvasTripwire1.getObjects().length - 1]); |
|
|
} |
|
|
} |
|
|
//canvasTripwire1.getObjects()[0].stroke = "#ffff00"; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
function func_translate_name(translate_name) { |
|
|
|
|
|
var json_label_names = JSON.parse(LABEL_NAMES); |
|
|
var json_label_names_zh_tw = JSON.parse(LABEL_NAMES_zh_tw); |
|
|
var json_label_names_ja_jp = JSON.parse(LABEL_NAMES_ja_jp); |
|
|
var json_label_names_it_it = JSON.parse(LABEL_NAMES_it_it); |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("RAFFIC") >= 1) { |
|
|
var data = json_label_names.Tiny_Traffic[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.Tiny_Traffic[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.Tiny_Traffic[0]; |
|
|
var data_it_it = json_label_names_it_it.Tiny_Traffic[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (localStorage.getItem("events_default_version") != null && localStorage.getItem("events_default_version") == "4") { |
|
|
if (translate_name == "person") { |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = "人"; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = "人"; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = "Umana"; |
|
|
else |
|
|
translate_name = "Human"; |
|
|
} |
|
|
else if (translate_name == "car") { |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = "車"; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = "車"; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = "Veicolo"; |
|
|
else |
|
|
translate_name = "Vehicle"; |
|
|
} |
|
|
else { |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
} |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("IFIRE") >= 1) { |
|
|
var data = json_label_names.AIFIRE[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIFIRE[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIFIRE[0]; |
|
|
var data_it_it = json_label_names_it_it.AIFIRE[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("IAERO") >= 1) { |
|
|
var data = json_label_names.AIAERO[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIAERO[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIAERO[0]; |
|
|
var data_it_it = json_label_names_it_it.AIAERO[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("ITOF") >= 1) { |
|
|
var data = json_label_names.AITOF[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AITOF[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AITOF[0]; |
|
|
var data_it_it = json_label_names_it_it.AITOF[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("UMAN") >= 1) { |
|
|
var data = json_label_names.AIHUMAN[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIHUMAN[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIHUMAN[0]; |
|
|
var data_it_it = json_label_names_it_it.AIHUMAN[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("ISAFTY") >= 1) { |
|
|
var data = json_label_names.AISAFETY[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AISAFETY[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AISAFETY[0]; |
|
|
var data_it_it = json_label_names_it_it.AISAFETY[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("IPRODUCTION") >= 1) { |
|
|
var data = json_label_names.AIPRODUCTION[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIPRODUCTION[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIPRODUCTION[0]; |
|
|
var data_it_it = json_label_names_it_it.AIPRODUCTION[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("ISHIP") >= 1) { |
|
|
var data = json_label_names.AISHIP[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AISHIP[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AISHIP[0]; |
|
|
var data_it_it = json_label_names_it_it.AISHIP[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("license_type").search("LPR") >= 1) { |
|
|
var data = json_label_names.AIANPR[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIANPR[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIANPR[0]; |
|
|
var data_it_it = json_label_names_it_it.AIANPR[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("IAML") >= 1) { |
|
|
var data = json_label_names.AIAML[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIAML[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIAML[0]; |
|
|
var data_it_it = json_label_names_it_it.AIAML[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("IFRONTBACK") >= 1) { |
|
|
var data = json_label_names.AIFRONTBACK[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIFRONTBACK[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIFRONTBACK[0]; |
|
|
var data_it_it = json_label_names_it_it.AIFRONTBACK[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (localStorage.getItem("dataset_ver").search("IRAIL") >= 1) { |
|
|
var data = json_label_names.AIRAILWAY[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIRAILWAY[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIRAILWAY[0]; |
|
|
var data_it_it = json_label_names_it_it.AIRAILWAY[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("ISPORTS") >= 1) { |
|
|
var data = json_label_names.AISPORTS[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AISPORTS[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AISPORTS[0]; |
|
|
var data_it_it = json_label_names_it_it.AISPORTS[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("IFACE") >= 1) { |
|
|
var data = json_label_names.AIFACE[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIFACE[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIFACE[0]; |
|
|
var data_it_it = json_label_names_it_it.AIFACE[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("IGARBAGE") >= 1) { |
|
|
var data = json_label_names.AIGARBAGE[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIGARBAGE[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIGARBAGE[0]; |
|
|
var data_it_it = json_label_names_it_it.AIGARBAGE[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (localStorage.getItem("dataset_ver").search("IGENDER") >= 1) { |
|
|
var data = json_label_names.AIGENDER[0]; |
|
|
var data_zh_tw = json_label_names_zh_tw.AIGENDER[0]; |
|
|
var data_ja_jp = json_label_names_ja_jp.AIGENDER[0]; |
|
|
var data_it_it = json_label_names_it_it.AIGENDER[0]; |
|
|
for (var key in data) { |
|
|
if (data.hasOwnProperty(key)) { |
|
|
if (data[key] != "_s") { |
|
|
var label_names = data[key]; |
|
|
if (label_names == translate_name) { |
|
|
var label_names_zh_tw = data_zh_tw[key]; |
|
|
var label_names_ja_jp = data_ja_jp[key]; |
|
|
var label_names_it_it = data_it_it[key]; |
|
|
if (G_LANG == "zh_tw") |
|
|
translate_name = label_names_zh_tw; |
|
|
else if (G_LANG == "ja_jp") |
|
|
translate_name = label_names_ja_jp; |
|
|
else if (G_LANG == "it_it") |
|
|
translate_name = label_names_it_it; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return translate_name; |
|
|
} |