File size: 1,394 Bytes
01e1043
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Stream pedestrian detection web server

### Requirements

- python = 3.7
- redis
- flask
- opencv
- pytorch
- dotenv

Please note that you need to install redis on your system.

### The architecture.

![web server architecture](images/arc.png)

1 - `RealTimeTracking` reads frames from rtsp link using threads 
(Using threads make the web server robust against network packet loss) 

2 - In `RealTimeTracking.run` function in each iteration frame is stored in redis cache on server.

3 - Now we can serve the frames on redis to clients.

4 - To start the pedestrian detection, after running 
`rtsp_webserver.py`, send a GET request on `127.0.0.1:8888/run`
with setting these GET method parameters

| Param | Value | Description |
| :-------------: | :-------------: | :-------------: |
| run  | 1/0  |  to start the tracking set 1/ to stop tracking service set it as 0|
| camera_stream  | 'rtsp://ip:port/admin...'  | provide it with valid rtsp link |

for example:

    (to start the service)  127.0.0.1:8888/run?run=1
    (to stop the service)  127.0.0.1:8888/run?run=0
    (to change the camera) 
        1- 127.0.0.1:8888/run?run=0 (first stop the current service)
        2- 127.0.0.1:8888/run?run=0&camera_stream=rtsp://ip:port/admin... (then start it with another rtsp link)
    
![web server architecture](images/request.png)


5 - get pedestrian detection stream in `127.0.0.1:8888`