def flir_snapshot(snapshot_path):
cam = cv2.VideoCapture(snapshot_path)
if cam.isOpened():
cv2.waitKey(500)
ret, frame = cam.read()
if ret:
return frame
cam.release()
열화상 카메라로 실화상이미지를 저장하고 싶어 RTSP에 접근하였다.
opencv의 cv2.VideoCapture() 메서드를 이용해서 RTSP 영상의 frame을 저장해보니 정상적으로 이미지가 캡쳐되지 않았다.
정상적인 프레임을 가져오기까지 시간이 필요한 것으로 판단되었다.
cv2.waitkey(500) 메서드로 0.5초의 대기시간을 주어해결해보고자 했다. 하지만 그 문제가 해결되지 않았다.
업데이트
이번에는 chatGPT로 상황을 설명하고 문제를 해결하기 위해 코드를 개선해달라고 요청했다.
It seems that the current code takes a snapshot immediately after opening the camera, which may not always provide a clear image as the camera might need some time to adjust the exposure and focus settings. To address this issue, you can try the following changes:
Wait for a few seconds after opening the camera to allow it to stabilize and adjust its settings.Check if the first few frames captured are clear and discard them if they are not.
Here's an updated version of your code with these changes:
def flir_snapshot(snapshot_path):
cam = cv2.VideoCapture(snapshot_path)
if cam.isOpened():
# Wait for a few seconds to allow the camera to stabilize
time.sleep(5)
# Capture a few frames and check if they are clear
for i in range(5):
ret, frame = cam.read()
if ret:
return frame
cam.release()
카메라가 안정화될때까지 기다려주는 코드, frame 몇개를 가지고 상태를 체크하는 것으로 코드를 개선해주었다.
결과는 수집하면서 지켜봐야겠다.
728x90
'Computer Vision' 카테고리의 다른 글
[OpenCV] cv2.VideoWriter로 동영상 생성하기 (0) | 2023.04.19 |
---|---|
[Object Tracking] SORT(Simple Online and Realtime Tracking) 논문 정리 (0) | 2023.03.13 |
[CV] Histogram of Oriented Gradients (0) | 2023.02.23 |
[Python / OpenCV] M1 Mac / VScode / opencv 설치하기 (0) | 2022.06.03 |