Problems running photo sample on Sphinx

I already reported here a problem with a remote Sphinx instance (see last post). These warnings are still there.

Today I tried to get familiar with taking photos and tried this sample olympe/src/olympe/doc/examples/photo.py at 324a4b2744f6f024a2f0a3dfab2ddddb58b4566c · Parrot-Developers/olympe · GitHub by changing the drone IP to the IP of my Sphinx instance.

The problem with the missing or failing index manifests again. The assertion fails after a 60 s timeout:

(olympe-python3) pi@raspberrypi:~/vxparrot $ python test.py
2022-06-27 11:06:17,115 [INFO]  olympe.backend - _create_pomp_loop - Creating pomp loop
2022-06-27 11:06:17,120 [INFO]  olympe.backend - _do_create - device callbacks have been added to arsdk_ctrl
2022-06-27 11:06:17,122 [INFO]  olympe.scheduler - _create_pomp_loop - Creating pomp loop
2022-06-27 11:06:17,142 [INFO]  olympe.media - _create_pomp_loop - Creating pomp loop
2022-06-27 11:06:17,151 [INFO]  olympe.backend - _device_added_cb - DiscoveryNet: New device has been detected: 'ANAFI-0000000'
2022-06-27 11:06:17,156 [INFO]  olympe.drone - _connecting_cb - Connecting to device: ANAFI-0000000
2022-06-27 11:06:17,157 [INFO]  olympe.drone - _connect_impl - Connection in progress...
2022-06-27 11:06:17,160 [INFO]  olympe.drone.ANAFI-0000000 - _connected_cb - Connected to device: ANAFI-0000000
2022-06-27 11:06:17,161 [INFO]  olympe.drone.ANAFI-0000000 - _connected_cb - {'c2d_port': 2233,
 'c2d_update_port': 51,
 'c2d_user_port': 21,
 'proto_v': 3,
 'qos_mode': 0,
 'status': 0}
2022-06-27 11:06:17,163 [INFO]  olympe.drone.ANAFI-0000000 - _create_command_interface - Command interface has been created
2022-06-27 11:06:17,169 [INFO]  olympe.drone.ANAFI-0000000 - _send_command_impl - common.Common.CurrentDateTime(datetime='20220627T110617+0200') has been sent to the device
2022-06-27 11:06:17,182 [INFO]  olympe.drone.ANAFI-0000000 - _send_command_impl - common.Common.AllStates() has been sent to the device
2022-06-27 11:06:17,188 [INFO]  olympe.drone.ANAFI-0000000 - _recv_cmd_cb - common.CommonState.CurrentDateTimeChanged(datetime='20220627T110617+0200')
2022-06-27 11:06:17,193 [INFO]  olympe.drone.ANAFI-0000000 - _on_sync_done - Synchronization of b'192.168.188.118' at 20220627T110617+0200
2022-06-27 11:06:17,205 [WARNING]       olympe.media - _get_all_media - HTTP 541: http://192.168.188.118:80/api/v1/media/medias b'Media Not Yet Indexed'

---shortened---


2022-06-27 11:07:18,040 [INFO]  olympe.drone.ANAFI-0000000 - _disconnection_impl - disconnected from device: b'192.168.188.118'
2022-06-27 11:07:18,049 [INFO]  olympe.drone.ANAFI-0000000 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7f7ce884f0>
2022-06-27 11:07:18,061 [INFO]  olympe.drone.ANAFI-0000000 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7f7aa65ee0>
2022-06-27 11:07:18,065 [INFO]  olympe.media - _websocket_event_reader - websocket closed
2022-06-27 11:07:18,076 [INFO]  olympe.scheduler - _destroy_pomp_loop - Pomp loop has been destroyed: subscribers_thread
2022-06-27 11:07:18,284 [INFO]  olympe.backend - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-1
Traceback (most recent call last):
  File "/home/pi/vxparrot/test.py", line 125, in <module>
    test_photo()
  File "/home/pi/vxparrot/test.py", line 121, in test_photo
    main(drone)
  File "/home/pi/vxparrot/test.py", line 111, in main
    assert drone.media(
AssertionError
2022-06-27 11:07:18,377 [INFO]  olympe.media - _shutdown - olympe.media shutdown
2022-06-27 11:07:19,076 [INFO]  olympe.media - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-2
(olympe-python3) pi@raspberrypi:~/vxparrot $ 

What can I do against this?

1 Like

This is a warning/error I’m seeing all the time at startup:

2022-06-27 11:06:17,188 [INFO]  olympe.drone.ANAFI-0000000 - _recv_cmd_cb - common.CommonState.CurrentDateTimeChanged(datetime='20220627T110617+0200')
2022-06-27 11:06:17,193 [INFO]  olympe.drone.ANAFI-0000000 - _on_sync_done - Synchronization of b'192.168.188.118' at 20220627T110617+0200
2022-06-27 11:06:17,205 [WARNING]       olympe.media - _get_all_media - HTTP 541: http://192.168.188.118:80/api/v1/media/medias b'Media Not Yet Indexed'
2022-06-27 11:06:17,320 [INFO]  olympe.drone.ANAFI-0000000 - _recv_cmd_cb - common.CommonState.BatteryStateChanged(percent=61)
2022-06-27 11:06:17,358 [INFO]  olympe.drone.ANAFI-0000000 - _recv_cmd_cb - common.ARLibsVersionsState.DeviceLibARCommandsVersion(version='4.0.0.4')

and

022-06-27 11:20:11,856 [ERROR] 	olympe.media - _get_all_media - The webserver is unavailable
2022-06-27 11:20:11,856 [WARNING] 	olympe.media - aconnect - Media are not yet indexed

The script shows the same problems if run directly on simulator

Could somebody of the knowing please try to answer/comment?

TIA

I’m not even able to make a photo, neither on simulator, nor on Anafi.

This is the code:

# Setup
self.drone(camera.set_camera_mode(cam_id=0, value='photo')).wait()

self.drone(camera.set_photo_mode(
                cam_id=0,
                mode='single',
                format='full_frame',
                file_format='jpeg',
                burst='burst_4_over_1s',
                bracketing='preset_1ev',
                capture_interval=0
)).wait()

Shoot:

        self.logger.info("taking photo")
        photo_saved = self.drone(camera.photo_progress(result="photo_saved", _policy="wait"))
        self.drone(camera.take_photo(cam_id=0)).wait()
        if not photo_saved.wait(_timeout=30).success():
            assert False, "take_photo timedout"

It always runs into timeout when trying to make the photo. On simulator the mode change between video and photo is visible in the front camera simulation (different FOV)

I was using your sample code for this. What am I making wrong here?

Having now tested the sample provided here Get real-time photos from the Anafi in sphinx - #2 by ndessart

It is a bit outdated, but I could make it work against a real drone.

Running this script either remotely against or locally on the simulator does not work and shows the same error symptoms:

The script (when run on simulator):


from olympe.messages.camera import (
    set_camera_mode,
    set_photo_mode,
    take_photo,
    photo_progress,
)
import olympe
import os
import re
import requests
import shutil
import tempfile
import xml.etree.ElementTree as ET


# Drone IP
ANAFI_IP = "10.202.0.1"

# Drone web server URL
ANAFI_URL = "http://{}/".format(ANAFI_IP)

# Drone media web API URL
ANAFI_MEDIA_API_URL = ANAFI_URL + "api/v1/media/medias/"

XMP_TAGS_OF_INTEREST = (
    "CameraRollDegree",
    "CameraPitchDegree",
    "CameraYawDegree",
    "CaptureTsUs",
    # NOTE: GPS metadata is only present if the drone has a GPS fix
    # (i.e. they won't be present indoor)
    "GPSLatitude",
    "GPSLongitude",
    "GPSAltitude",
)


def take_photo_burst(drone):
    # take a photo burst and get the associated media_id
    photo_saved = drone(photo_progress(result="photo_saved", _policy="wait"))
    drone(take_photo(cam_id=0)).wait()
    photo_saved.wait()
    media_id = photo_saved.received_events().last().args["media_id"]

    # download the photos associated with this media id
    media_info_response = requests.get(ANAFI_MEDIA_API_URL + media_id)
    media_info_response.raise_for_status()
    download_dir = tempfile.mkdtemp()
    for resource in media_info_response.json()["resources"]:
        image_response = requests.get(ANAFI_URL + resource["url"], stream=True)
        download_path = os.path.join(download_dir, resource["resource_id"])
        image_response.raise_for_status()
        with open(download_path, "wb") as image_file:
            shutil.copyfileobj(image_response.raw, image_file)

        # parse the xmp metadata
        with open(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")
            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
                # only print the XMP tags we are interested in
                if xmp_tag in XMP_TAGS_OF_INTEREST:
                    print(resource["resource_id"], xmp_tag, xmp_value)


def setup_photo_burst_mode(drone):
    drone(set_camera_mode(cam_id=0, value="photo")).wait()
    # For the file_format: jpeg is the only available option
    # dng is not supported in burst mode
    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()


def main(drone):
    drone.connect()
    setup_photo_burst_mode(drone)
    take_photo_burst(drone)


if __name__ == "__main__":
    with olympe.Drone(ANAFI_IP) as drone:
        main(drone)

The log (script does not end):

2022-06-29 15:21:19,202 [WARNING]       olympe.media - _get_all_media - HTTP 541: http://10.202.0.1:80/api/v1/media/medias b'Media Not Yet Indexed'
2022-06-29 15:21:21,203 [ERROR]         olympe.media - _get_all_media - The webserver is unavailable
2022-06-29 15:21:21,203 [WARNING]       olympe.media - aconnect - Media are not yet indexed

Even with curl the problem is persistent:

(olympe-python3) ubuntu@simulator:~/code/parrot-groundsdk$ curl http://10.202.0.1/api/v1/media/medias -v
*   Trying 10.202.0.1:80...
* TCP_NODELAY set
* Connected to 10.202.0.1 (10.202.0.1) port 80 (#0)
> GET /api/v1/media/medias HTTP/1.1
> Host: 10.202.0.1
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 541 Media Not Yet Indexed
< Connection: close
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< 
* Closing connection 0
(olympe-python3) ubuntu@simulator:~/code/parrot-groundsdk$ 

Related, unanswered as well…

https://forum.developer.parrot.com/t/media-not-yet-indexed/15882

Also related and gracefully ignored:

https://forum.developer.parrot.com/t/unable-to-connect-to-drone-with-olympe-media-class/15577

1 Like

At least some hints here:

Seems, photo is a bit “underexposed” in simulator…

1 Like

Hi. The example in the code does have some problems, however, I took photos in a different way. You can use the following command to extract a photo sphinx-cli camera front_streaming -n --count=1 -o . (details can be found here Record and visualize cameras - 2.8.2 ). If you want to call this command with code, you can try the OS library. Hope to help you.

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