Giter VIP home page Giter VIP logo

siyi_sdk's Introduction

siyi_sdk

Python implementation of SIYI SDK for communication with ZR10 and A8 Mini cameras

If you find this code useful, kindly give a STAR to this repository. Thanks!

Setup

  • Clone this package
    git clone https://github.com/mzahana/siyi_sdk.git
  • Connect the camera to PC or onboard computer using the ethernet cable that comes with it. The current implementation uses UDP communication.
  • Power on the camera
  • Do the PC wired network configuration. Make sure to assign a manual IP address to your computer
    • For example, IP 192.168.144.12
    • Gateway 192.168.144.25
    • Netmask 255.255.255.0
  • Done.

Usage

  • Check the scripts in the siyi_sdk/tests directory to learn how to use the SDK

  • To import this module in your code, copy the siyi_sdk.py siyi_message.py utility.py crc16_python.py scripts in your code directory, and import as follows, and then follow the test examples

    from siyi_sdk import SIYISDK
  • Example: To run the test_gimbal_rotation.py run,

    cd siyi_sdk/tests
    python3 test_gimbal_rotation.py
    
  • Use gui

    python3 gui/tkgui.py

Video Streaming

Requirements

  • OpenCV sudo apt-get install python3-opencv -y

  • imutils pip install imutils

  • Gstreamer https://gstreamer.freedesktop.org/documentation/installing/index.html?gi-language=c

    Ubuntu:

    sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio -y

Examples

  • An example of how to receive image frames from camera, see tests/test_rtsp.py
  • An example of how to stream image frames to an RTMP server, see tests/test_rtmp_stream.py
  • An example of how to receive an image stream from camera using RTSP and send them to an RTMP server, see tests/test_from_rtsp_to_rtmp.py

Tools

  • To run a nginx-rtmp server from a docker container
docker run -d -p 1935:1935 --name nginx-rtmp tiangolo/nginx-rtmp

Reference

  • To play an rtmp stream, you can use the following command in a terminal (you will need to install mpv sudo apt install mpv)
mpv   --msg-color=yes   --msg-module=yes   --keepaspect=yes   --no-correct-pts   --untimed   --vd-lavc-threads=1   --cache=no   --cache-pause=no   --demuxer-lavf-o-add="fflags=+nobuffer+fastseek+flush_packets"   --demuxer-lavf-probe-info=nostreams   --demuxer-lavf-analyzeduration=0.1   --demuxer-max-bytes=500MiB   --demuxer-readahead-secs=0.1     --interpolation=no   --hr-seek-framedrop=no   --video-sync=display-resample   --temporal-dither=yes   --framedrop=decoder+vo     --deband=no   --dither=no     --hwdec=auto-copy   --hwdec-codecs=all     --video-latency-hacks=yes   --profile=low-latency   --linear-downscaling=no   --correct-downscaling=yes   --sigmoid-upscaling=yes   --scale=ewa_hanning   --scale-radius=3.2383154841662362   --cscale=ewa_lanczossoft   --dscale=mitchell     --fs   --osc=no   --osd-duration=450   --border=no   --no-pause   --no-resume-playback   --keep-open=no   --network-timeout=0 --stream-lavf-o=reconnect_streamed=1   rtmp://127.0.0.1/live/webcam

OR you can use VLC, but you may notice high latency!

siyi_sdk's People

Contributors

mzahana avatar tianmingli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

siyi_sdk's Issues

SIYI message self._seq variable does not reset to 0.

SIYI message self._seq variable starts at 0 and increments everytime a request function is used in the SDK. When it hits 65536 it gives this warning:

[SIYISDK::incrementSEQ] : Sequence value is greater than 65535. Resetting to zero

But the variable does not reset to 0 and this warning keeps showing and the request does not complete.

I propose to add this line after line 147 in siyi-message.py: self._seq = 0

1 sec delay in rtsp streaming

Hello,
First of all, Thank you for providing such a helpful API for SIYI Camera.
I am using the SIYI ZR10 camera and connected it to my PC using an Ethernet Cable. I need RTSP streaming so whenever I run test_rtsp.py there is a 1 second delay which is a trouble for me since I need real-time video streaming.

Also when I read the RTSP data using OpenCV I am having the same issue. However, when I connected my system with Skydroid H16 Radio there was only negligible delay in video streaming.

Kindly suggest some improvements.
Regards

Problem with test_gimbal_rotation.py

Hello!
Thank you for sharing this useful repository! but I have a problem with the running test_gimbal_rotation.py.
I used the test_gimbal_rotation.py script to rotate the A8 mini gimbal but every time I set the yaw angles in degrees in this script. It always goes to 103 degrees no matter what number I give it as the yaw angle in the input. I also calibrate the camera but this doesn't work!

Unable to connect to camera with IP and UDP working properly

Hello! I'm trying to implement the SDK with ZR10 and Jetson Nano. But I'm facing an issue while running siyi_sdk.py:

`"/home/mikeainsel/Desktop/Camera control/.venv/bin/python" "/home/mikeainsel/Desktop/Camera control/siyi_sdk/siyi_sdk.py"
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/mikeainsel/Desktop/Camera control/siyi_sdk/siyi_sdk.py", line 224, in recvLoop
self.bufferCallback()
File "/home/mikeainsel/Desktop/Camera control/siyi_sdk/siyi_sdk.py", line 232, in bufferCallback
buff,addr = self._socket.recvfrom(self._BUFF_SIZE)
socket.timeout: timed out
[INFO] 2024-04-14 08:29:23,221 [SIYISDK::disconnect] : Stopping all threads
[ERROR] 2024-04-14 08:29:23,221 [SIYISDK::connect] : Failed to connect to camera
[WARNING] 2024-04-14 08:29:23,589 [SIYISDK::connectionLoop] : Connection checking loop is stopped. Check your connection!'

The camera is connected via Ethernet and I already checked the IP connection with 'ping'
'PING 192.168.144.25 (192.168.144.25) 56(84) bytes of data.
64 bytes from 192.168.144.25: icmp_seq=1 ttl=64 time=0.150 ms
64 bytes from 192.168.144.25: icmp_seq=2 ttl=64 time=0.131 ms
64 bytes from 192.168.144.25: icmp_seq=3 ttl=64 time=0.124 ms'

and 'sudo tcpdump -i any udp port 37260 -vv' (to check UDP connection)
'tcpdump: listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
08:22:01.854222 IP (tos 0x0, ttl 64, id 56187, offset 0, flags [DF], proto UDP (17), length 38)
mikeainsel-desktop.58087 > mikeainsel-desktop.37260: [bad udp cksum 0xa1a7 -> 0x2ea6!] UDP, length 10
08:22:02.976377 IP (tos 0x0, ttl 64, id 56345, offset 0, flags [DF], proto UDP (17), length 38)
mikeainsel-desktop.58087 > mikeainsel-desktop.37260: [bad udp cksum 0xa1a7 -> 0x2ea6!] UDP, length 10
08:22:04.098226 IP (tos 0x0, ttl 64, id 56588, offset 0, flags [DF], proto UDP (17), length 38)
mikeainsel-desktop.58087 > mikeainsel-desktop.37260: [bad udp cksum 0xa1a7 -> 0x2ea6!] UDP, length 10
08:25:59.722293 IP (tos 0x0, ttl 64, id 58143, offset 0, flags [DF], proto UDP (17), length 38)
mikeainsel-desktop.56627 > mikeainsel-desktop.37260: [bad udp cksum 0xa1a7 -> 0x345a!] UDP, length 10
08:26:00.844058 IP (tos 0x0, ttl 64, id 58306, offset 0, flags [DF], proto UDP (17), length 38)
mikeainsel-desktop.56627 > mikeainsel-desktop.37260: [bad udp cksum 0xa1a7 -> 0x345a!] UDP, length 10
'
How can I address this issue?
I'm new to programming, so I'm sorry if this sort of error I'm facing is stupid :)

tkgui.py generates error

Exception in thread Thread-1 (recvLoop):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/mnt/c/Users/bura7/Desktop/SAVX/Dron_buyuk/SDK/siyi_sdk-main/siyi_sdk.py", line 224, in recvLoop
self.bufferCallback()
File "/mnt/c/Users/bura7/Desktop/SAVX/Dron_buyuk/SDK/siyi_sdk-main/siyi_sdk.py", line 232, in bufferCallback
buff,addr = self._socket.recvfrom(self._BUFF_SIZE)
TimeoutError: timed out
[INFO] 2024-03-20 09:43:00,573 [SIYISDK::disconnect] : Stopping all threads
[ERROR] 2024-03-20 09:43:00,574 [SIYISDK::connect] : Failed to connect to camera
No connection
[WARNING] 2024-03-20 09:43:00,904 [SIYISDK::connectionLoop] : Connection checking loop is stopped. Check your connection!

I get this error when I try to operate the gui by using the python3 gui/tkgui.py command. Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.