本文整理汇总了Python中Camera.Camera.getFrame方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.getFrame方法的具体用法?Python Camera.getFrame怎么用?Python Camera.getFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.getFrame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Camera
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import getFrame [as 别名]
laserTreshold = 100 #Tune this value for laser detection
cam = Camera(cameraID, captureWidth, captureHeight, 2)
def countdown(duration, event=""):
#raw_input("(Press Enter to continue)")
for i in range(duration, 0, -1):
print(str(i) + " ", end="")
sys.stdout.flush()
time.sleep(1)
print(event)
try:
#Gather the setup vectors
print("Shooting initial difference picture")
baseImg = cam.getFrame()
baseImgChannelB, baseImgChannelG, baseImgChannelR = cv2.split(baseImg)
cv2.imshow("Mask", baseImgChannelR)
cv2.waitKey(0)
sourceMatrix = []
for corner in range(1, 5):
print("Laser corner " + str(corner) + " and press a button")
channelB, channelG, channelR = cv2.split(cam.getFrame())
mask = cv2.absdiff(baseImgChannelB, channelR)
ret, mask = cv2.threshold(mask, laserTreshold, 255, cv2.THRESH_BINARY)
mask = cv2.dilate(mask, None, iterations=2)
示例2: Camera
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import getFrame [as 别名]
upper = (130, 255, 255)
cam = Camera(cameraID, captureWidth, captureHeight)
def countdown(duration, event=""):
#raw_input("(Press Enter to continue)")
for i in range(duration, 0, -1):
print(str(i) + " ", end="")
sys.stdout.flush()
time.sleep(1)
print(event)
#Gather the setup vectors
print("Shoot initial difference picture")
countdown(3, "Got it")
baseImgGrey = cv2.cvtColor(cam.getFrame(), cv2.COLOR_BGR2GRAY)
cv2.imshow("Mask", baseImgGrey)
cv2.waitKey(0)
for corner in range(1, 5):
print("Laser corner " + str(corner))
countdown(3, "Got it")
imgGrey = cv2.cvtColor(cam.getFrame(), cv2.COLOR_BGR2GRAY)
mask = cv2.absdiff(baseImgGrey, imgGrey)
cv2.imshow("Mask", mask)
cv2.waitKey(0)
ret, mask = cv2.threshold(mask, 100, 255, cv2.THRESH_BINARY)
if corner == 1: maskCombined = mask
else: maskCombined = maskCombined + mask #Add all the dots to a single mask
示例3: Camera
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import getFrame [as 别名]
from __future__ import print_function
import time, numpy, sys
from Camera import Camera
import cv2
import cv2.cv as cv
captureWidth = 1280 #Width of camera picture
captureHeight = 720 #Height of camera picture
cameraID = 2 #Which camera to use
cam = Camera(cameraID, captureWidth, captureHeight, 2)
transformationMatrix = numpy.array([[2.82259237e+01, 6.24776063e+01, -5.49726821e+04], [ -3.12753244e+01, 5.64481465e+01, -1.36139199e+04], [ 1.47719421e-03, -1.51581973e-01, 1.00000000e+00]])
try:
while True:
img = cam.getFrame()
dst = cv2.warpPerspective(img, transformationMatrix, (720,720), flags=cv2.INTER_NEAREST)
cv2.imshow("Mask", dst)
cv2.waitKey(50)
except:
cam.release()