|
|
|
@ -33,12 +33,13 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
//获取 摄像头图片/标注点位
|
|
|
|
|
getImgMarkData() { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
this.http.get(`/api/Cameras/${this.cameraId}`).subscribe((info: any) => { |
|
|
|
|
info.dimensionedPoints |
|
|
|
|
? (info.dimensionedPoints = JSON.parse(info.dimensionedPoints)) |
|
|
|
|
: null; |
|
|
|
|
this.camerasData = info; |
|
|
|
|
this.markType = info.type; |
|
|
|
|
this.http.get(`/api/Cameras/${this.cameraId}`).subscribe((data: any) => { |
|
|
|
|
console.log(456, data); |
|
|
|
|
// data.dimensionedPointsHuanghai
|
|
|
|
|
// ? (data.dimensionedPointsHuanghai = JSON.parse(data.dimensionedPointsHuanghai))
|
|
|
|
|
// : null;
|
|
|
|
|
this.camerasData = data; |
|
|
|
|
this.markType = data.type; |
|
|
|
|
|
|
|
|
|
this.markType === 3 |
|
|
|
|
? (this.selectedBtn = '收银区') |
|
|
|
@ -91,7 +92,6 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//初始化背景图
|
|
|
|
|
|
|
|
|
|
canvas; |
|
|
|
|
ctx; |
|
|
|
|
|
|
|
|
@ -133,40 +133,52 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//初始化标绘图形
|
|
|
|
|
initMark(canvas, context) { |
|
|
|
|
this.camerasData.dimensionedPointsOfHH = sessionStorage.getItem('xxx'); |
|
|
|
|
|
|
|
|
|
if (!this.camerasData.dimensionedPointsOfHH) { |
|
|
|
|
if (!this.camerasData.dimensionedPointsHuanghai) { |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
this.camerasData.dimensionedPointsOfHH = JSON.parse( |
|
|
|
|
this.camerasData.dimensionedPointsOfHH |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai = JSON.parse( |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('原始标点数据', this.camerasData.dimensionedPointsOfHH); |
|
|
|
|
console.log('原始标点数据', this.camerasData.dimensionedPointsHuanghai); |
|
|
|
|
//收银区
|
|
|
|
|
if (this.camerasData.dimensionedPointsHuanghai.cashierROI.length !== 0) { |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.cashierROI.forEach( |
|
|
|
|
(element) => { |
|
|
|
|
this.cashierROIDrawPolygon(element.x, element.y, canvas, context); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
//绘制停车区多边形
|
|
|
|
|
this.camerasData.dimensionedPointsOfHH.carStopROI.forEach((element) => { |
|
|
|
|
//停车区
|
|
|
|
|
if (this.camerasData.dimensionedPointsHuanghai.carStopROI.length !== 0) { |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.carStopROI.forEach( |
|
|
|
|
(element) => { |
|
|
|
|
this.carStopROIDrawPolygon(element.x, element.y, canvas, context); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制收银区多边形
|
|
|
|
|
this.camerasData.dimensionedPointsOfHH.cashierROI.forEach((element) => { |
|
|
|
|
this.cashierROIDrawPolygon(element.x, element.y, canvas, context); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//绘制闯入区多边形
|
|
|
|
|
this.camerasData.dimensionedPointsOfHH.intrusionROI.forEach((element) => { |
|
|
|
|
//闯入区
|
|
|
|
|
if (this.camerasData.dimensionedPointsHuanghai.intrusionROI.length !== 0) { |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.intrusionROI.forEach( |
|
|
|
|
(element) => { |
|
|
|
|
this.intrusionROIDrawPolygon(element.x, element.y, canvas, context); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//绘制卸油区矩形
|
|
|
|
|
if (this.camerasData.dimensionedPointsHuanghai.unloadingROI.length !== 0) { |
|
|
|
|
this.unloadingROIOblongPoints = |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.unloadingROI; |
|
|
|
|
this.unloadingROIDrawOblong( |
|
|
|
|
this.camerasData.dimensionedPointsOfHH.unloadingROI, |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.unloadingROI, |
|
|
|
|
context |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
markType: number = 0; //0=进出口,1=加油区,2=卸油区,3=便利店,
|
|
|
|
|
|
|
|
|
@ -625,7 +637,19 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
clearCanvas() { |
|
|
|
|
let canvas = document.getElementById('canvas') as any; |
|
|
|
|
let context = canvas.getContext('2d'); |
|
|
|
|
|
|
|
|
|
this.unloadingROIOblongPoints = []; //矩形的点的集合
|
|
|
|
|
//停车区多边形
|
|
|
|
|
this.carStopROIPoints = []; //线段的点的集合
|
|
|
|
|
this.carStopROICircles = []; //可拖动圆圈的点的集合
|
|
|
|
|
this.carStopROIAllpoints = []; //整体移动点位
|
|
|
|
|
//闯入区多边形
|
|
|
|
|
this.intrusionROIPoints = []; //线段的点的集合
|
|
|
|
|
this.intrusionROICircles = []; //可拖动圆圈的点的集合
|
|
|
|
|
this.intrusionROIAllpoints = []; //整体移动点位
|
|
|
|
|
//收银区多边形
|
|
|
|
|
this.cashierROIPoints = []; //线段的点的集合
|
|
|
|
|
this.cashierROICircles = []; //可拖动圆圈的点的集合
|
|
|
|
|
this.cashierROIAllpoints = []; //整体移动点位
|
|
|
|
|
context.clearRect(0, 0, canvas.width, canvas.height); |
|
|
|
|
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null; |
|
|
|
|
} |
|
|
|
@ -639,21 +663,57 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
nzOkType: 'primary', |
|
|
|
|
nzOkDanger: true, |
|
|
|
|
nzOnOk: () => { |
|
|
|
|
// if (type == 'isAllMonitoring') {
|
|
|
|
|
// //全局的多边形
|
|
|
|
|
// this.pointsOfmonitor = [];
|
|
|
|
|
// this.circlesOfmonitor = [];
|
|
|
|
|
// this.context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
|
|
|
|
|
// this.copyCanvas
|
|
|
|
|
// ? this.context.putImageData(this.copyCanvas, 0, 0)
|
|
|
|
|
// : null;
|
|
|
|
|
// }
|
|
|
|
|
// this.initMark2(this.canvas, this.ctx); //初始化标绘图形
|
|
|
|
|
if (this.markType === 2) { |
|
|
|
|
//卸油区
|
|
|
|
|
this.context.clearRect(0, 0, this.canvasWidth, this.canvasHeight); |
|
|
|
|
this.copyCanvas |
|
|
|
|
? this.context.putImageData(this.copyCanvas, 0, 0) |
|
|
|
|
: null; |
|
|
|
|
if (type === 'carStopROI') { |
|
|
|
|
this.carStopROIPoints = []; |
|
|
|
|
this.carStopROICircles = []; |
|
|
|
|
this.carStopROIAllpoints = []; |
|
|
|
|
//重绘闯入和卸油
|
|
|
|
|
this.redrawAll(); |
|
|
|
|
} |
|
|
|
|
if (type === 'intrusionROI') { |
|
|
|
|
this.intrusionROIPoints = []; |
|
|
|
|
this.intrusionROICircles = []; |
|
|
|
|
this.intrusionROIAllpoints = []; |
|
|
|
|
this.redrawAll(); |
|
|
|
|
} |
|
|
|
|
if (type === 'unloadingROI') { |
|
|
|
|
this.unloadingROIOblongPoints = []; |
|
|
|
|
this.redrawAll(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.clearCanvas(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
nzCancelText: '取消', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
redrawAll() { |
|
|
|
|
this.redrawPolygon( |
|
|
|
|
this.carStopROIPoints, |
|
|
|
|
this.carStopROIAllpoints, |
|
|
|
|
this.carStopROICircles, |
|
|
|
|
this.context, |
|
|
|
|
'green' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
this.redrawPolygon( |
|
|
|
|
this.intrusionROIPoints, |
|
|
|
|
this.intrusionROIAllpoints, |
|
|
|
|
this.intrusionROICircles, |
|
|
|
|
this.context, |
|
|
|
|
'red' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
this.redrawRectangle(this.unloadingROIOblongPoints, this.context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//根据已有数据重绘多边形
|
|
|
|
|
redrawPolygon(data, points, circles, context, color) { |
|
|
|
|
data.forEach((element) => { |
|
|
|
@ -699,9 +759,9 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//保存
|
|
|
|
|
save() { |
|
|
|
|
console.log(this.camerasData.dimensionedPointsOfHH); |
|
|
|
|
if (!this.camerasData.dimensionedPointsOfHH) { |
|
|
|
|
this.camerasData.dimensionedPointsOfHH = { |
|
|
|
|
console.log(this.camerasData.dimensionedPointsHuanghai); |
|
|
|
|
if (!this.camerasData.dimensionedPointsHuanghai) { |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai = { |
|
|
|
|
carStopROI: [], |
|
|
|
|
intrusionROI: [], |
|
|
|
|
cashierROI: [], |
|
|
|
@ -714,7 +774,8 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
this.message.create('warning', '绘制完整后可保存!'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.camerasData.dimensionedPointsOfHH.carStopROI = this.carStopROIPoints; |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.carStopROI = |
|
|
|
|
this.carStopROIPoints; |
|
|
|
|
} |
|
|
|
|
//卸油区
|
|
|
|
|
if (this.markType === 2) { |
|
|
|
@ -727,10 +788,11 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.camerasData.dimensionedPointsOfHH.carStopROI = this.carStopROIPoints; |
|
|
|
|
this.camerasData.dimensionedPointsOfHH.intrusionROI = |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.carStopROI = |
|
|
|
|
this.carStopROIPoints; |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.intrusionROI = |
|
|
|
|
this.intrusionROIPoints; |
|
|
|
|
this.camerasData.dimensionedPointsOfHH.unloadingROI = |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.unloadingROI = |
|
|
|
|
this.unloadingROIOblongPoints; |
|
|
|
|
} |
|
|
|
|
//便利店
|
|
|
|
@ -739,24 +801,26 @@ export class ImageLabelComponent implements OnInit {
|
|
|
|
|
this.message.create('warning', '绘制完整后可保存!'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.camerasData.dimensionedPointsOfHH.cashierROI = this.cashierROIPoints; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// let paramsData = JSON.parse(JSON.stringify(this.camerasData));
|
|
|
|
|
// paramsData.dimensionedPointsHH = JSON.stringify(
|
|
|
|
|
// paramsData.dimensionedPointsHH
|
|
|
|
|
// );
|
|
|
|
|
console.log('标点结果', this.camerasData.dimensionedPointsOfHH); |
|
|
|
|
// this.http
|
|
|
|
|
// .put(`/api/Cameras/${this.camerasData.id}/DimensionedPoints`, paramsData)
|
|
|
|
|
// .subscribe((data) => {
|
|
|
|
|
// this.message.create('success', '保存成功!');
|
|
|
|
|
// const isFullScreen = document.fullscreenElement;
|
|
|
|
|
// if (document.exitFullscreen && isFullScreen) {
|
|
|
|
|
// //关闭全屏
|
|
|
|
|
// document.exitFullscreen();
|
|
|
|
|
// }
|
|
|
|
|
// this.modal.closeAll();
|
|
|
|
|
// });
|
|
|
|
|
this.camerasData.dimensionedPointsHuanghai.cashierROI = |
|
|
|
|
this.cashierROIPoints; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let body = { |
|
|
|
|
dimensionedPointsHuanghai: JSON.stringify( |
|
|
|
|
this.camerasData.dimensionedPointsHuanghai |
|
|
|
|
), |
|
|
|
|
}; |
|
|
|
|
console.log('标点结果', this.camerasData.dimensionedPointsHuanghai); |
|
|
|
|
this.http |
|
|
|
|
.put(`/api/Cameras/${this.camerasData.id}/DimensionedPoints`, body) |
|
|
|
|
.subscribe((data) => { |
|
|
|
|
this.message.create('success', '保存成功!'); |
|
|
|
|
const isFullScreen = document.fullscreenElement; |
|
|
|
|
if (document.exitFullscreen && isFullScreen) { |
|
|
|
|
//关闭全屏
|
|
|
|
|
document.exitFullscreen(); |
|
|
|
|
} |
|
|
|
|
this.modal.closeAll(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|