我的外部热敏网络摄像头是 PureThermal 版本 1.2.2。我在 VS Code 上使用 Python 3.9.16 环境和 MacOS Ventura 13.3.1
这是我的代码:
import numpy as np
import cv2
# Replace this with the correct camera index or device name
camera_index = 2
cap = cv2.VideoCapture(camera_index) # apiPreference=cv2.CAP_AVFOUNDATION)
cap.set(cv2.CAP_PROP_FPS, 60)
if not cap.isOpened():
print("Cannot open camera")
exit()
while True:
# Capture frame-by-frame
ret, frame = cap.read()
# if frame is read correctly ret is True
if not ret:
print("Can't receive frame (stream end?). Exiting ...")
break
# Display the resulting frame
cv2.imshow("Webcam Frame", frame)
if cv2.waitKey(1) == ord('q'):
break
# When everything is done, release the capture
cap.release()
cv2.destroyAllWindows()
此代码与我的内置相机完美配合。但是,它会返回带有我的外部热像仪的黑色窗口。我的热像仪有正确的索引。
问题:我需要在我的代码中添加什么才能让我的热流工作?我需要标准化、调整大小或做其他事情吗?