Taking photo with Thermal Camera

Hi there. Just recently I was able to take photos with my Parrot drone and download them on my computer by connecting to the Drone via WiFi. However, I haven’t been able to use the thermal camera to take the photo instead. I’m not sure if I should be using the thermal message or the camera message since I’ve read the documentation and for me it’s quite confusing still. Here’s the relevant part of the code:

def take_real_photo(drone):
    assert drone.media(
        indexing_state(state="indexed")
    ).wait(_timeout=60).success()
    setup_photo_burst_mode(drone)
    test_real_drone(drone)
    drone.disconnect()


def test_real_drone(drone):
    photo_saved = drone(photo_progress(result="photo_saved", _policy="wait"))
    drone(take_photo(cam_id=0)).wait()
    if not photo_saved.wait(_timeout=30).success():
        assert False, "take_photo timedout"
    photo_progress_info = photo_saved.received_events().last().args
    media_id = photo_progress_info["media_id"]
    photo_count = photo_progress_info["photo_count"]
    drone.media.download_dir = tempfile.mkdtemp(prefix="olympe_photo_example")
    logger.info(
        "Download photo burst resources for media_id: {} in {}".format(
            media_id,
            drone.media.download_dir,
        )
    )
    media_download = drone(download_media(media_id, integrity_check=True))
    resources = media_download.as_completed(expected_count=photo_count, timeout=60)
    resource_count = 0
    for resource in resources:
        logger.info(f"Resource: {resource.resource_id}")
        if not resource.success():
            logger.error(f"Failed to download {resource.resource_id}")
            continue
        resource_count += 1
        with open(resource.download_path, "rb") as image_file:
            image_data = image_file.read()
            image_xmp_start = image_data.find(b"<x:xmpmeta")
            image_xmp_end = image_data.find(b"</x:xmpmeta")
            if image_xmp_start < 0 or image_xmp_end < 0:
                logger.error(f"Failed to find XMP photo metadata {resource.resource_id}")
                continue
            image_xmp = ET.fromstring(image_data[image_xmp_start: image_xmp_end + 12])
            for image_meta in image_xmp[0][0]:
                xmp_tag = re.sub(r"{[^}]*}", "", image_meta.tag)
                xmp_value = image_meta.text
                if xmp_tag in XMP_TAGS_OF_INTEREST:
                    logger.info(f"{resource.resource_id} {xmp_tag} {xmp_value}")
    logger.info(f"{resource_count} media resource downloaded")
    assert resource_count == 14, f"resource count == {resource_count} != 14"
    assert media_download.wait(1.).success(), "Photo burst media download"


def setup_photo_burst_mode(drone):
    drone(set_camera_mode(cam_id=0, value="photo")).wait()
    assert drone(
        set_photo_mode(
            cam_id=0,
            mode="burst",
            format="rectilinear",
            file_format="jpeg",
            burst="burst_14_over_1s",
            bracketing="preset_1ev",
            capture_interval=0.0,
        )
    ).wait().success()

Do I have to figure out the cam_id? I’ve tried and it changes from photo to video camera, but as far as I know my drone has support for thermal photos as I’ve taken some with some phone app.

Is there any answer to this? I’m really lost as I’ve searched on the forum and people seem unable to do this, however, all the posts I’ve seen are trying to stream video, while I just want to take a photo with the thermal camera and get the result downloaded on the Drones server address.

I’m quite lost on how to get some help as I’ve been unable to get a response here.

An update for anyone interested on this.

I’ve been able to take some sort of “Thermal” photo. however, I still know nothing on how to interpret the image I get, since it’s basically a Grayscale image. As far as I’ve worked with Grayscale images you can get temperatures by using some formulas, but those are usually unique to each camera and I’m not sure where to find those values for the Anafi Thermal camera.

Here’s the image I get:

In my case I have to use cam_id=1, since other cameras give even lower quality images or straight up won’t work. Here’s the code I added when setting up the camera:

    drone(set_mode(mode="standard")) # command message olympe.messages.thermal.set_mode(mode, _timeout=10, _no_expect=False, _float_tol=(1e-07, 1e-09))
    # Thermal modes standard, disabled, blended. Should disable camera? cam_id 1 works.
    # No Thermal support for streaming video.
    drone(set_rendering(mode="thermal", blending_rate=0))
    drone(set_palette_settings(mode="relative", lowest_temp=273, highest_temp=314, outside_colorization="limited", 
                               relative_range="unlocked", spot_type="cold", spot_threshold=0))
    drone(set_sensitivity(range="low")) 
    drone(set_emissivity(emissivity=1))
    drone(set_camera_mode(cam_id=1, value="photo")).wait()

Again, I’m really trying out things as I’ve got no help on this so far. If anyone is able to get something different then please reply to this post, I’m sure it would be helpful for a lot of people.

This topic was automatically closed after 30 days. New replies are no longer allowed.