开发者

AttributeError list object has no attribute splitlines

i'm working on project object detection using python because i'm new on python i don't know how to fix this, i try all i can and still can't fix it, it was on loop detection pls someone help me i'm try use yolo and pytesseract at sametime

here is my program



    class_ids = []
    confidences = []
    boxes = []
    for out in outs:
        for detection in out:
            scores = detection[5:]
            class_id = np.argmax(scores)
            confidence = scores[class_id]
            if confidence > 0.5:
                # Object detected
                center_x = int(detection[0] * width)
                center_y = int(detection[1] * height)
                w = int(detection[2] * width)
                h = int(detection[3] * height)

                # Rectangle coordinates
                x = int(center_x - w / 2)
                y = int(center_y - h / 2)

                boxes.append([x, y, w, h])
                confidences.append(float(confidence))
                class_ids.append(class_id)

    indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)
    print(indexes)
    font = cv2.FONT_HERSHEY_PLAIN
    for i in range(len(boxes)):
        if i in indexes:
            x, y, w, h = boxes[i]
            label = str(classes[class_ids[i]])
            color = colors[class_ids[i]开发者_StackOverflow社区]
            cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)
            cv2.putText(frame, label, (x, y + 30), font, 3, color, 3)

    for box in boxes.splitlines():
        box = box.split(' ')
    
        x, y, w, h = int(box[1]), int(box[2]), int(box[3]), int(box[4])
        name = box[0]
        
        print(text)
        cv2.rectangle(frame, (x, height-y), (w, height-h), (50,50,255), 1)
        cv2.putText(frame, name, (x, height-y+25), cv2.FONT_HERSHEY_PLAIN, 1, (50,50,255), 2)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜