diff --git a/core.py b/core.py index 1bf912b..6d2aa5b 100755 --- a/core.py +++ b/core.py @@ -100,27 +100,23 @@ class Core(QThread): if frame_1 is not None: self.__rtspserver_1.update_frame(frame_1) - sleep(0.03) + sleep(1/25) except Exception as e: print(e) sleep(0.1) - - except Exception as e: - print(e) - sleep(0.1) - def __detection(self): while self.__is_detecting: try: - torch.cuda.empty_cache() + torch.cuda.set_per_process_memory_fraction() source = self.__processing_source roi = self.__detection_roi frame = source.get_frame() cropped_frame = frame[roi[1]:roi[3], roi[0]:roi[2]] - results = self.__detector.predict(cropped_frame) + with torch.no_grad(): + results = self.__detector.predict(cropped_frame) global_bboxes = list() for result in results: cls = result[0] @@ -136,8 +132,11 @@ class Core(QThread): print(e) sleep(0.1) + def __tracking(self): source = self.__processing_source + track_color = (0, 255, 0) #green + lost_color = (255, 0, 0) #blue if showTrack: pygame.init() @@ -167,8 +166,8 @@ class Core(QThread): if frame is not None: if self.__is_tracking and self.__tracker is not None and self.__tracker_roi is not None : x, y, w, h = map(int, self.__tracker_roi) - box_color = (0, 255, 255) if self.__tracker__succ else (255, 0, 0) - cv2.rectangle(frame, (x, y), (x + w, y + h), box_color, 2) + box_color = track_color if self.__tracker__succ else lost_color + cv2.rectangle(frame, (x, y), (x + w, y + h), box_color, self.__thickness) if self.__processing_id == 1: self.__rtspserver_1.update_frame(frame)