Exemplo n.º 1
0
def main_flir_image_processor():
    """
    Process an image taken with a Flir One Pro thermal camera.
    The image can be taken either with the official app or a custom app using the Flir's SDK.
    This does not work on videos splitted frame by frame, because the camera doesn't save
    thermal information when recording a video.

    I have left a picture to test out the script.
    """
    input_file = 'test_images/' + 'flir_20190617T163823.jpg'

    fie = FlirImageExtractor()
    fie.process_image(input_file, upsample_thermal=True, transform_rgb=True)

    # fie.plot()

    rgb_image = fie.get_rgb_np()
    rgb_image = cv2.cvtColor(rgb_image, cv2.COLOR_BGR2RGB)
    thermal_image_3d = fie.img_thermal_rgb
    thermal_image_3d = cv2.cvtColor(thermal_image_3d, cv2.COLOR_BGR2RGB)

    # Creating region contours
    image_processor = ImageProcessor(option='dlib_68landmarks')
    image_processor.process_image(rgb_image)

    cv2.imshow("RGB image with contours", rgb_image)
    # cv2.waitKey(0)

    image_processor.apply_saved_contours(thermal_image_3d)

    cv2.imshow("Thermal image with contours", thermal_image_3d)
    cv2.waitKey(0)

    # thermal_image_raw = fie.get_thermal_np()
    # regions = image_processor.all_regions
    # print('Region\tMean T\tStd T')
    #
    # for region in regions:
    #     mean, std = region.get_mean_std_temperature(thermal_image_raw)
    #     print('{}\t{}\t{}'.format(region.name, mean, std))

    # fie.export_thermal_to_csv('thermals_csv/'+file_name+'_thermal_csv.csv')

    fie.save_images()
Exemplo n.º 2
0
                        os.path.join(folder_path, file_name)))
image_names = [img for img in file_names if img.endswith(file_type)]

video_writters = []

# Prepare all video writers
for fps in fps_options:
    video_writters.append(
        cv2.VideoWriter(video_name.format(fps), 0, fps,
                        (output_dim, output_dim)))

for image_name in tqdm(image_names):
    image = cv2.imread(os.path.join(folder_path, image_name))

    try:
        image_processor.process_image(image)
    except NoFaceFoundException:
        continue

    for video_writter in video_writters:
        video_writter.write(image)

for video_writter in video_writters:
    video_writter.release()

cv2.destroyAllWindows()

# Code for displaying a single image
# image_name = "IMG_20190607_020523.jpg"
# image_name = "IMG_20190715_162030.jpg"
# image_name = "IMG_20190706_140033_1.jpg"