IndentationError unindent与任何外部缩进级别python不匹配

时间:2018-12-05 23:18:29

标签: python yolo

我有一个YOLO的python代码,但是在将检测到的对象提取到单独的图像中时遇到错误。

cv2.imwrite('roi%d.png',count,image[ y:(y+h), x: (x+w) ]) count++

参数x,y,w,h是未检测到对象边界的坐标。

count = 0
        for i in idxs.flatten():
            # extract the bounding box coordinates
            (x, y) = (boxes[i][0], boxes[i][1])
            (w, h) = (boxes[i][2], boxes[i][3])

            # draw a bounding box rectangle and label on the frame

            cv2.imwrite('roi%d.png',count,image[ y:(y+h), x: (x+w) ]) 
              count++
            color = [int(c) for c in COLORS[classIDs[i]]]
            cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)
            text = "{}: {:.4f}".format(LABELS[classIDs[i]],
                confidences[i])
            cv2.putText(frame, text, (x, y - 5),
                cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)

0 个答案:

没有答案