当前位置: 首页>>代码示例>>Python>>正文


Python Video.findFaces方法代码示例

本文整理汇总了Python中video.Video.findFaces方法的典型用法代码示例。如果您正苦于以下问题:Python Video.findFaces方法的具体用法?Python Video.findFaces怎么用?Python Video.findFaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在video.Video的用法示例。


在下文中一共展示了Video.findFaces方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: goGetEm

# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import findFaces [as 别名]
def goGetEm():
	minRemovalScore = 0.25
	timeOut = 10
	cleanThresh = 5
	binNumber = 100
	distanceWeight = 0.5
	timeWeight = 0.0
	sizeWeight = 0.5
	weights = (distanceWeight, timeWeight, sizeWeight)
	writingToFiles = True
	distDev = 200
	timeDev = 1
	sizeDev = 0.25
	devs = (distDev, timeDev, sizeDev)
	framesback = 5

	# minRemovals = [0.0001, 0.1, 0.25]
	# weightDev = [((0.5,0,0.5),(100,0.34,0.15)),((0.5,0,0.5),(200,0.34,0.25)),((0.45,0.2,0.35),(100,0.34,0.15)),((0.45,0.2,0.35),(200,0.34,0.25))]
	i = 0
	# for minRemovalScore in minRemovals:
	# 	for setting in weightDev:
			# weights = setting[0]
			# devs = setting[1]
	variables = [minRemovalScore, timeOut, cleanThresh, binNumber, weights, writingToFiles, devs, framesback]
	vidFile = "datums/outvideo"+str(i)+".avi"
	vid = Video("Testvideos/Movie1.mov", variables, False)
	vid.openVidWrite(vidFile)
	success = vid.readFrame()
	while (success):
		vid.findFaces()
		vid.writeToVideo()
		success = vid.readFrame()
	vid.endWindow()
开发者ID:danhan52,项目名称:facial-recognition,代码行数:35,代码来源:variableTest.py

示例2: goGetEm

# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import findFaces [as 别名]
def goGetEm():
	minRemovalScore = 0.0001
	timeOut = 10
	cleanThresh = 5
	binNumber = 100
	distanceWeight = 0.5
	sizeWeight = 0.0
	timeWeight = 0.5
	weights = (distanceWeight, timeWeight, sizeWeight)
	writingToFiles = True
	distDev = 200
	timeDev = 0.34
	sizeDev = 0.25
	devs = (distDev, timeDev, sizeDev)
	framesback = 2
	variables = [minRemovalScore, timeOut, cleanThresh, binNumber, weights, writingToFiles, devs, framesback]
	vid = Video(0, variables)
	# vidFile = "outvid.avi"
	# csvFile = "variable.csv"
	# if writingToFiles:
	# 	vid.openVidWrite(vidFile)
	# 	vid.openCSVWrite(csvFile)
	while (True):
		vid.readFrame()
		vid.findFaces()
		vid.display()
		# vid.writeToVideo()
		# exit on escape key
		key = cv2.waitKey(1)
		if key == 27:
			break
	vid.endWindow()
开发者ID:danhan52,项目名称:facial-recognition,代码行数:34,代码来源:livetrackwithface.py

示例3: draw

# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import findFaces [as 别名]
    def draw(self):
        '''Draws main GUI, then loops on frames'''
        grid = QGridLayout()
        
        self.leftbox = ImageBox()
        grid.addWidget(self.leftbox,0,0)

        self.rightbox = ControlBox(self)
        grid.addWidget(self.rightbox, 0, 1)
        
        variables = (0.25, 10, 5, 100, (0.5,0,0.5), False, (200.0,0.34,0.25), 2)
        #create Video object
        vid = Video(0,variables)
        
        while(True):
            
            # Read every frame and extract images
            vid.readFrame()
            frame_as_string_before = vid.getCurrentFrame().tostring()
            vid.findFaces()
            self.face_list = vid.getFaces()
            
            # If we've clicked the num button, draw rectangles around each face
            if self.draw_nums:
                for i in range(len(self.face_list)):
                    # Uncomment if we don't want to use predicted position
#                    vid.showRectangle(self.face_list[i].getPosition(),self.face_list[i].getID())
                    # If the face is obscured, draw the rectangle around the predicted position
                    if not face.isObscured():
                        vid.showRectangle(self.face_list[i].getPosition(),self.face_list[i].getID())
                    else:
                        vid.showRectangle(self.face_list[i].getPredictedPosition(),self.face_list[i].getID())
     
                
            frame = vid.getCurrentFrame()
            
            rects = []
        
            #Get position of each face
            for face in self.face_list:
                # Position of each face (for use in Control Box) based on last detected position, not predicted
                tuples = face.getPosition()
                rects.append([tuples[0][0], tuples[0][1], tuples[1][0], tuples[1][1]])
                # Uncomment if we want to base it on predicted
#                if not face.isObscured():
#                    tuples = face.getPosition()
#                    rects.append([tuples[0][0], tuples[0][1], tuples[1][0], tuples[1][1]])
#                else:
#                    tuples = face.getPredictedPosition()
#                    if tuples:
#                        rects.append([tuples[0][0], tuples[0][1], tuples[1][0], tuples[1][1]])
               
                
            # Transform cv2 frame (numpy array) into QPixmap via string and QImage
            cv2.cvtColor(frame, cv.CV_BGR2RGB, frame)
            frame_as_string = frame.tostring()
            
            image = QImage(frame_as_string,\
            frame.shape[1],frame.shape[0],QImage.Format_RGB888)
            pixmap = QPixmap.fromImage(image) 
            
            # Get images of faces for use in Control Box
            face_pics = get_imgs_from_rects(image, rects)
           
            # DON'T DELETE
            # What does it do
            # WHO KNOWS
            if cv2.waitKey(1) & 0xFF == ord('q'):
                vid.endWindow()
                break
            
            # Update everything with current face info
            self.leftbox.set_image(pixmap, self.face_list, face_pics)
            self.rightbox.setFaces(face_pics, self.face_list)
            
            self.setLayout(grid)
            self.show()
开发者ID:danhan52,项目名称:facial-recognition,代码行数:79,代码来源:face_video.py


注:本文中的video.Video.findFaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。