本文整理汇总了Python中video.Video.getCurrentFrame方法的典型用法代码示例。如果您正苦于以下问题:Python Video.getCurrentFrame方法的具体用法?Python Video.getCurrentFrame怎么用?Python Video.getCurrentFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类video.Video
的用法示例。
在下文中一共展示了Video.getCurrentFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import getCurrentFrame [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()