def drawDebugRects(self,image): """Draw rectangles around the tracked facial features.""" if utils.isGray(image): faceColor =255 leftEyeColor = 255 rightEyeColor = 255 noseColor = 255 mouthColor = 255 else: faceColor = (255,255,255)#white leftEyeColor = (0,0,255)#red rightEyeColor = (0,255,255)#yellow noseColor = (0,255,0)#green mouthColor = (255,0,0)#blue for face in self.faces: rects.outlineRect(image,face.faceRect,faceColor) rects.outlineRect(image,face.leftEyeRect,leftEyeColor) rects.outlineRect(image,face.rightEyeRect,rightEyeColor) rects.outlineRect(image,face.noseRect,noseColor) rects.outlineRect(image,face.mouthRect,mouthColor)
def drawDebugRects(self, image): """ Draw rectangles around the tracked facial features. """ if utils.isGray(image): faceColor = 255 leftEyeColor = 255 rightEyeColor = 255 noseColor = 255 mouthColor = 255 else: faceColor = (255, 255, 255) # white leftEyeColor = (0, 0, 255) # red rightEyeColor = (0, 255, 255) # yellow noseColor = (0, 255, 0) # green mouthColor = (255, 0, 0) # blue for face in self.faces: rects.outlineRect(image, face.faceRect, faceColor) rects.outlineRect(image, face.leftEyeRect, leftEyeColor) rects.outlineRect(image, face.rightEyeRect, rightEyeColor) rects.outlineRect(image, face.noseRect, noseColor) rects.outlineRect(image, face.mouthRect, mouthColor)
def drawDebugRects(self, image): if utils.isGray(image): faceColor = 255 leftEyeColor = 255 rightEyeColor = 255 noseColor = 255 mouthColor = 255 else: faceColor = (255, 255, 255) # white leftEyeColor = (0, 0, 255) # red rightEyeColor = (0, 255, 255) # yellow noseColor = (0, 255, 0) # green mouthColor = (255, 0, 0) # blue for face in self.faces: rects.outlineRect(image, face.faceRect, faceColor) rects.outlineRect(image, face.leftEyeRect, leftEyeColor) rects.outlineRect(image, face.rightEyeRect, rightEyeColor) rects.outlineRect(image, face.noseRect, noseColor) rects.outlineRect(image, face.mouthRect, mouthColor)
def drawRect(self, image): if utils.isGray(image): faceColor = 255 leftEyeColor = 255 rightEyeColor = 255 noseColor = 255 mouthColor = 255 else: faceColor = (255, 255, 255) # white leftEyeColor = (0, 0, 255) # red rightEyeColor = (0, 255, 255) # yellow #noseColor = (0, 255, 0) # green mouthColor = (255, 0, 0) # blue for face in self.faces: rects.outlineRect(image, faceColor, face.face) rects.outlineRect(image, leftEyeColor, face.lefteye) rects.outlineRect(image, rightEyeColor, face.righteye) #rects.outlineRect(image, face.noseRect, noseColor) rects.outlineRect(image, mouthColor, face.smile) self.faces = []
def drawDebugRects(self, image): if utils.isGray(image): faceColor = 255 leftEyeColor = 255 rightEyeColor = 255 noseColor = 255 mouthColor = 255 else: faceColor = (255, 255, 255) leftEyeColor = (0, 0, 255) rightEyeColor = (0, 255, 255) noseColor = (0, 255, 0) mouthColor = (255, 0, 0) white = (255, 255, 255) for face in self.faces: rects.outlineRect(image, face.faceRect, faceColor) rects.outlineRect(image, face.leftEyeRect, leftEyeColor) rects.outlineRect(image, face.rightEyeRect, rightEyeColor) rects.outlineRect(image, face.noseRect, noseColor) rects.outlineRect(image, face.mouthRect, mouthColor) k = 5 leftEye = None rightEye = None mouth = None nose = None if face.leftEyeRect is not None: leftEye = (face.leftEyeRect[0] + int(face.leftEyeRect[2] / 2), face.leftEyeRect[1] + int(face.leftEyeRect[3] / 2)) rect = (leftEye[0] - k, leftEye[1] - k, 2 * k, 2 * k) rects.outlineRect(image, rect, white) if face.rightEyeRect is not None: rightEye = (face.rightEyeRect[0] + int(face.rightEyeRect[2] / 2), face.rightEyeRect[1] + int(face.rightEyeRect[3] / 2)) rect = (rightEye[0] - k, rightEye[1] - k, 2 * k, 2 * k) rects.outlineRect(image, rect, white) if face.mouthRect is not None: mouth = (face.mouthRect[0] + int(face.mouthRect[2] / 2), face.mouthRect[1] + int(face.mouthRect[3] / 2)) rect = (mouth[0] - k, mouth[1] - k, 2 * k, 2 * k) rects.outlineRect(image, rect, white) if face.noseRect is not None: nose = (face.noseRect[0] + int(face.noseRect[2] / 2), face.noseRect[1] + int(face.noseRect[3] / 2)) rect = (nose[0] - k, nose[1] - k, 2 * k, 2 * k) rects.outlineRect(image, rect, white) if leftEye and rightEye and nose and mouth is not None: cv2.line(image, leftEye, rightEye, white, 1) cv2.line(image, leftEye, mouth, white, 1) cv2.line(image, mouth, rightEye, white, 1) cv2.line(image, nose, rightEye, white, 1) cv2.line(image, nose, leftEye, white, 1) cv2.line(image, nose, mouth, white, 1) # Descritores distEyes = utils.dist(leftEye, rightEye) distLeftEyeToNose = utils.dist(leftEye, nose) distRightEyeToNose = utils.dist(rightEye, nose) distLeftEyeToMouth = utils.dist(leftEye, mouth) distRightEyeToMouth = utils.dist(rightEye, mouth) distNoseToMouth = utils.dist(nose, mouth) #print(distEyes, distLeftEyeToNose, distRightEyeToNose, distLeftEyeToMouth, distRightEyeToMouth, distNoseToMouth) print(distEyes/distLeftEyeToNose, distEyes/distRightEyeToNose, distEyes/distLeftEyeToMouth, distEyes/distRightEyeToMouth, \ distLeftEyeToNose/distLeftEyeToMouth, distRightEyeToNose/distRightEyeToMouth) # Gerando caracterizadores faciais #print(">> Face: ",face.faceRect) #print(">> Left eye: ",face.leftEyeRect) #print(">> Right eye: ",face.rightEyeRect) #print(">> Nose: ", face.noseRect) #print(">> Mouth: ",face.mouthRect)