我具有检测器功能,可以拍摄图像并检测人。我想在边框内得到图像。我已经尝试过了,但是并没有给我正确的图像
def run(self,image):
self.personBBs = [] #person bounding boxes
self.sub_image = None # image inside the bounding box
for i, c in reversed(list(enumerate(out_classes))):
predicted_class = self.class_names[c]
if "person" != predicted_class:
continue
score = out_scores[i]
if score > person_threshold:
self.personFlag = True
box = out_boxes[i]
bounding_boxes_list = [int(v) for v in box]
left,top,bottom,right = bounding_boxes_list
#condition for getting the image inside the bounding box
self.sub_image = image[left:bottom, top:right]
self.personBBs.append(bounding_boxes_list)
return self.sub_image,self.personBBs