Commit 6909b5e5 authored by Perera P.A.M.M's avatar Perera P.A.M.M

Update main.py

parent f7afcfbd
...@@ -13,7 +13,7 @@ while True: ...@@ -13,7 +13,7 @@ while True:
ret, frame = cap.read() ret, frame = cap.read()
height, width, _ = frame.shape height, width, _ = frame.shape
# Extract Region of interest # Extract Region of interest.
roi = frame[340: 720,500: 800] roi = frame[340: 720,500: 800]
# 1. Object Detection # 1. Object Detection
...@@ -22,7 +22,7 @@ while True: ...@@ -22,7 +22,7 @@ while True:
contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
detections = [] detections = []
for cnt in contours: for cnt in contours:
# Calculate area and remove small elements # Calculate area and remove small elements.
area = cv2.contourArea(cnt) area = cv2.contourArea(cnt)
if area > 100: if area > 100:
#cv2.drawContours(roi, [cnt], -1, (0, 255, 0), 2) #cv2.drawContours(roi, [cnt], -1, (0, 255, 0), 2)
...@@ -31,7 +31,7 @@ while True: ...@@ -31,7 +31,7 @@ while True:
detections.append([x, y, w, h]) detections.append([x, y, w, h])
# 2. Object Tracking # 2. Object Tracking.
boxes_ids = tracker.update(detections) boxes_ids = tracker.update(detections)
for box_id in boxes_ids: for box_id in boxes_ids:
x, y, w, h, id = box_id x, y, w, h, id = box_id
......
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