Пример #1
0
	def getForegroundMask(self, frame):
		# apply background subtraction
		fgmask = self.fgbg.apply(frame)

		# apply some filters
		fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, self.kernel)
		ret,fgmask = cv2.threshold(fgmask,127,255,cv2.THRESH_BINARY)
		
		return fgmask
Пример #2
0
	def getForegroundMask(self, frame):
		imgCopy = frame.copy()
		frame = cv2.GaussianBlur(frame,(3,3),0)
		cv2.absdiff(frame, self.background, imgCopy)
		gray = cv2.cvtColor(imgCopy, cv2.COLOR_BGR2GRAY)
		_, thresh = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
		fgmask = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, self.kernel)

		return fgmask