def gotFrame(self, img): # Set up parameters outImg = None # Preprocessing img = cv2.resize(img, (640, 480)) rawImg = vision.shadesOfGray(img) blurImg = cv2.GaussianBlur(rawImg, ksize=(0, 0), sigmaX=10) enhancedImg = cv2.addWeighted(rawImg, 2.5, blurImg, -1.5, 0) enhancedImg = cv2.GaussianBlur(enhancedImg, ksize=(3, 3), sigmaX=2) hsvImg = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) hsvImg = self.normalise(hsvImg) bluredimg = cv2.GaussianBlur(enhancedImg, ksize=(5, 5), sigmaX=2) bluredimg = cv2.cvtColor(bluredimg, cv2.COLOR_BGR2HSV) bluredimg = self.normalise(bluredimg) # return cv2.cvtColor(hsvImg, cv2.COLOR_HSV2BGR) # Find red image redImg = self.threshold(hsvImg, bluredimg, "RED") outImg = redImg # Find green image #greenLen, greenImg = self.threshold(img, "GREEN") # Find blue image #blueLen, blueImg = self.threshold(img, "BLUE") #outImg = redImg | greenImg | blueImg return outImg
def gotFrame(self, img): # Set up parameters outImg = None # Preprocessing img = cv2.resize(img, (640, 480)) rawImg = vision.shadesOfGray(img) blurImg = cv2.GaussianBlur(rawImg, ksize=(0, 0), sigmaX=10) enhancedImg = cv2.addWeighted(rawImg, 2.5, blurImg, -1.5, 0) hsvImg = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) hsvImg = self.normalise(hsvImg) # return cv2.cvtColor(img, cv2.COLOR_HSV2BGR) # Find red image redImg = self.threshold(hsvImg, "RED") outImg = redImg # Find green image #greenLen, greenImg = self.threshold(img, "GREEN") # Find blue image #blueLen, blueImg = self.threshold(img, "BLUE") #outImg = redImg | greenImg | blueImg return outImg