Skip to content

Commit 3fd745d

Browse files
committed
Added Infra Requirement in README.md
1 parent 38eee6f commit 3fd745d

File tree

2 files changed

+65
-47
lines changed

2 files changed

+65
-47
lines changed

ai_services/vision/python/stream-video/README.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ vision-service python sample for streaming service (detecting object) video usin
22

33
# MAC OS:
44

5-
## 0. Set up
5+
## 0. Setup
66
```
7-
Follow links below to generate a config file and a key pair in your ~/.oci directory
7+
Follow the links below to generate a config file and a key pair in your ~/.oci directory
88
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
99
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm
1010
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm#configfile
@@ -16,18 +16,19 @@ b. A key pair named oci_api_key.pem and oci_api_key_public.pem
1616
1717
Now make sure you change the reference of key file in config file (where key file point to private key:key_file=/YOUR_DIR_TO_KEY_FILE/oci_api_key.pem)
1818
```
19+
1920
## 1. Make sure you are in the root directory of this project:
2021
```
2122
cd ~/stream-video
2223
```
2324

2425
## 2. Upload Public Key
2526
```
26-
# Upload your oci_api_key_public.pem to console:
27+
# Upload your oci_api_key_public.pem to the console:
2728
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three
2829
29-
Just in case you do not have your own config and oci_api_key.pem ready to use, we have
30-
a pair of keys and a config file in /sample_secrets folder, you can use those to run demo code for testing purposes.
30+
If you do not have your own config and oci_api_key.pem ready to use, we have
31+
a pair of keys and a config file in the /sample_secrets folder. You can use those to run the demo code for testing purposes.
3132
```
3233

3334
## 3. Make sure you have python installed on your machine
@@ -39,43 +40,57 @@ And I see following:
3940
Python 3.9.6
4041
'''
4142

42-
## 4. Install all dependencies(include our beta version SDK):
43+
## 4. Install all dependencies (including our beta version SDK):
4344
```
44-
# Make sure you are on either Oracle Corp VPN or OCNA, and have enabled proxy
45+
# Make sure you are on either Oracle Corp VPN or OCNA, and have enabled the proxy
4546
export http_proxy=http://www-proxy-adcq7.us.oracle.com:80;
4647
export https_proxy=http://www-proxy-adcq7.us.oracle.com:80;
4748
export no_proxy=localhost,127.0.0.1,.us.oracle.com,oraclecorp.com;
4849
pip install -r requirements.txt
4950
5051
```
5152

52-
## 5. Stream video python sample scripts usage
53+
## 5. Private Connectivity via Static IP and Port Forwarding
54+
```
55+
Follow these steps to configure secure private connectivity in Oracle Cloud Infrastructure:
56+
57+
### A. Create a Virtual Cloud Network (VCN):
58+
Set up a new VCN with your chosen CIDR block in the appropriate compartment.
59+
60+
### B. Create a Private Subnet:
61+
Add a private subnet within your VCN to isolate internal resources.
62+
63+
### C. Create a NAT Gateway:
64+
Provision a NAT Gateway in the VCN so that private resources can access the internet for updates and patches, while remaining inaccessible from the public internet.
65+
66+
### D. Configure Route Table:
67+
Add a route table entry to direct all outbound internet traffic from the private subnet through the NAT Gateway.
5368
5469
```
55-
usage: stream_video_demo.py [-h] --compartment-id [COMPARTMENT_ID] --subnet-id [SUBNET_ID] --camera-url [CAMERA_URL] --namespace [NAMESPACE] --bucket [BUCKET] --prefix [PREFIX] [-v]
5670

57-
arguments:
58-
-h, --help show this help message and exit
59-
-v, --verbose Print logs
60-
--compartment-id, COMPARTMENT_OCID compartment for the resources
61-
--subnet-id, SUBNET_ID subnet for the private endpoint
62-
--camera-url, CAMERA_URL camera url for the stream
63-
--namespace, NAMESPACE namespace of the Bucket
64-
--bucket, BUCKET_NAME bucket name
6571

66-
optional arguments:
67-
--prefix, PREFIX prefix
72+
## 5. Stream video python sample scripts usage
6873

74+
```
75+
usage: stream_video_demo.py [-h] --compartment-id [COMPARTMENT_ID] --subnet-id [SUBNET_ID] --camera-url [CAMERA_URL] --namespace [NAMESPACE] --bucket [BUCKET] [--prefix PREFIX] [-v]
6976
77+
arguments:
78+
-h, --help Show this help message and exit
79+
-v, --verbose Print logs
80+
--compartment-id COMPARTMENT_OCID Compartment OCID for the resources
81+
--subnet-id SUBNET_ID Subnet for the private endpoint
82+
--camera-url CAMERA_URL Camera URL for the stream
83+
--namespace NAMESPACE Namespace of the bucket
84+
--bucket BUCKET_NAME Bucket name
85+
optional arguments:
86+
--prefix PREFIX Prefix
7087
```
7188

7289
## 6. Some examples commands:
7390
```
74-
python3 stream_video_demo.py --compartment-id "ocid1.compartment.oc1..xxxx" --subnet-id "ocid1.subnet.oc1.iad.xxxxxx" --camera-url "stream_url" --namespace "namespace" --bucket "bucket-name" --prefix "testing"
75-
76-
Above command will create stream source, stream job and stream group, then start and stop stream job and finally delete everything
91+
python3 stream_video_demo.py --compartment-id "ocid1.compartment.oc1.." --subnet-id "ocid1.subnet.oc1.iad." --camera-url ""rtsp://64.181.159.98:443/weapon" --namespace "namespace" --bucket "bucket" --prefix "testing"
7792
93+
The above command will create a stream source, stream job, and stream group, then start and stop the stream job, and finally delete everything.
7894
7995
```
8096

81-
## 7. After running above script, You should see output in json, format is video-file_fps_output-frame-rate_responses.json.

ai_services/vision/python/stream-video/stream_video_demo.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
# Supports Python 3
1414
##########################################################################
1515
# Info:
16-
usage: python3.9 stream_video_demo.py --compartment-id "COMPARTMENT_ID" --camera-url "RTSP_URL" --namespace "NAMESPACE" --bucket "BUCKET_NAME" --prefix "PREFIX"
17-
[-v]
18-
16+
usage: stream_video_demo.py [-h] --compartment-id [COMPARTMENT_ID] --subnet-id [SUBNET_ID] --camera-url [CAMERA_URL] --namespace [NAMESPACE] --bucket [BUCKET] [--prefix PREFIX] [-v]
17+
18+
arguments:
19+
-h, --help Show this help message and exit
20+
-v, --verbose Print logs
21+
--compartment-id COMPARTMENT_OCID Compartment OCID for the resources
22+
--subnet-id SUBNET_ID Subnet for the private endpoint
23+
--camera-url CAMERA_URL Camera URL for the stream
24+
--namespace NAMESPACE Namespace of the bucket
25+
--bucket BUCKET_NAME Bucket name
1926
optional arguments:
20-
-h, --help show this help message and exit
21-
-v, --verbose Print logs
22-
--compartment-id COMPARTMENT_OCID compartment for the resources
23-
--camera-url CAMERA_URL camera url for the stream
24-
--namespace NAMESPACE namespace of the Bucket
25-
--bucket BUCKET_NAME bucket name
26-
--prefix PREFIX prefix
27-
--feature FEATURE feature
28-
27+
--prefix PREFIX Prefix
2928
##################################################################################
3029
"""
3130

@@ -42,7 +41,7 @@
4241

4342
class StreamVideo:
4443
"""
45-
A class to
44+
Class to use all functionalities of Streaming Service
4645
"""
4746

4847
def __init__(self,compartment_id: str,subnet_id: str,camera_url: str, namespace: str,bucket: str,prefix: str, oci_config: dict, service_endpoint: str):
@@ -109,7 +108,7 @@ def create_private_endpoint(self, display_name="Vision_Private_Endpoint"):
109108
if status == 'SUCCEEDED':
110109
return create_private_endpoint_response.data.id
111110
elif status == 'FAILED':
112-
logger.error("creation of private endpoint failed %s",create_private_endpoint_response)
111+
logger.error("creation of private endpoint failed %s",create_private_endpoint_response.headers)
113112
sys.exit()
114113
elif time.time() - start_time > timeout_seconds:
115114
raise TimeoutError("Operation timed out after 5 minutes.")
@@ -156,7 +155,7 @@ def create_Stream_Source(self, vision_private_endpoint_ocid, display_name="Visio
156155
if create_stream_source_work_request.data.status == 'SUCCEEDED':
157156
return create_stream_source_response.data.id
158157
elif create_stream_source_work_request.data.status == 'FAILED':
159-
logger.error("creation of stream source failed %s",create_stream_source_response)
158+
logger.error("creation of stream source failed %s",create_stream_source_response.headers)
160159
sys.exit()
161160
elif time.time() - start_time > timeout_seconds:
162161
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -224,7 +223,7 @@ def create_Stream_Job(self, stream_source_ocid, display_name="Vision_Stream_Job"
224223
if create_stream_job_work_request.data.status == 'SUCCEEDED' :
225224
return create_stream_job_response.data.id
226225
elif create_stream_job_work_request.data.status == 'FAILED':
227-
logger.error("creation of stream job failed %s",create_stream_job_response)
226+
logger.error("creation of stream job failed %s",create_stream_job_response.headers)
228227
sys.exit()
229228
elif time.time() - start_time > timeout_seconds:
230229
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -251,7 +250,7 @@ def create_Stream_Group(self, stream_source_ocid, display_name="Vision_Stream_Gr
251250
if create_stream_group_work_request.data.status == 'SUCCEEDED' :
252251
return create_stream_group_response.data.id
253252
elif create_stream_group_work_request.data.status == 'FAILED':
254-
logger.error("creation of stream job failed %s",create_stream_group_response)
253+
logger.error("creation of stream job failed %s",create_stream_group_response.headers)
255254
sys.exit()
256255
elif time.time() - start_time > timeout_seconds:
257256
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -277,7 +276,7 @@ def start_Stream_Job(self, stream_job_ocid):
277276
if start_stream_job_work_request.data.status == 'SUCCEEDED' :
278277
return stream_job_ocid
279278
elif start_stream_job_work_request.data.status == 'FAILED':
280-
logger.error("starting of stream job failed %s",start_stream_job_response)
279+
logger.error("starting of stream job failed %s",start_stream_job_response.headers)
281280
sys.exit()
282281
elif time.time() - start_time > timeout_seconds:
283282
raise TimeoutError("Operation timed out after 5 minutes.")
@@ -303,7 +302,7 @@ def stop_Stream_Job(self, stream_job_ocid):
303302
if stop_stream_job_work_request.data.status == 'SUCCEEDED' :
304303
return stream_job_ocid
305304
elif stop_stream_job_work_request.data.status == 'FAILED':
306-
logger.error("stopping of stream job failed %s",stop_stream_job_response)
305+
logger.error("stopping of stream job failed %s",stop_stream_job_response.headers)
307306
sys.exit()
308307
elif time.time() - start_time > timeout_seconds:
309308
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -329,7 +328,7 @@ def delete_Stream_Job(self, stream_job_ocid):
329328
if delete_stream_job_work_request.data.status == 'SUCCEEDED' :
330329
return stream_job_ocid
331330
elif delete_stream_job_work_request.data.status == 'FAILED':
332-
logger.error("Deletion of stream job failed %s",delete_stream_job_response)
331+
logger.error("Deletion of stream job failed %s",delete_stream_job_response.headers)
333332
sys.exit()
334333
elif time.time() - start_time > timeout_seconds:
335334
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -354,7 +353,7 @@ def delete_Stream_Group(self, stream_group_ocid):
354353
if delete_stream_group_work_request.data.status == 'SUCCEEDED' :
355354
return stream_group_ocid
356355
elif delete_stream_group_work_request.data.status == 'FAILED':
357-
logger.error("Deletion of stream source failed %s",delete_stream_group_response)
356+
logger.error("Deletion of stream source failed %s",delete_stream_group_response.headers)
358357
sys.exit()
359358
elif time.time() - start_time > timeout_seconds:
360359
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -379,7 +378,7 @@ def delete_Stream_Source(self, stream_source_ocid):
379378
if delete_stream_source_work_request.data.status == 'SUCCEEDED' :
380379
return stream_source_ocid
381380
elif delete_stream_source_work_request.data.status == 'FAILED':
382-
logger.error("Deletion of stream source failed %s",delete_stream_source_response)
381+
logger.error("Deletion of stream source failed %s",delete_stream_source_response.headers)
383382
sys.exit()
384383
elif time.time() - start_time > timeout_seconds:
385384
raise TimeoutError("Operation timed out after 2 minutes.")
@@ -405,7 +404,7 @@ def delete_Vision_Private_Endpoint(self, vision_private_endpoint_ocid):
405404
if delete_vision_private_endpoint_work_request.data.status == 'SUCCEEDED' :
406405
return vision_private_endpoint_ocid
407406
elif delete_vision_private_endpoint_work_request.data.status == 'FAILED':
408-
logger.error("Deletion of stream job failed %s",delete_vision_private_endpoint_work_request)
407+
logger.error("Deletion of stream job failed %s",delete_vision_private_endpoint_work_request.headers)
409408
sys.exit()
410409
elif time.time() - start_time > timeout_seconds:
411410
raise TimeoutError("Operation timed out after 5 minutes.")
@@ -471,13 +470,17 @@ def delete_Vision_Private_Endpoint(self, vision_private_endpoint_ocid):
471470

472471
stream_group_ocid = stream_videos.create_Stream_Group(stream_source_ocid)
473472
logger.info("Stream Group created successfully %s", stream_group_ocid)
474-
473+
475474
start_stream_job = stream_videos.start_Stream_Job(stream_job_ocid)
476475
logger.info("Started Stream Job successfully %s", stream_job_ocid)
477476

477+
time.sleep(60)
478+
478479
stop_stream_job = stream_videos.stop_Stream_Job(stream_job_ocid)
479480
logger.info("Stopped Stream Job successfully %s", stream_job_ocid)
480481

482+
time.sleep(60)
483+
481484
delete_stream_job = stream_videos.delete_Stream_Job(stream_job_ocid)
482485
logger.info("Stream Job deleted successfully %s", stream_job_ocid)
483486

0 commit comments

Comments
 (0)