Detector/DetectorWraper.py
def visualize_detection(self, image):
		"""
		Return a image with visualized locations detected
		"""
		H, W, _ = image.shape
		pos_list = self.apply_detection(image)
		detections = {}
		hasDetection = False
		for i, L in enumerate(pos_list):
			text, coordinates = L[0], L[1]
			COLOR = COLORS[text]
			for x, y, w, h in coordinates:
				# prune bad homography points
				if x < 0 or y < 0 or x + w > W or \
				   y + h > H or w <= 1 or h <= 1:
					continue
				# add the detection to the dict for tracking
				detections[self.num_detect] = (x, y, w, h)
				self.detection_index[self.num_detect] = (x, y, w, h, self.num_save, text)
				self.num_detect += 1
				hasDetection = True
				# if the detection is human
				if text == 'face':
					gender = self.genderDetect.classify(image[y:y+h, x:x+w, :])
					gender = 'female' if gender[0] < 0.5 else 'male'
					cv2.putText(image, gender, (x + w // 2 -10, y + h + 15),
						cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR, 2, cv2.LINE_AA)

				image = cv2.rectangle(image, (x, y), (x + w, y + h), COLOR, 2)
				cv2.putText(image, text, (x, y - 5),
					cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR, 2, cv2.LINE_AA)
		if hasDetection:
			self.detection_frames[self.num_save] = detections
		self.num_save +=1
		return image

		Return a image with visualized locations detected
		
Return a image with visualized locations detected
Return a image with visualized locations detected
def visualize_detection(self, image):
		H, W, _ = image.shape
		pos_list = self.apply_detection(image)
		detections = {}
		hasDetection = False
		for i, L in enumerate(pos_list):
			text, coordinates = L[0], L[1]
			COLOR = COLORS[text]
			for x, y, w, h in coordinates:
				if x < 0 or y < 0 or x + w > W or \
				   y + h > H or w <= 1 or h <= 1:
					continue
				detections[self.num_detect] = (x, y, w, h)
				self.detection_index[self.num_detect] = (x, y, w, h, self.num_save, text)
				self.num_detect += 1
				hasDetection = True
				if text == 'face':
					gender = self.genderDetect.classify(image[y:y+h, x:x+w, :])
					gender = 'female' if gender[0] < 0.5 else 'male'
					cv2.putText(image, gender, (x + w // 2 -10, y + h + 15),
						cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR, 2, cv2.LINE_AA)
				image = cv2.rectangle(image, (x, y), (x + w, y + h), COLOR, 2)
				cv2.putText(image, text, (x, y - 5),
					cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR, 2, cv2.LINE_AA)
		if hasDetection:
			self.detection_frames[self.num_save] = detections
		self.num_save +=1
		return image
def visualize_detection ( self , image ) : H , W , _ = image . shape pos_list = self . apply_detection ( image ) detections = { } hasDetection = False for i , L in enumerate ( pos_list ) : text , coordinates = L [ 0 ] , L [ 1 ] COLOR = COLORS [ text ] for x , y , w , h in coordinates : if x < 0 or y < 0 or x + w > W or y + h > H or w <= 1 or h <= 1 : continue detections [ self . num_detect ] = ( x , y , w , h ) self . detection_index [ self . num_detect ] = ( x , y , w , h , self . num_save , text ) self . num_detect += 1 hasDetection = True if text == 'face' : gender = self . genderDetect . classify ( image [ y : y + h , x : x + w , : ] ) gender = 'female' if gender [ 0 ] < 0.5 else 'male' cv2 . putText ( image , gender , ( x + w // 2 - 10 , y + h + 15 ) , cv2 . FONT_HERSHEY_SIMPLEX , 0.6 , COLOR , 2 , cv2 . LINE_AA ) image = cv2 . rectangle ( image , ( x , y ) , ( x + w , y + h ) , COLOR , 2 ) cv2 . putText ( image , text , ( x , y - 5 ) , cv2 . FONT_HERSHEY_SIMPLEX , 0.6 , COLOR , 2 , cv2 . LINE_AA ) if hasDetection : self . detection_frames [ self . num_save ] = detections self . num_save += 1 return image
Return a image with visualized locations detected
Return a image with visualized locations detected
"""
		Return a image with visualized locations detected
		""" # prune bad homography points # add the detection to the dict for tracking # if the detection is human
self
image