diff --git a/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt b/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt index 8a71f8f..4ee02aa 100644 --- a/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt @@ -118,6 +118,19 @@ "安全标识", "电路图", "电线暴露", "跨电线", "配电箱", "贴纸", "开关" ) + //有限空间作业 + val CONFINED_SPACES_SCENE_ARRAY = arrayListOf( + "安全帽", "呼吸面罩", "施工路牌", "安全告知牌", "危险告知牌", "警戒线", + "路锥", "三脚架", "对讲机", "反光衣", "照明设备", "气体检测仪", "安全绳", + "灭火器", "风管", "鼓风机", "人" + ) + + //非居 + val NON_RESIDENTIAL_SCENE_ARRAY = arrayListOf( + "三通", "切断阀", "喉箍", "熄火保护", "风管", "软管", "报警装置", "接头", "灶台", + "灶眼", + ) + //调压站 val PRESSURE_REGULATING_STATION_SCENE_ARRAY = arrayListOf( "调压器", "阀门", "压力表", "流量计", "过滤器", "调长器", "压力测试仪", "长柄阀门" @@ -125,29 +138,7 @@ //建筑消防 val FIRE_PROTECTION_SCENE_ARRAY = arrayListOf( - "消火栓箱", "尖头水枪", "圆头水枪", "水带", "水带_矩形", "灭火器" - ) - - //有限空间作业 - val CONFINED_SPACES_SCENE_ARRAY = arrayListOf( - "安全帽", - "呼吸面罩", - "施工路牌", - "安全告知牌", - "危险告知牌", - "警戒线", - "路锥", - "三脚架", - "对讲机", - "反光衣", - "照明设备", - "气体检测仪", - "安全绳" - ) - - //非居 - val NON_RESIDENTIAL_SCENE_ARRAY = arrayListOf( - "三通", "人", "切断阀", "喉箍", "熄火保护", "风管", "软管", "报警装置", "接头" + "消火栓箱", "尖头水枪", "圆头水枪", "水带", "水带_矩形" ) /** diff --git a/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt b/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt index 8a71f8f..4ee02aa 100644 --- a/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/br/ar/app/utils/LocaleConstant.kt @@ -118,6 +118,19 @@ "安全标识", "电路图", "电线暴露", "跨电线", "配电箱", "贴纸", "开关" ) + //有限空间作业 + val CONFINED_SPACES_SCENE_ARRAY = arrayListOf( + "安全帽", "呼吸面罩", "施工路牌", "安全告知牌", "危险告知牌", "警戒线", + "路锥", "三脚架", "对讲机", "反光衣", "照明设备", "气体检测仪", "安全绳", + "灭火器", "风管", "鼓风机", "人" + ) + + //非居 + val NON_RESIDENTIAL_SCENE_ARRAY = arrayListOf( + "三通", "切断阀", "喉箍", "熄火保护", "风管", "软管", "报警装置", "接头", "灶台", + "灶眼", + ) + //调压站 val PRESSURE_REGULATING_STATION_SCENE_ARRAY = arrayListOf( "调压器", "阀门", "压力表", "流量计", "过滤器", "调长器", "压力测试仪", "长柄阀门" @@ -125,29 +138,7 @@ //建筑消防 val FIRE_PROTECTION_SCENE_ARRAY = arrayListOf( - "消火栓箱", "尖头水枪", "圆头水枪", "水带", "水带_矩形", "灭火器" - ) - - //有限空间作业 - val CONFINED_SPACES_SCENE_ARRAY = arrayListOf( - "安全帽", - "呼吸面罩", - "施工路牌", - "安全告知牌", - "危险告知牌", - "警戒线", - "路锥", - "三脚架", - "对讲机", - "反光衣", - "照明设备", - "气体检测仪", - "安全绳" - ) - - //非居 - val NON_RESIDENTIAL_SCENE_ARRAY = arrayListOf( - "三通", "人", "切断阀", "喉箍", "熄火保护", "风管", "软管", "报警装置", "接头" + "消火栓箱", "尖头水枪", "圆头水枪", "水带", "水带_矩形" ) /** diff --git a/app/src/main/java/com/casic/br/ar/app/widgets/FreeModeYoloDetectView.kt b/app/src/main/java/com/casic/br/ar/app/widgets/FreeModeYoloDetectView.kt index 7d441a7..09c213f 100644 --- a/app/src/main/java/com/casic/br/ar/app/widgets/FreeModeYoloDetectView.kt +++ b/app/src/main/java/com/casic/br/ar/app/widgets/FreeModeYoloDetectView.kt @@ -25,7 +25,7 @@ private val rect by lazy { Rect() } private var detectResults: MutableList = ArrayList() private var segmentationResults: MutableList = ArrayList() - private var hiddenTroubles: MutableList = ArrayList() + private var hiddenTrouble = YoloResult() private var textHeight = 0 init { @@ -49,138 +49,141 @@ ) { this.segmentationResults = segmentationResults this.detectResults = detectResults + postInvalidate() //筛选出隐患 - val hiddenTroubles = ArrayList() if (detectResults.isNotEmpty()) { //要先判断场景。用第一个结果作为场景判断依据 val firstTarget = LocaleConstant.CLASS_NAMES_ARRAY[detectResults.first().type] - val sceneName = if (LocaleConstant.DISTRIBUTION_BOX_SCENE_ARRAY.contains(firstTarget)) { - "配电箱" + hiddenTrouble.position = detectResults.first().position + if (LocaleConstant.DISTRIBUTION_BOX_SCENE_ARRAY.contains(firstTarget)) { + if (!detectResults.isContains(16)) { + hiddenTrouble.type = 0 + postInvalidate() + } + + if (!detectResults.isContains(36)) { + hiddenTrouble.type = 1 + postInvalidate() + } + + if (detectResults.isContains(35)) { + for (yolo in detectResults) { + if (yolo.type == 35) { + hiddenTrouble.position = yolo.position + hiddenTrouble.type = 2 + postInvalidate() + break + } + } + } + + if (detectResults.isContains(41)) { + for (yolo in detectResults) { + if (yolo.type == 41) { + hiddenTrouble.position = yolo.position + hiddenTrouble.type = 3 + postInvalidate() + break + } + } + } } else if (LocaleConstant.CONFINED_SPACES_SCENE_ARRAY.contains(firstTarget)) { - "有限空间作业" + if (detectResults.isContains(3)) { + if (!detectResults.isContains(15)) { + hiddenTrouble.type = 4 + postInvalidate() + } + + if (!detectResults.isContains(20)) { + hiddenTrouble.type = 5 + postInvalidate() + } + + if (!detectResults.isContains(15) && !detectResults.isContains(17)) { + hiddenTrouble.type = 6 + postInvalidate() + } + } + + if (!detectResults.isContains(9)) { + hiddenTrouble.type = 7 + postInvalidate() + } + + if (!detectResults.isContains(42) && !detectResults.isContains(37)) { + hiddenTrouble.type = 8 + postInvalidate() + } + + if (!detectResults.isContains(14)) { + hiddenTrouble.type = 9 + postInvalidate() + } + + if (!detectResults.isContains(51)) { + hiddenTrouble.type = 10 + postInvalidate() + } + + if (!detectResults.isContains(33)) { + hiddenTrouble.type = 11 + postInvalidate() + } + + if (!detectResults.isContains(18)) { + hiddenTrouble.type = 12 + postInvalidate() + } + + if (!detectResults.isContains(0)) { + hiddenTrouble.type = 13 + postInvalidate() + } + + if (!detectResults.isContains(25)) { + hiddenTrouble.type = 14 + postInvalidate() + } } else if (LocaleConstant.NON_RESIDENTIAL_SCENE_ARRAY.contains(firstTarget)) { - "非居民用户" - } else { - "" - } - - val result = YoloResult() - result.position = detectResults.first().position - when (sceneName) { - "配电箱" -> { - //配电箱位置即为隐患位置 - if (!detectResults.isContains(16)) { - result.type = 0 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(36)) { - result.type = 1 - hiddenTroubles.add(result) - } - - if (detectResults.isContains(35)) { - result.type = 2 - hiddenTroubles.add(result) - } - - if (detectResults.isContains(41)) { - result.type = 3 - hiddenTroubles.add(result) + if (detectResults.isContains(49)) { + for (yolo in detectResults) { + if (yolo.type == 49) { + hiddenTrouble.position = yolo.position + hiddenTrouble.type = 15 + postInvalidate() + break + } } } - "有限空间作业" -> { - if (detectResults.isContains(3)) { - if (!detectResults.isContains(15)) { - result.type = 4 - hiddenTroubles.add(result) + if (detectResults.isContains(1)) { + for (yolo in detectResults) { + if (yolo.type == 1) { + hiddenTrouble.position = yolo.position + hiddenTrouble.type = 16 + postInvalidate() + break } - - if (!detectResults.isContains(20)) { - result.type = 5 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(15) && !detectResults.isContains(17)) { - result.type = 6 - hiddenTroubles.add(result) - } - } - - if (!detectResults.isContains(9)) { - result.type = 7 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(42) && !detectResults.isContains(37)) { - result.type = 8 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(14)) { - result.type = 9 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(51)) { - result.type = 10 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(33)) { - result.type = 11 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(18)) { - result.type = 12 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(0)) { - result.type = 13 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(25)) { - result.type = 14 - hiddenTroubles.add(result) } } - "非居民用户" -> { - if (detectResults.isContains(49)) { - result.type = 15 - hiddenTroubles.add(result) - } + if (!detectResults.isContains(4)) { + hiddenTrouble.type = 17 + postInvalidate() + } - if (detectResults.isContains(1)) { - result.type = 16 - hiddenTroubles.add(result) - } + if (!detectResults.isContains(34)) { + hiddenTrouble.type = 18 + postInvalidate() + } - if (!detectResults.isContains(4)) { - result.type = 17 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(34)) { - result.type = 18 - hiddenTroubles.add(result) - } - - if (!detectResults.isContains(22)) { - result.type = 19 - hiddenTroubles.add(result) - } + if (!detectResults.isContains(22)) { + hiddenTrouble.type = 19 + postInvalidate() } } } - this.hiddenTroubles = hiddenTroubles - - postInvalidate() } override fun onDraw(canvas: Canvas) { @@ -193,8 +196,10 @@ drawAlarmTips(canvas, it, LocaleConstant.SEGMENTATION_ARRAY[it.type]) } - hiddenTroubles.forEach { - drawAlarmTips(canvas, it, LocaleConstant.HIDDEN_TROUBLE_ARRAY[it.type]) + if (detectResults.isNotEmpty()) { + drawAlarmTips( + canvas, hiddenTrouble, LocaleConstant.HIDDEN_TROUBLE_ARRAY[hiddenTrouble.type] + ) } }