Metropolis Microservices/RidgeRun Services/PTZ: Difference between revisions

no edit summary
No edit summary
Line 4: Line 4:




PTZ Microservice is a microservice developed by RidgeRun. It allows you to navigate a '''360-degrre''' video through pan, tilt, and zoom (PTZ).
PTZ Microservice is a microservice developed by RidgeRun. It allows you to navigate a '''360-degree''' video through pan, tilt, and zoom (PTZ).


This microservice leverages the RidgeRun [[ Spherical Video PTZ | Spherical Video PTZ ]] to make possible the selection of your region of interest within the sphere.  
This microservice leverages the RidgeRun [[ Spherical Video PTZ | Spherical Video PTZ ]] to make possible the selection of your region of interest within the sphere.  
Line 39: Line 39:
==Running the service==
==Running the service==


PTZ Microservice can run as a standalone application or as docker image. The docker approach has some benefits, for example: since the application is encapsulated along with its dependencies, less conflicts arise in the process of deployment.  
PTZ Microservice can run as a standalone application or as a docker image. The docker approach has some benefits, for example: since the application is encapsulated along with its dependencies, fewer conflicts arise in the deployment.  


===As a docker image===
===As a docker image===


Before starting with docker support make sure you have nvidia runtime in your system. Follow [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuration these instructions] to have docker up and running in your Jetson Board.
Before starting with docker support make sure you have Nvidia runtime in your system. Follow [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuration these instructions] to have docker up and running in your Jetson Board.


====Use prebuild image ====
====Use prebuild image ====
Line 56: Line 56:




====Build your own image (Dockerfile)====
====Build your image (Dockerfile)====


If you instead want to build your own image, a convenient Dockerfile is included as part of the service.  
If you instead want to build your image, a convenient Dockerfile is included as part of the service.  


{{Review|Add link to the repository|mortigoza}}
{{Review|Add link to the repository|mortigoza}}


First, we need to prepare the context directory for this build, please create a directory and include all the needed repositories (listed below). The Dockerfile will look for all the source code in the context directory and copy them to the container.
First, we need to prepare the context directory for this build, please create a directory and include all the necessary repositories (listed below). The Dockerfile will look for all the source code in the context directory and copy them to the container.


<pre>
<pre>
Line 89: Line 89:
====Launch the container====
====Launch the container====


Either if you pulled the prebuilt image or you built your own, a docker container can be launched by running the following command:
Either you pulled the prebuilt image or you built your own, a docker container can be launched by running the following command:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 105: Line 105:
===As a standalone application===
===As a standalone application===


The service can also be run directly into you jetson device.
The service can also be run directly into your jetson device.


Before running the service, you should make sure you have all the dependencies installed. The instructions to do it can be found here: [https://developer.ridgerun.com/wiki/index.php/Spherical_Video_PTZ/User_Guide/Building_and_Installation Spherical Video PTZ Building and Installation] and: [https://developer.ridgerun.com/wiki/index.php/GstRtspSink_-_Building_the_plug-in GstRtspSink plugin]
Before running the service, you should make sure you have all the dependencies installed. The instructions to do it can be found here: [https://developer.ridgerun.com/wiki/index.php/Spherical_Video_PTZ/User_Guide/Building_and_Installation Spherical Video PTZ Building and Installation] and: [https://developer.ridgerun.com/wiki/index.php/GstRtspSink_-_Building_the_plug-in GstRtspSink plugin]
Line 140: Line 140:


#Get an RTSP stream as the input.
#Get an RTSP stream as the input.
#Performs the PTZ in the stream, depending on the user instructions.
#Performs the PTZ in the stream, depending on the user's instructions.
#Returns the stream transformed using the same protocol, RTSP, as the output.  
#Returns the stream transformed using the same protocol, RTSP, as the output.  


Line 151: Line 151:
In the example above we assume the following:
In the example above we assume the following:


* There is an 360-degree RTSP Stream being played in the URI: rtsp://192.168.100.20:4000/sream_in,  
* A 360-degree RTSP Stream is being played in the URI: rtsp://192.168.100.20:4000/sream_in,  
* The PTZ microservice is runnig in: (IP) host=192.168.100.15, port=7000
* The PTZ microservice is running in: (IP) host=192.168.100.15, port=7000


<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Line 162: Line 162:


# Create client (by default will talk to address 127.0.0.1 and port 5020)
# Create client (by default will talk to address 127.0.0.1 and port 5020)
# Change host and port for the IP address and port of the service.
# Change the host and port for the IP address and port of the service.
client = PTZ(host=192.168.100.15, port=7000
client = PTZ(host=192.168.100.15, port=7000


Line 206: Line 206:




First we have to import the required models and modules:
First, we have to import the required models and modules:


<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Line 231: Line 231:
</syntaxhighlight>
</syntaxhighlight>


* in_uri is the URI where the PTZ Microservice is going to "listen" to the incoming RTSP stream.
* in_uri is the URI where the PTZ Microservice will be "listening" to get the incoming RTSP stream.
* out_port is the port where the  PTZ Microservice is going to locate its output (RTSP stream transformed with the PTZ specified), in this case, port 8000
* out_port is the port where the  PTZ Microservice is going to locate its output (RTSP stream transformed with the PTZ specified), in this case, port 8000
* out_mapping is the mapping where the  PTZ Microservice is going to locate its output (RTSP stream transformed with the PTZ specified), in this case, /stream_out
* out_mapping is the mapping where the  PTZ Microservice is going to locate its output (RTSP stream transformed with the PTZ specified), in this case, /stream_out
Line 245: Line 245:




Using the same logic as in the stream. We can send requests to update pan, tilt and zoom, using these commands:  
Using the same logic as in the stream. We can send requests to update pan, tilt, and zoom, using these commands:  
<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
# Perform PTZ
# Perform PTZ
89

edits