Skip to content
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e155871
Review- Removing unused imports
Ihebdhouibi Sep 15, 2024
8e43594
Review- Adding windows timeout mechanism
Ihebdhouibi Sep 15, 2024
04bb477
Review- removing obselete code
Ihebdhouibi Sep 15, 2024
694330d
Review- Encapsulate global variable in a config class
Ihebdhouibi Sep 15, 2024
48a7ecf
Review- fixing typo in ScraperConfig class
Ihebdhouibi Sep 15, 2024
9d03605
Review- fixing typo in timeout cnstr
Ihebdhouibi Sep 15, 2024
31fdb56
Review- Fixing search_download call
Ihebdhouibi Sep 15, 2024
34e6cad
Review- missing parentheses
Ihebdhouibi Sep 15, 2024
173afd2
Review- fixing typo
Ihebdhouibi Sep 15, 2024
2c863d7
Review- search_download call fix
Ihebdhouibi Sep 15, 2024
d948deb
Review- Establishing DB connection using context manager
Ihebdhouibi Sep 15, 2024
704250c
Review- Removing commented lines
Ihebdhouibi Sep 15, 2024
b58e70d
Review- Apply code reusebility to store alerts functions
Ihebdhouibi Sep 15, 2024
f7e3782
Review- Apply code reusebility to retrieving alerts functions
Ihebdhouibi Sep 15, 2024
042b951
Review- Add exception handling
Ihebdhouibi Sep 15, 2024
6289aa9
Review- Add remove_camera function
Ihebdhouibi Sep 15, 2024
5a17c59
Review- Fixing typo
Ihebdhouibi Sep 15, 2024
d628218
Review- Add exception handling
Ihebdhouibi Sep 15, 2024
caebad0
Review- Fixing typo and naming in functions
Ihebdhouibi Sep 15, 2024
8517949
Review- Updating create_azure_container function
Ihebdhouibi Sep 15, 2024
4075fc5
Review- Remove commented lines
Ihebdhouibi Sep 15, 2024
f7893a4
Review- Updating upload_blob function
Ihebdhouibi Sep 15, 2024
244dcb2
Review- removing debbuging and unecessary lines
Ihebdhouibi Sep 15, 2024
aae9185
Review- Removing unecessary prints
Ihebdhouibi Sep 16, 2024
f1e5c12
Review- Removing commented code
Ihebdhouibi Sep 16, 2024
39616c3
Review- Documenting functions
Ihebdhouibi Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions MachineVision/RobberyDetection/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import time
import tensorflow as tf
import numpy as np
import logging
from PIL import Image
from keras.models import load_model
from keras.preprocessing.image import img_to_array
Expand Down Expand Up @@ -143,24 +144,25 @@ def __init__(self, name, **kwargs):
self.RobberyDetector = load_model('/home/iheb/PycharmProjects/Vision-Alarm/MachineVision/RobberyDetection/Robbery_Detection_Model3.h5')

def alarm(self):
print('Robbery Robbery')

logging.debug(f"Robbery detected")
Comment on lines -146 to +55

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using print statements for debugging use logging

self.sendSignal_(name="Robbery_detected")

def cycle_(self):
# print('inside Robbery detection')

if self.client is None:
time.sleep(1.0)
print('client timedout')
logging('client timedout')
else:
index, isize = self.client.pull()
if (index is None):
# print(self.pre, "Client timed out..")
logging(f"{self.pre} Client timed out..")
pass
else:
print("Client index, size =", index, isize)
logging(f"Client index: {index} size: {isize}")
try:
data = self.client.shmem_list[index]
# print(data)

except BaseException:
print("There is an issue in getting data from shmem_list")
try:
Expand All @@ -173,25 +175,24 @@ def cycle_(self):
img_resized = cv2.resize(img, (224, 224))
img = Image.fromarray(img_resized)

print(img_resized.shape)
print(type(img_resized))
print(type(img))
logging(img_resized.shape)

img_array = img_to_array(img=img)
img_array = tf.expand_dims(img_array, 0)

print("img : ",type(img))
print("img_array : ",type(img_array))
# print(img_array)
# try:
# predictions = self.RobberyDetector.predict(img_array)
# print("preds :",predictions)
# score = predictions[0]
# print("this image is %.2f No Robber and %.2f Robbery" %(100 * (1-score), 100 * score))
# except Exception as e:
# print("Unable to predict image class : "+str(e))
# ** frontend methods handling received outgoing signals ***
logging("img : ",type(img))
logging("img_array : ",type(img_array))

try:
predictions = self.RobberyDetector.predict(img_array)
logging("preds :",predictions)
score = predictions[0]
logging("This image is %.2f No Robber and %.2f Robbery" %(100 * (1-score), 100 * score))
except Exception as e:
print(f"Unable to predict image class : {e}")


def Robbery_detected(self):
print("At frontend: Robbery detected ")
logging("At frontend: Robbery detected ")
self.signals.Robbery_detected.emit()