如何在边框内获取图像?

时间:2018-12-26 11:09:12

标签: python object-detection

我具有检测器功能,可以拍摄图像并检测人。我想在边框内得到图像。我已经尝试过了,但是并没有给我正确的图像

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

0 个答案:

没有答案