mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
added contour merge for contour grouping
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
from multiprocessing import Queue
|
||||
from multiprocessing.managers import BaseManager
|
||||
|
||||
import tornado.ioloop
|
||||
import multiprocessing
|
||||
import logging
|
||||
from cscore import CameraServer
|
||||
|
||||
from app.ChameleonVisionApp import ChameleonApplication
|
||||
from app.classes.SettingsManager import SettingsManager
|
||||
from tornado.options import options
|
||||
|
||||
@@ -137,18 +137,26 @@ class VisionHandler(metaclass=Singleton):
|
||||
return False
|
||||
if target_group != TargetGroup.Single:
|
||||
f_contour_list = []
|
||||
for index, contour in i_contours:
|
||||
finall_contour = contour
|
||||
for c in range(target_group):
|
||||
first_contour = i_contours[index + c]
|
||||
second_contour = i_contours[index + c + 1]
|
||||
for index, g_contour in enumerate(i_contours):
|
||||
final_contour = g_contour
|
||||
for c in range(target_group.value):
|
||||
try:
|
||||
first_contour = i_contours[index + c]
|
||||
second_contour = i_contours[index + c + 1]
|
||||
except IndexError:
|
||||
continue
|
||||
if is_intersecting(first_contour, second_contour, intersection_point):
|
||||
pass
|
||||
final_contour = numpy.concatenate((final_contour, second_contour))
|
||||
else:
|
||||
continue
|
||||
|
||||
f_contour_list.append(final_contour)
|
||||
|
||||
return f_contour_list
|
||||
else:
|
||||
return i_contours
|
||||
|
||||
'''start of the first filtration of contours'''
|
||||
filtered_contours = []
|
||||
for contour in input_contours:
|
||||
try:
|
||||
@@ -177,8 +185,9 @@ class VisionHandler(metaclass=Singleton):
|
||||
except Exception as e:
|
||||
print(e)
|
||||
continue
|
||||
|
||||
#checking for contour grouping before sorting
|
||||
grouped_contours = group_target(filtered_contours, TargetGroup[target_grouping], target_intersection)
|
||||
|
||||
sorted_contours = getattr(self.sort_mode, sort_mode)(grouped_contours)
|
||||
|
||||
return sorted_contours
|
||||
@@ -217,6 +226,12 @@ class VisionHandler(metaclass=Singleton):
|
||||
port += 1
|
||||
|
||||
def thread_proc(self, cs, cam_name, port=5557):
|
||||
|
||||
def change_camera_values():
|
||||
SettingsManager.usb_cameras[cam_name].setBrightness(0)
|
||||
SettingsManager.usb_cameras[cam_name].setExposureManual(0)
|
||||
SettingsManager.usb_cameras[cam_name].setWhiteBalanceAuto()
|
||||
|
||||
cv_sink = cs.getVideo(camera=SettingsManager.usb_cameras[cam_name])
|
||||
|
||||
width = SettingsManager().cams[cam_name]["video_mode"]["width"]
|
||||
@@ -303,7 +318,8 @@ class VisionHandler(metaclass=Singleton):
|
||||
extent=curr_pipeline['extent'],
|
||||
sort_mode=curr_pipeline['sort_mode'], cam_area=cam_area,
|
||||
target_grouping=curr_pipeline['target_group'],
|
||||
target_intersection=curr_pipeline['target_intersection'])
|
||||
target_intersection=
|
||||
curr_pipeline['target_intersection'])
|
||||
|
||||
res = self.draw_image(input_image=image, is_binary=False, contours=filtered_contours)
|
||||
socket.send_pyobj(res)
|
||||
|
||||
1
backend/settings/cams/USB Camera-B4.09.24.1.json
Normal file
1
backend/settings/cams/USB Camera-B4.09.24.1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"pipelines": {"pipeline0": {"exposure": 50, "brightness": 11, "orientation": "Normal", "resolution": [320, 160], "hue": [0, 100], "saturation": [0, 100], "value": [0, 100], "erode": false, "dilate": false, "area": [0, 100], "ratio": [0, 20], "extent": [0, 100], "is_binary": "Normal", "sort_mode": "Largest", "target_group": "Single", "target_intersection": "Up"}}, "path": "/dev/v4l/by-path/pci-0000:02:03.0-usb-0:1:1.0-video-index0", "video_mode": {"fps": 187, "width": 320, "height": 240, "pixel_format": "kYUYV"}}
|
||||
57
chameleon-client/src/components/ch-range-ratio.vue
Normal file
57
chameleon-client/src/components/ch-range-ratio.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
<template>
|
||||
<row type="flex" justify="start" align="middle" :gutter="1">
|
||||
<Col span="4">
|
||||
<h4>{{title.charAt(0).toUpperCase() + title.slice(1)}} :</h4>
|
||||
</Col>
|
||||
<Col span="4" style="text-align: left">
|
||||
<InputNumber style="align-self: flex-start;" v-model="value[0]" size="small"></InputNumber>
|
||||
</Col>
|
||||
<Col span="10">
|
||||
<Slider range v-model="value" @on-input="handleInput"></Slider>
|
||||
</Col>
|
||||
<Col span="4" style="text-align: right">
|
||||
<InputNumber style="align-self: flex-end;" v-model="value[1]" size="small"></InputNumber>
|
||||
</Col>
|
||||
</row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ch-range',
|
||||
props:{
|
||||
title:String,
|
||||
Xkey:String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleInput() {
|
||||
this.$socket.sendObj({[this.Xkey]:this.value});
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
value:{
|
||||
get:function(){
|
||||
return this.$store.state[this.Xkey];
|
||||
},
|
||||
set:function(value){
|
||||
this.$store.commit(this.Xkey,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
h4 {
|
||||
color: #e6ebf1;
|
||||
}
|
||||
/* .ivu-input-number-input{
|
||||
background-color: #2c3e50 !important;
|
||||
color: #fff !important;
|
||||
} */
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user