0

My external thermal webcam is the PureThermal version 1.2.2. I'm on VS Code with a Python 3.9.16 environment and MacOS Ventura 13.3.1

Here is my code:

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()

This code works perfectly with my built-in camera. However, it returns a black window with my external thermal camera. I have the correct index for my thermal camera.

Question: what do I need to add to my code to get my thermal stream working? Do I need to normalize, resize, or do something else?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

0 Answers0