@@ -12,6 +12,12 @@ A quick example to get used to setting up detectors and asking good questions: s
12
12
Ensure you have Python 3.7 or higher installed, and then install the Groundlight SDK and OpenCV library:
13
13
14
14
``` bash
15
+ # MacOS
16
+ brew install ffmpeg
17
+
18
+ # Ubuntu/Fedora linux
19
+ sudo apt install -y ffmpeg
20
+
15
21
pip install groundlight pillow ffmpeg yt-dlp typer
16
22
```
17
23
@@ -27,9 +33,15 @@ ffmpeg -i "$(yt-dlp -g $1 | head -n 1)" -vframes 1 last.jpg -y
27
33
28
34
This will download the most recent frame from a YouTube live stream and save it to a local file ` last.jpg ` .
29
35
30
- 2 . Log in to the [ Groundlight application] ( https://app.groundlight.ai ) and get an [ API Token] ( api-tokens ) .
36
+ 2 . Ensure that the script has execute permissions. You can add execute permissions using the following command:
37
+
38
+ ```
39
+ chmod +x get_latest_frame.sh
40
+ ```
41
+
42
+ 3 . Log in to the [ Groundlight application] ( https://app.groundlight.ai ) and get an [ API Token] ( api-tokens ) .
31
43
32
- 3 . Next, we'll write the Python script for the application.
44
+ 4 . Next, we'll write the Python script for the application.
33
45
34
46
``` python notest
35
47
import os
@@ -47,7 +59,7 @@ def main(*, video_id: str = None, detector_name: str = None, query: str = None,
47
59
:param query: Question you want to ask of the stream (we will alert on the answer of NO)
48
60
"""
49
61
gl = Groundlight()
50
- detector = gl.create_detector (name = detector_name, query = query, confidence_threshold = confidence)
62
+ detector = gl.get_or_create_detector (name = detector_name, query = query, confidence_threshold = confidence)
51
63
52
64
while True :
53
65
p = subprocess.run([" ./get_latest_frame.sh" , video_id])
@@ -66,9 +78,9 @@ if __name__ == "__main__":
66
78
67
79
```
68
80
69
- 4 . Save the script as ` streaming_alert.py ` in the same directory as ` get_latest_frame.sh ` above and run it:
81
+ 5 . Save the script as ` streaming_alert.py ` in the same directory as ` get_latest_frame.sh ` above and run it:
70
82
71
83
``` bash
72
- python streaming_alert.py < VIDEO_ID> --detector_name < DETECTOR_NAME> --query < QUERY IN QUOTATION MARKS>
84
+ python streaming_alert.py --video-id= < VIDEO_ID> --detector-name= < DETECTOR_NAME> --query= < QUERY IN QUOTATION MARKS>
73
85
```
74
86
0 commit comments