-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-detection.py
29 lines (24 loc) · 956 Bytes
/
my-detection.py
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
#!/usr/bin/python3
import jetson.inference
import jetson.utils
import boto3
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson.utils.videoSource("csi://0") # '/dev/video0' for V4L2
display = jetson.utils.videoOutput("display://0") # 'my_video.mp4' for file
# Create an SNS client
sns = boto3.client('sns',region_name='us-west-2')
while display.IsStreaming():
img = camera.Capture()
detections = net.Detect(img)
for detection in detections:
#print(detection.ClassID, detection.Confidence)
if ((detection.ClassID==1) & (detection.Confidence>=0.90)):
# Publish a simple message to the specified SNS topic
response = sns.publish(
TopicArn='arn:aws:sns:us-west-2:876612415673:xavier_securitycam',
Message='Confidence: '+str(detection.Confidence),
)
print(response)
break
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))