本文整理汇总了Python中SimpleCV.Display.leftButtonDownPosition方法的典型用法代码示例。如果您正苦于以下问题:Python Display.leftButtonDownPosition方法的具体用法?Python Display.leftButtonDownPosition怎么用?Python Display.leftButtonDownPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Display
的用法示例。
在下文中一共展示了Display.leftButtonDownPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Display
# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import leftButtonDownPosition [as 别名]
disp = Display((800,600))
vals = []
last = (0,0)
# Load the video from the rpi
vc = VirtualCamera("video.h264","video")
# Sometimes there is crud at the begining, buffer it out
for i in range(0,10):
img = vc.getImage()
img.save(disp)
# Show the user a frame let them left click the center
# of the "donut" and the right inner and outer edge
# in that order. Press esc to exit the display
while not disp.isDone():
test = disp.leftButtonDownPosition()
if( test != last and test is not None):
last = test
vals.append(test)
# 0 = xc yc
# 1 = r1
# 2 = r2
# center of the "donut"
Cx = vals[0][0]
Cy = vals[0][1]
# Inner donut radius
R1x = vals[1][0]
R1y = vals[1][1]
R1 = R1x-Cx
# outer donut radius
示例2: print
# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import leftButtonDownPosition [as 别名]
print("Give (at least one) file name(s) of the images(s) to process")
sys.exit()
disp = Display((1280,1024))
virtual_cam = VirtualCamera(sys.argv[1], "image")
img = virtual_cam.getImage()
img.save(disp)
points = []
last_pt = (0, 0)
# Show the first image, the user had to left click the center of the donut,
# followed by the right inner and outer edge (in that order). Press "Esc" to exit.
# All the images are processed with the same parameters
while not disp.isDone():
temp_pt = disp.leftButtonDownPosition()
if( temp_pt != last_pt and temp_pt is not None):
last_pt = temp_pt
points.append(temp_pt)
# Center of the donut
Cx = points[0][0]
Cy = points[0][1]
# Inner donut radius
R1x = points[1][0]
R1y = points[1][1]
R1 = R1x-Cx
# Outer donut radius
R2x = points[2][0]
R2y = points[2][1]
R2 = R2x-Cx
示例3:
# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import leftButtonDownPosition [as 别名]
COLOR = Color.BLUE
# main loop #
while not disp.isDone():
img = cam.getImage()
img = img.flipHorizontal() # just for my convenience - simulates mirror :)
if inVideoMode:
(orig_h, orig_w) = (img.height, img.width) # required for VideoStream
px = disp.mouseX
py = disp.mouseY
left_down = disp.leftButtonDownPosition() # grab coordinates for event press
left_up = disp.leftButtonUpPosition() # grab coordinates for event release
if left_down is not None: # left mouse button pressed
# start drawing rectangle
(lx, ly) = left_down
if left_up is not None: # left mouse button released
# stop drawing rectangle, go into zoom mode
(lx, ly) = (None, None)
inZoomMode = True if not inZoomMode else False # enter zooming mode
zoom = (sx, sy, w, h)
if inZoomMode:
img = img.crop(zoom[0], zoom[1], zoom[2], zoom[3])