Skip to content

Commit 1db5e92

Browse files
authored
Merge pull request #4 from hadikoub/patch-2
update to fix negative result issue
2 parents 2cf3db2 + b2e7d8e commit 1db5e92

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

src/main/inference/yolov3_opencv_cpu_detection.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,38 @@ async def infer(self, input_data, draw, predict_batch):
102102
output_bboxes = []
103103
for i in remaining_indices:
104104
box = boxes[i[0]]
105+
left = int(box[0])
106+
107+
right = int(box[0]) + int(box[2])
108+
109+
top = int(box[1])
110+
111+
bottom = int(box[1]) + int(box[3])
112+
113+
114+
115+
116+
if (left < 0):
117+
left = 0
118+
if (right > height- 1):
119+
right = width - 1
120+
if (top < 0):
121+
top = 0
122+
if (bottom >height - 1):
123+
bottom = height - 1
124+
125+
126+
105127
output_bboxes.append(
106128
{
107129
'ObjectClassName': self.labels[class_ids[i[0]]],
108130
'ObjectClassId': class_ids[i[0]],
109131
'confidence': confidences[i[0]],
110132
'coordinates': {
111-
'left': int(box[0]),
112-
'right': int(box[0]) + int(box[2]),
113-
'top': int(box[1]),
114-
'bottom': int(box[1]) + int(box[3])
133+
'left': left,
134+
'right':right,
135+
'top': top,
136+
'bottom': bottom
115137
}
116138
}
117139
)

0 commit comments

Comments
 (0)