本文整理汇总了Python中polygon.Polygon.get_points方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.get_points方法的具体用法?Python Polygon.get_points怎么用?Python Polygon.get_points使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.get_points方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import get_points [as 别名]
#.........这里部分代码省略.........
self.main_window.setup_play_btn.setEnabled(False)
def click_setup_pause_btn(self):
print("Clicked setup pause button!")
self.play.setup_status = False
self.play.setup_timer.stop()
self.main_window.setup_pause_btn.setEnabled(False)
self.main_window.setup_play_btn.setEnabled(True)
def click_setup_bg_btn(self):
print("Clicked capture background button")
self.background.capture_frame()
def click_draw_btn(self):
print("Clicked draw button")
self.line_status = False
self.draw_status = True
if self.play.setup_status == False:
self.play.run_setup_pause()
self.main_window.setup_draw_btn.setEnabled(False)
self.main_window.setup_line_btn.setEnabled(True)
# get area of polygon
area = self.polygon.compute_area()
self.main_window.area_lbl.setText(str(self.polygon.area))
def click_line_btn(self):
print("Clicked line button")
self.line_status = True
self.draw_status = False
if self.play.setup_status == False:
self.play.run_setup_pause()
self.main_window.setup_line_btn.setEnabled(False)
self.main_window.setup_draw_btn.setEnabled(True)
self.main_window.area_lbl.setText("")
def click_reset_btn(self):
print("Clicked reset button")
self.polygon.reset()
if self.play.setup_status == False:
self.play.run_setup_reset()
self.main_window.setup_reset_btn.setEnabled(False)
self.main_window.setup_line_btn.setEnabled(False)
self.main_window.setup_draw_btn.setEnabled(False)
self.line_status = False
self.draw_status = False
def setup_frame_click(self, event):
if self.play.setup_status == True:
print("Pause the source before assigning coordinates")
else:
print("Clicked setup frame")
x = event.pos().x()
y = event.pos().y()
print(x, y)
print(event.pos())
point = (x, y)
self.polygon.append(point)
self.polygon.get_no_points()
if self.polygon.no_of_points > 0:
self.main_window.setup_reset_btn.setEnabled(True)
if self.polygon.no_of_points > 1:
self.line_status = True
if self.polygon.no_of_points > 2:
self.main_window.setup_draw_btn.setEnabled(True)
self.play.run_setup_pause()
def get_video(self):
return self.video
def load_video(self, video_id):
load = False
s = self.dbs
result = s.query(Video).filter(Video.id == video_id)
if result.count() == 1:
video = result.first()
load = True
elif result.count() > 1:
print("Found more than 1 match in database!")
else:
print("No match found in database!")
if load == True:
self.path = video.path
self.base_name = video.name
self.fps = str(video.fps)
self.duration = video.duration
# address
self.address_window = AddressWindow(self, self.main_window)
self.address_window.get_address(video.address_id)
# polygon
self.polygon = Polygon(self, self.source)
self.polygon.get_points(video.id)
self.polygon.compute_area()
area = self.polygon.area
self.main_window.area_lbl.setText(str(abs(area)))
self.metadata = get_metadata(self.path)
self.duration = get_duration(self.metadata)
self.resolution = get_resolution(self.metadata)
self.format = get_format(self.metadata)
# load in setup
self.populate_setup()
示例2: __init__
# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import get_points [as 别名]
class Analysis:
def __init__(self, source, setup):
self.dbs = source.dbs
self.main_window = source.main_window
self.source = source
self.setup = setup
if self.source.media == 'file':
self.files = source.files
self.main_window.tabs.setCurrentIndex(1)
self.pointer = 0
self.location = Location(self.main_window, self.source)
# signals
# play button
self.main_window.connect(self.main_window.analysis_play_btn, \
SIGNAL("clicked()"), self.click_analysis_play_btn)
# pause button
self.main_window.connect(self.main_window.analysis_pause_btn, \
SIGNAL("clicked()"), self.click_analysis_pause_btn)
# stop button
self.main_window.connect(self.main_window.analysis_stop_btn, \
SIGNAL("clicked()"), self.click_analysis_stop_btn)
# next button
self.main_window.connect(self.main_window.analysis_next_btn, \
SIGNAL("clicked()"), self.click_analysis_next_btn)
# debug speed button
self.main_window.connect(self.main_window.speed_btn, \
SIGNAL("clicked()"), self.click_speed_btn)
# debug road status button
self.main_window.connect(self.main_window.road_status_btn, \
SIGNAL("clicked()"), self.click_road_status_btn)
# haar collect button
self.main_window.connect(self.main_window.haar_capture_btn, \
SIGNAL("clicked()"), self.click_haar_capture_btn)
# haar classifier button
self.main_window.connect(self.main_window.classifier_btn, \
SIGNAL("clicked()"), self.click_classifier_btn)
# choose media source
if self.source.media == 'file':
self.sequencer()
if self.source.media == 'camera':
self.open()
def release_media(self):
print("Releasing media")
if self.source.setup_frames != None:
self.source.setup_frames.release()
self.source.analysis_frames.release()
def sequencer(self):
init_setup(self.main_window)
if self.pointer != len(self.files):
self.file = self.files[self.pointer]
self.open()
self.pointer += 1
else:
print("Nothing to analyse!")
self.dialog = DialogWindow("Analysis", "Analysis is finished!")
init_main(self.main_window)
# self.main_window.tabs.hide()
self.play.analysis_timer.stop()
self.release_media()
def open(self):
init_analysis(self.main_window)
self.main_window.analysis_next_btn.setEnabled(True)
if self.source.media == 'file':
self.source.base_name = get_base_file(self.file)
self.source.analysis_frames = cv2.VideoCapture(self.file)
if self.source.media == 'camera':
init_analysis_camera(self.main_window)
print("Setting analysis frames for camera")
# release camera resource for analysis
self.source.setup_frames.release()
self.source.analysis_frames = cv2.VideoCapture(config['camera'])
# images folder
directory = 'images/' + self.source.base_name
create_dir(directory)
self.get_video()
if self.source.media == 'file':
self.setup.load_video(self.video.id)
self.background = Background(self.source)
self.background.get_db(self.video.id)
self.source.background = self.background
self.polygon = Polygon(self.source, self.setup)
self.polygon.get_points(self.video.id)
self.polygon.draw_setup(self.background.frame, self.polygon.points)
self.source.polygon = self.polygon
self.play = Play(self.source, self.setup)
self.play.run_analysis()
# set location
self.location.set_location(self.video.address_id)
# play
self.click_analysis_play_btn()
def click_analysis_play_btn(self):
print("Clicked play button in analysis!")
self.play.analysis_status = True
self.play.analysis_timer.start()
#.........这里部分代码省略.........