Commit 35a31f0d authored by Pramodya Hettiarachchi's avatar Pramodya Hettiarachchi

Merge branch 'it18006308_pramodya' into 'master'

in proximity kettle part done

See merge request !19
parents 6839e1bf 94ac09c1
......@@ -7,6 +7,7 @@ import pickle
import time
import cv2
import sys
from shapely.geometry import box
THRESHOLD_ITEM = 0.5
THRESHOLD_PERSON = 0.5
......@@ -46,4 +47,58 @@ def forFrame(frame_number, output_array, outpun_count, returned_frame):
if len(persons) > 1:
print("Person in room")
# Test commit
if len(persons >= 1):
for person in persons:
# Create person with minX, minY maxX, maxY
person_box = box(person[0], person[3], person[1], person[2])
x1 = person[0]
x2 = person[1]
y1 = person[2]
y2 = person[3]
# x_center = (x1+x2)/2
person_midpoint = ((x1+x2)/2, (y1+y2)/2) # X and Y coordinates
if kettle_count > 0:
# Loop each kettle
for kettle in kettles:
kettle_box = box(kettle[0]+50, kettle[3]+50, kettle[1]+50, kettle[2]+50)
# Check weather child is in proximity to the kettle
k_x1 = kettle[0] + 50 # Left
k_x2 = kettle[1] + 50 # Right
k_y1 = kettle[2] + 50 # Top
k_y2 = kettle[3] + 50 # Bottom
overlap = False
if kettle_box.intersection(person_box) != None:
print("Kettle - Person is in the Kettles Danger Region")
overlap = True
if x1 >= k_x1 & x1 <= k_x2:
print("Kettle - X1 is inside the Persons Danger region!")
overlap = True
if x2 >= k_x1 & x2 <= k_x2:
print("Kettle - X2 is inside the Persons Danger region!")
overlap = True
if y1 >= k_y2 & y1 <= k_y1:
print("Kettle - Y1 is inside the Persons Danger region!")
overlap = True
if y2 >= k_y2 & y2 <= k_y2:
print("Kettle - Y2 is inside the Persons Danger region!")
overlap = True
# If kettle and child bounding bor overlap, Calculate Distance between center point of two boxes
if(overlap == True):
kettle_midpoint = ((k_x1+k_x2)/2, (k_y1+k_y2)/2)
distance = ((((kettle_midpoint[0] - person_midpoint[0])**2) + ((kettle_midpoint[1]
- person_midpoint[1])**2) )**0.5)
else:
print("No Kettles Found")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment