本文整理汇总了Python中video.Video.compute_affine_matrix方法的典型用法代码示例。如果您正苦于以下问题:Python Video.compute_affine_matrix方法的具体用法?Python Video.compute_affine_matrix怎么用?Python Video.compute_affine_matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类video.Video
的用法示例。
在下文中一共展示了Video.compute_affine_matrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from video import Video [as 别名]
# 或者: from video.Video import compute_affine_matrix [as 别名]
#.........这里部分代码省略.........
""" If affine calibration is been performed """
if (self.video.aff_flag == 1):
""" Save last mouse coordinate """
self.video.mouse_coord[self.video.mouse_click_id] = [(x-MIN_X),(y-MIN_Y)]
""" Update the number of used poitns for calibration """
self.video.mouse_click_id += 1
""" Update status label text """
self.ui.rdoutStatus.setText("Affine Calibration: Click point %d"
%(self.video.mouse_click_id + 1))
"""
If the number of click is equal to the expected number of points
computes the affine calibration.
TO DO: Change this code to use you programmed affine calibration
and NOT openCV pre-programmed function as it is done now.
"""
if(self.video.mouse_click_id == self.video.aff_npoints):
"""
Update status of calibration flag and number of mouse
clicks
"""
self.video.aff_flag = 2
self.video.mouse_click_id = 0
print self.video.mouse_coord
print self.video.real_coord
""" Perform affine calibration with OpenCV """
#self.video.aff_matrix = cv2.getAffineTransform(
# self.video.mouse_coord,
# self.video.real_coord)
self.video.compute_affine_matrix()
""" Updates Status Label to inform calibration is done """
self.ui.rdoutStatus.setText("Waiting for input")
"""
Uncomment to gether affine calibration matrix numbers
on terminal
"""
print self.video.aff_matrix
if self.video.aff_flag == 2:
mouse_coord = np.array([[(x-MIN_X)], [(y-MIN_Y)],[1]])
self.world_coord = np.dot(self.video.aff_matrix, mouse_coord)
if self.define_template_flag == 0:
self.click_point1 = copy.deepcopy(self.last_click)
self.define_template_flag = 1
elif self.define_template_flag == 1:
self.click_point2 = copy.deepcopy(self.last_click)
self.template = copy.deepcopy(self.video.bwFrame[2*self.click_point1[1]:2*self.click_point2[1],2*self.click_point1[0]:2*self.click_point2[0]])
print self.click_point1
print self.click_point2
self.define_template_flag = -1
cv2.imwrite('./template.png', self.template)
def affine_cal(self):
"""
Function called when affine calibration button is called.
Note it only chnage the flag to record the next mouse clicks
and updates the status text label
"""
self.video.aff_flag = 1
self.ui.rdoutStatus.setText("Affine Calibration: Click point %d"