Skip to content

Commit 6d46b43

Browse files
Filipgitbook-bot
authored andcommitted
GITBOOK-35: No subject
1 parent 742644a commit 6d46b43

5 files changed

Lines changed: 57 additions & 5 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# API Reference
1+
# REST API Reference
22

3+
This is the reference for the REST API part of Robopipe API. To try out particular endpoints, simply navigate to the appropriate endpoint and click on the "**Test it**" button. All endpoints have included the request and response body schema, along with the restrictions for particular attributes. When running the API, you can also open your locally running docs on [https://robopipe-1.local/docs](https://robopipe-1.local/docs) (Swagger UI). The OpenAPI specification can be downloaded from your server (controller) at [https://robopipe-1.local/openapi.json](https://robopipe-1.local/openapi.json) or below.

docs/api/rest-api-reference/streams.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Streams
22

3-
Each camera contains a number of sensors of different types. Our API currently supports manipulation of color and monochromatic image sensors. Each sensor produces image data in various formats and is configurable independently of other sensor on the same device. Sensors are addressed by their socket name which is in the format [_CAM\_(A-H)_](#user-content-fn-1)[^1]_._
3+
Each camera contains a number of sensors of different types. Each sensor (or combination of multiple sensors) provides an image **stream** which can be consumed directly as video stream, or fed as input into a neural network. Our API exposes operations through which these **streams** can be consumed or manipulated. Each stream is addresses either by its sensor name - CAM\_(A-H)[^1] or by its combined name - DEPTH\_(A-H)\_(A-H)[^2]_._
4+
5+
## Depth API
6+
7+
Some camera models containing multiple image sensors, support a feature called _Stereo Depth_. This feature combines data from two image sensors at a time, to calculate the depth of the image in front of it. The result is a single image stream. The image will consist of depth data calculated by the camera, lighter areas will contain objects that are closer to the camera while darker areas will contain objects further away. This stream is configurable the same way as a single sensor.
8+
9+
{% hint style="info" %}
10+
Depth stream and the respective sensors it uses cannot be both active at the same time. E.g. if stream DEPTH\_B\_C is active, then streams CAM\_B and CAM\_C will be inactive and vice versa.
11+
{% endhint %}
412

513
## API Reference
614

@@ -40,4 +48,6 @@ Each camera contains a number of sensors of different types. Our API currently s
4048

4149
available sensor, with names CAM\_A,
4250

43-
CAM\_B, CAM\_C, etc.
51+
CAM\_B, CAM\_C, ... depending on you camera model.
52+
53+
[^2]: The first and second capital letters A-H in the stream name correspond to the left and right image sensor respectively.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# WebSocket API Reference
22

3+
Along with the REST API, Robopipe API also exposes some WebSocket endpoints for cosuming live data. Particularly video streams and neural network detections. You can find the specifications at their respective pages below.

docs/api/websocket-api-reference/nn-inference.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Running inference
44

5-
The neural network starts at the point it is uploaded to the camera. The output from the model can be read by subscribing to a websocket endpoint `ws://host:port/cameras/{mxid}/sensors/{sensor_name}/nn`. The outputted data will be a json in the format:
5+
The neural network starts at the point it is uploaded to the camera. The output from the model can be read by subscribing to a websocket endpoint `ws://host:port/cameras/{mxid}/streams/{sensor_name}/nn`. The outputted data will be a json in the format:
66

77
```json
88
{
@@ -11,3 +11,43 @@ The neural network starts at the point it is uploaded to the camera. The output
1111
```
1212

1313
where detections will contain whetever you is your model's output.
14+
15+
## Output format
16+
17+
The data format received from the websocket endpoint depends on the type of neural network you have running on the camera.
18+
19+
### Generic neural network
20+
21+
In case you used a generic neural network, the output data will be a one dimensional array containing raw data from the last layer of the neural network.
22+
23+
```json
24+
{
25+
"detections": [
26+
0.3,
27+
0.02,
28+
0.05,
29+
...
30+
]
31+
}
32+
```
33+
34+
### YOLO & MobilenetSSD
35+
36+
In case you have chosen either a YOLO or MobilenetSSD model, the output format will be an array containing detection objects. Each detection object contains:
37+
38+
* label - number indicating the label it detected
39+
* confidence - float in the range \[0, 1] indicating the confidence level of the detection
40+
* coords - four element tuple, containing the coordinates of the detection in the image \[x\_min, y\_min, x\_max, y\_max]
41+
42+
```json
43+
{
44+
"detections": [
45+
{"label": 0, "confidence": 0.765, "coords": [0.5, 0.1, 0.6, 0.23]},
46+
...
47+
]
48+
}
49+
```
50+
51+
#### Depth
52+
53+
In case a depth stream is active and running at the same time a neural network is deployed, each detection object will also contain information regarding its depth position.

docs/api/websocket-api-reference/stream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Each sensor provides its own video stream. If there are no subscribers, no data
66

77
### Receiving segments
88

9-
The data obtained via websockets is MP4 fragments encoded using H.264 codec. To start receiving data, simply open a websocket at `ws://host:port/camera/MXID/sensors/SENSOR_NAME/video`.
9+
The data obtained via websockets is MP4 fragments encoded using H.264 codec. To start receiving data, simply open a websocket at `ws://host:port/camera/MXID/streams/SENSOR_NAME/video`.
1010

1111
### Playing the video
1212

0 commit comments

Comments
 (0)