Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: siyi image and video download script #27947

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented Aug 28, 2024

This adds a python script to the Tools/camera_gimbals directory that makes it easy to download images and videos from Siyi camera gimbals.

I'm not a python expert so all suggestions for improvements are very welcome. ChatGPT has given me a fairly long list of things that could be improved so if people like I could try and improve it further.

This has been tested on a Siyi ZT6 and some sample output is shown below

python siyi-download.py --ipaddr 192.168.87.81 --dest images3
siyi-download.py: downloading image files
siyi-download.py: 1 directories
siyi-download.py: 13 files
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0001.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0002.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0003.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0004.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0005.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0006.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0007.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0008.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0009.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0010.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0011.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0012.jpg
siyi-download.py: downloading: http://192.168.87.81:82/photo/101SIYI_IMG/IMG_0013.jpg
siyi-download.py: downloading video files
siyi-download.py: 1 directories
siyi-download.py: 1 files
siyi-download.py: downloading: http://192.168.87.81:82/mp4/100SIYI_VID/Rec_0001.mp4

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Randy! I added a few non-functional suggestions on the python code, mostly for readability. Feel free to accept/dismiss any as they have likely won't impact functionality.

As far as building the URL's, consider using urllib's built in support for parameters, which can replace the call

return "http://" + ip_address + ":82/cgi-bin/media.cgi/api/v1/getdirectories?media_type=" + str(media_type)

With something like:

params = {"media_type": str(media_type)}
f"http://{ip_address}:82/cgi-bin/media.cgi/api/v1/getdirectories?" + urllib.parse.urlencode(params)

Reference:
https://stackoverflow.com/a/15799706/11032285

Or, you can even use the urlparse library.

String concatenation works totally fine too!

Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
Tools/cameras_gimbals/siyi-download/siyi-download.py Outdated Show resolved Hide resolved
@rmackay9
Copy link
Contributor Author

Hi @Ryanf55, thanks very much for that, I'll make those changes!

@rmackay9
Copy link
Contributor Author

Besides the changes requested by Ryan, I've also added a bit more error checking so I think this is ready to be merged to master.

I have also discovered that there's an issue on the Siyi side in that we can't download the raw thermal images but I've raised this with Siyi and hopefully they will resolve this

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really only care about the AP_FLAKE8_CLEAN change.

@tridge tridge merged commit 4bcb395 into ArduPilot:master Sep 3, 2024
93 checks passed
@rmackay9 rmackay9 deleted the siyi-download-files branch September 3, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants