python 如何在下面的脚本中读取多个图像?

siv3szwd  于 2023-02-15  发布在  Python
关注(0)|答案(1)|浏览(143)
cv2_imshow((predict[0].masks.masks[0].numpy() * 255).astype("uint8"))

在这个脚本中,我可以读取一个图像,但如何在predict[]中读取多个图像呢?

qmelpv7a

qmelpv7a1#

预测是一个对象列表吗?2如果是,这有帮助吗?

import cv2

# Loop over all the masks in predict
for mask in predict:
    # Display the mask for the first object in the list
    cv2.imshow('Mask', (mask.masks.masks[0].numpy() * 255).astype("uint8"))
    cv2.waitKey(0)

# Close all windows when done
cv2.destroyAllWindows()

相关问题