Detector/DetectorWraper.py
def similarity_score(self, img1, img2):
		"""
		Calculate the similarity score used for detection tracking
		"""
		# resize into the same shape first
		if img1.shape != img2.shape:
			v, h = max(img1.shape[0], img2.shape[0]), max(img1.shape[1], img2.shape[1])
			dim = (h, v)
			h_scale = min(img1.shape[1], img2.shape[1]) / h
			v_scale = min(img1.shape[0], img2.shape[0]) / v
			img1 = cv2.resize(img1, dim, interpolation = cv2.INTER_AREA)
			img2 = cv2.resize(img2, dim, interpolation = cv2.INTER_AREA)
		# # histogram
		# diff = 0
		# for c in range(3):
		# 	hist1 = cv2.calcHist([img1], [c], None, [256], [0, 256])
		# 	hist2 = cv2.calcHist([img2], [c], None, [256], [0, 256])
		# 	diff += np.linalg.norm(hist1 - hist2)

		# HoG
		fd1, _ = hog(img1, orientations=8, pixels_per_cell=(16, 16),
                    cells_per_block=(1, 1), visualize=True, multichannel=True)
		fd2, _ = hog(img2, orientations=8, pixels_per_cell=(16, 16),
                    cells_per_block=(1, 1), visualize=True, multichannel=True)
		# Combine both
		dist = np.linalg.norm(fd1 - fd2)
		aim = mean_pixel_intensity_diff(img1, img2)
		score = 1 / (dist + aim + 1)
		return score

		Calculate the similarity score used for detection tracking
		
Calculate the similarity score used for detection tracking
Calculate the similarity score used for detection tracking
def similarity_score(self, img1, img2):
		if img1.shape != img2.shape:
			v, h = max(img1.shape[0], img2.shape[0]), max(img1.shape[1], img2.shape[1])
			dim = (h, v)
			h_scale = min(img1.shape[1], img2.shape[1]) / h
			v_scale = min(img1.shape[0], img2.shape[0]) / v
			img1 = cv2.resize(img1, dim, interpolation = cv2.INTER_AREA)
			img2 = cv2.resize(img2, dim, interpolation = cv2.INTER_AREA)
		fd1, _ = hog(img1, orientations=8, pixels_per_cell=(16, 16),
                    cells_per_block=(1, 1), visualize=True, multichannel=True)
		fd2, _ = hog(img2, orientations=8, pixels_per_cell=(16, 16),
                    cells_per_block=(1, 1), visualize=True, multichannel=True)
		dist = np.linalg.norm(fd1 - fd2)
		aim = mean_pixel_intensity_diff(img1, img2)
		score = 1 / (dist + aim + 1)
		return score
def similarity_score ( self , img1 , img2 ) : if img1 . shape != img2 . shape : v , h = max ( img1 . shape [ 0 ] , img2 . shape [ 0 ] ) , max ( img1 . shape [ 1 ] , img2 . shape [ 1 ] ) dim = ( h , v ) h_scale = min ( img1 . shape [ 1 ] , img2 . shape [ 1 ] ) / h v_scale = min ( img1 . shape [ 0 ] , img2 . shape [ 0 ] ) / v img1 = cv2 . resize ( img1 , dim , interpolation = cv2 . INTER_AREA ) img2 = cv2 . resize ( img2 , dim , interpolation = cv2 . INTER_AREA ) fd1 , _ = hog ( img1 , orientations = 8 , pixels_per_cell = ( 16 , 16 ) , cells_per_block = ( 1 , 1 ) , visualize = True , multichannel = True ) fd2 , _ = hog ( img2 , orientations = 8 , pixels_per_cell = ( 16 , 16 ) , cells_per_block = ( 1 , 1 ) , visualize = True , multichannel = True ) dist = np . linalg . norm ( fd1 - fd2 ) aim = mean_pixel_intensity_diff ( img1 , img2 ) score = 1 / ( dist + aim + 1 ) return score
Calculate the similarity score used for detection tracking
Calculate the similarity score used for detection tracking
"""
		Calculate the similarity score used for detection tracking
		""" # resize into the same shape first # # histogram # diff = 0 # for c in range(3): # 	hist1 = cv2.calcHist([img1], [c], None, [256], [0, 256]) # 	hist2 = cv2.calcHist([img2], [c], None, [256], [0, 256]) # 	diff += np.linalg.norm(hist1 - hist2) # HoG # Combine both
self
img1
img2