visibilitydataset / visibilitydataset.github.io

MIT License
5 stars 0 forks source link

Thermal image pre-processing #3

Closed SayedNadim closed 1 year ago

SayedNadim commented 1 year ago

Hi, thanks again for the great work. I am wondering about the thermal image pre-processing. I have a FLIR Boson LWIR camera and I recorded some images with it. When I checked the max and min values of the images, I found them to be around 23000 and 22631. But when I checked the same with outdoor_robust_night1, I found them to be around 3200 and 1958. Do you have any hint on this?

This is my code for recording the thermal images.

# capture.py
import cv2
#
cap = cv2.VideoCapture(2)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 512)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('Y', '1', '6', ' '))
cap.set(cv2.CAP_PROP_CONVERT_RGB, 0)

framecount = 200
frame_buf = []
for _ in range(framecount):  # record indefinitely (until user presses q), replace with "while True"
    stream_ret, frame = cap.read()
    if stream_ret:
        frame = cv2.flip(frame, -1)
        print(frame.shape)
        cv2.imshow("image", frame)
        if cv2.waitKey(1) == ord('q'):
            break;
        frame_buf.append(frame)
#
cv2.destroyAllWindows()

folder = './Thermal/'

# Below is example code to save images to "folder" (Use appropriate directory syntax.)
num = 0
while len(frame_buf) > 0:
    cv2.imwrite(f'{folder}/cap_{num}.png', frame_buf.pop(0))
    num += 1

Here's one of the captured images. cap_198

Thanks in advance.

alexjunholee commented 1 year ago

Hi,

As the transformation function of each camera is different, You may convert the values into temperature with our own function.

Please refer to the raw_to_kelvin function in the process_img.py.

def raw_to_kelvin(val):
    return ( 1428.0 / log( 408825.0 / ( val + 58.417 ) + 1.0 ) )

Thanks!

SayedNadim commented 1 year ago

Thank you for answering. I will try and get back to you. Best wishes!

SayedNadim commented 1 year ago

Can you please tell me the meanings of the values used in this equation? I would much appreciate it if you could refer me to some links.

alexjunholee commented 1 year ago

You may refer to the original FLIR camera driver's source code.

SayedNadim commented 1 year ago

Thanks a lot. Closing the issue now.