我想從視頻截圖中提取個人作為影像。因此,從這一幀開始,我想要 5 張影像,我將通過為每個視頻框創建邊界框將其匯出為 1.jpg、2.jpg ...、5.jpg。

這里有第七個輪廓,在影像的左上角。可以這樣過濾掉:
# Reject any contour smaller than min_area
min_area = 20000 # in square pixels
contours = [contour for contour in contours if cv2.contourArea(contour) >= min_area]
輸出:

下一步是使用 找到每個相機的最小邊界矩形boundingRect():
# Get bounding rectangle for each contour
bounding_rects = [cv2.boundingRect(contour) for contour in contours]
# Display each rectangle
img = img_orig.copy()
for rect in bounding_rects:
x,y,w,h = rect
cv2.rectangle(img,(x,y),(x w,y h),(0,255,0),10)
plt.imshow(img)
輸出:

在bounding_rects串列中,您現在擁有每個相機的 x、y、寬度和高度。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/534347.html
