예제 #1
0
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()
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()
def goGetEm():
	minRemovalScore = 0.0001
	timeOut = 10
	cleanThresh = 5
	binNumber = 100
	distanceWeight = 1
	timeWeight = 1
	sizeWeight = 1
	#weights = (distanceWeight, timeWeight, sizeWeight)
	#variables = [minRemovalScore, timeOut, cleanThresh, binNumber, weights]
	variables = (0.25, 10, 5, 100, (1,1,1), False, (200,0.34,0.25), 2)
	#vid = Video("Slightmovement.MP4", [0,1,0.1,0.1,1000,0])
	vid = Video(0, variables)
	while (True):
		vid.readFrame()
		vid.findFaces()
		vid.display()
		# exit on escape key
		key = cv2.waitKey(20)
		if cv2.waitKey(1) & 0xFF == ord('q'):
			break
	vid.endWindow()
예제 #4
0
    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()