在對人臉識別中進行影像處理時,運用的np.vstack()函式。使得如果攝像頭中沒有檢測到人臉就會報錯:ValueError: need at least one array to concatenate,有沒有好的解決辦法?
代碼如下:
bounding_boxes = []
for s in scales: # run P-Net on different scales
boxes = run_first_stage(image, pnet, scale=s, threshold=thresholds[0])
bounding_boxes.append(boxes)
# collect boxes (and offsets, and scores) from different scales
bounding_boxes = [i for i in bounding_boxes if i is not None]
bounding_boxes = np.vstack(bounding_boxes)
keep = nms(bounding_boxes[:, 0:5], nms_thresholds[0])
bounding_boxes = bounding_boxes[keep]
bounding_boxes = calibrate_box(bounding_boxes[:, 0:5],
bounding_boxes[:, 5:])
bounding_boxes = convert_to_square(bounding_boxes)
bounding_boxes[:, 0:4] = np.round(bounding_boxes[:, 0:4])
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/58471.html
標籤:機器視覺
上一篇:壓力變送器使用前要怎樣校驗呢
下一篇:問一下陰陽師py腳本的問題
