Commit f900e5fe authored by Odhara Kodikara's avatar Odhara Kodikara

Merge branch 'master' of http://gitlab.sliit.lk/2021-115/2021-115 into it18110708_kodikara

 Conflicts:
	.idea/workspace.xml
parents cfabc76c 0f324cce
# IT18006308
# Import Libraries
from imageai.Detection import ObjectDetection, VideoObjectDetection
import os
import pickle
import time
import cv2
import sys
THRESHOLD_ITEM = 0.5
THRESHOLD_PERSON = 0.5
print("Test 1 : Hot Object Detection Start")
detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("../model/yolo.h5")
detector.loadModel()
def forFrame(frame_number, output_array, outpun_count, returned_frame):
kettle_count = 0
kettles = []
person_count = 0
persons = []
for detection in output_array:
print(str(detection['name']) + " - " + str(detection['percentage_probability']) + " - " + str(
detection['box_point']))
if detection['name'] == 'kettle' and detection['percentage_probability'] >= THRESHOLD_ITEM:
kettle_count = kettle_count + 1
kettles.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection['box_point'])
if detection['name'] == 'person' and detection['percentage_probability'] >= THRESHOLD_PERSON:
person_count = person_count + 1
persons.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection['box_point'])
# Check the person is in room
if len(persons) == 0:
print("Person is not in room")
if len(persons) > 1:
print("Person in room")
# IT18006308
# Import Libraries
from imageai.Detection import ObjectDetection
from imageai.Detection import ObjectDetection, VideoObjectDetection
from imageai.Detection.Custom import CustomObjectDetection
import os
import pickle
import time
......@@ -9,35 +11,68 @@ import cv2
import sys
THRESHOLD_ITEM = 0.5
THRESHOLD_PERSON = 0.5
print("Test 1 : Sharp Object Detection Start")
detector = ObjectDetection()
detector2 = ObjectDetection()
# detector = ObjectDetection()
detector = VideoObjectDetection()
detector2 = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("model/yolo.h5")
detector.setModelPath("../model/yolo.h5")
detector.loadModel()
detection1 = detector.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
# detection1 = detector.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
detector2.setModelTypeAsRetinaNet()
detector2.setModelPath("model/resnet50_coco_best_v2.1.0.h5")
detector2.loadModel()
detection2 = detector2.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
scissors_count = 0
scissors = []
# detection2 = detector2.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
def forFrame(frame_number, output_array, outpun_count, returned_frame):
scissors_count = 0
scissors = []
knife_count = 0
knife = []
fork_count = 0
fork = []
person_count = 0
person = []
print(frame_number)
# YOLOv3 Model (person and scissors)
for detection in output_array:
print(str(detection['name']) + " - " + str(detection['percentage_probability']) + " - " + str(
detection['box_point']))
# identify Scissors
if detection['name'] == 'scissors' and detection['percentage_probability'] >= THRESHOLD_ITEM:
scissors_count = scissors_count + 1
scissors.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection['box_point'])
if detection['name'] == 'person' and detection['percentage_probability'] >= THRESHOLD_PERSON:
person_count = person_count + 1
person.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection['box_point'])
# RetinaNet Model
if detection['name'] == 'knife' and detection['percentage probability'] >= THRESHOLD_ITEM:
knife_count = knife_count + 1
knife.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_point"])
print(detection1)
if detection['name'] == 'fork' and detection['percentage_probability'] >= THRESHOLD_ITEM:
fork_count = fork_count + 1
fork.append(detection['box_point'])
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_point"])
# YOLOv3 Model
for detection in detection1:
print(str(detection['name']) + " - " + str(detection['precentage_probability']) + " - " + str(
detection['box_point']))
# Check the person is in room
if len(person) == 0:
print("Person is not in room")
# identify Scissors
if(detection['name'] == 'scissors' and detection['precentage_probability'] >= THRESHOLD_ITEM):
scissors_count = scissors_count + 1
scissors.append(detection['box_point'])
print(detection["name"], " : ", detection["precentage_probability"], " : ", detection['box_point'])
if len(person) > 1:
print("Person in room")
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