本文整理汇总了Python中SimpleCV.Display类的典型用法代码示例。如果您正苦于以下问题:Python Display类的具体用法?Python Display怎么用?Python Display使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Display类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(cameraNumber, camWidth, camHeight, outputFile):
BUFFER_NAME = 'cloud3.avi'
vs = VideoStream(fps=24, filename=BUFFER_NAME, framefill=True)
disp = Display((camWidth, camHeight))
cam = Camera(cameraNumber, prop_set={"width": camWidth, "height": camHeight})
# while the user does not press 'esc'
start_time = time()
count = 0
while disp.isNotDone():
# KISS: just get the image... don't get fancy
img = cam.getImage()
print type(img)
skimage.io.push(img)
#img.show()
# write the frame to videostream
vs.writeFrame(img)
# show the image on the display
img.save(disp)
current_time = time()
if current_time-start_time>=5:
outputFile = "testing_chunk_%d.mp4" % (count)
print "Saving %s" % (outputFile)
saveFilmToDisk(BUFFER_NAME, outputFile)
start_time = time()
count += 1
示例2: main
def main():
x = 0;
cam = Camera (prop_set={'width':640, 'height':480})
disp = Display (resolution=(320,240))
while disp.isNotDone():
img = cam.getImage()
img = img.scale(0.5)
faces = img.findHaarFeatures("eye.xml")
#print "not Detected"
if faces:
for face in faces:
face.draw()
print "eyes Detected"
# x = 0
else:
# x += 1
print "close eyes"
#print (x)
#if x > 10:
# print "HOY GISING"
# return main()
img.save(disp)
示例3: opticalFlow
def opticalFlow():
cam = Camera()
img = cam.getImage().scale(.20)
disp = Display(img.size())
img.save(disp)
X = range(100)
Y = [0 for i in range(100)]
flag = 0
count = 0
while not disp.isDone():
ax.clear()
count += 1
if flag == 0:
imgA = cam.getImage().scale(0.20)
flag += 1
else:
imgB = cam.getImage().scale(0.20)
imgB.save(disp)
motion = imgB.findMotion(imgA)
s = sum([i.magnitude() for i in motion])
imgA = imgB
if count < 100:
Y[count] = s
else:
Y.append(s)
Y = Y[1:]
X.append(count)
X = X[1:]
ax.bar(X, Y)
plt.xlim(X[0], X[-1])
plt.draw()
示例4: main
def main(cameraNumber, camWidth, camHeight, outputFile):
BUFFER_NAME = 'motiontest.avi'
# create the video stream for saving the video file
#vs = VideoStream(fps=24, filename=fname, framefill=True)
vs = VideoStream(fps=24, filename=BUFFER_NAME, framefill=True)
# create a display with size (width, height)
disp = Display((camWidth, camHeight))
# Initialize Camera
cam = Camera(cameraNumber, prop_set={"width": camWidth, "height": camHeight})
# while the user does not press 'esc'
while disp.isNotDone():
# KISS: just get the image... don't get fancy
img = cam.getImage()
#img.show()
# write the frame to videostream
vs.writeFrame(img)
# show the image on the display
img.save(disp)
# Finished the acquisition of images now Transform into a film
#self.makefilmProcess = Process(target=self.saveFilmToDisk, args=(BUFFER_NAME, outputFile))
#self.makefilmProcess.start()
saveFilmToDisk(BUFFER_NAME, outputFile)
示例5: main
def main(cameraNumber, camWidth, camHeight, outputFile):
BUFFER_NAME = 'buffer.avi'
# create the video stream for saving the video file
vs = VideoStream(fps=24, filename=BUFFER_NAME, framefill=True)
# create a display with size (width, height)
disp = Display((camWidth, camHeight))
# Initialize Camera
cam = Camera(cameraNumber, prop_set={"width": camWidth, "height": camHeight})
# while the user does not press 'esc'
while disp.isNotDone():
# KISS: just get the image... don't get fancy
img = cam.getImage()
# write the frame to videostream
vs.writeFrame(img)
# show the image on the display
img.save(disp)
# Finished the acquisition of images now Transform into a film
makefilmProcess = Process(self.saveFilmToDisk, args=(BUFFER_NAME, outputFile))
makefilmProcess.start()
def saveFilmToDisk(self, bufferName, outname):
# construct the encoding arguments
params = " -i {0} -c:v mpeg4 -b:v 700k -r 24 {1}".format(bufferName, outname)
# run avconv to compress the video since ffmpeg is deprecated (going to be).
call('avconv'+params, shell=True)
示例6: simpleDiff
def simpleDiff():
cam = Camera()
img = cam.getImage().scale(.20)
disp = Display(img.size())
img.save(disp)
X = range(100)
Y = [0 for i in range(100)]
count = 0
imgA = cam.getImage().scale(0.20).grayscale()
while not disp.isDone():
ax.clear()
count += 1
time.sleep(0.1)
imgB = cam.getImage().scale(0.20).grayscale()
#imgB.save(disp)
motion = (imgB - imgA).binarize().invert().erode(1).dilate(1)
motion.save(disp)
s = diff(motion)
imgA = imgB
if count < 100:
Y[count] = s
else:
Y.append(s)
Y = Y[1:]
X.append(count)
X = X[1:]
ax.bar(X, Y)
plt.xlim(X[0], X[-1])
plt.draw()
imgA = imgB
示例7: Process
class VideoModule:
videoTitle = time.strftime("%Y_%m_%d_%H_%M_%S")
topic = ''
continueRecord = True
width = 300
height = 300
makefilmProcess = Process()
disp = 0
def getVideoTitle(self):
return self.videoTitle
def getVideoDisplay(self):
return self.disp
def recordVideo(self, cb, topic, length=5):
global BUFFER_NAME
BUFFER_NAME = topic + '_' + time.strftime("%Y_%m_%d_%H_%M_%S") + '.avi'
vs = VideoStream(fps=24, filename=BUFFER_NAME, framefill=True)
self.disp = Display((self.width, self.height))
cam = Camera(1, prop_set={"width":self.width,"height":self.height})
while self.continueRecord:
gen = (i for i in range(0, 30 * length) if self.continueRecord)
for i in gen:
img = cam.getImage()
vs.writeFrame(img)
img.save(self.disp)
self.continueRecord = False
print "Broke capture loop"
self.disp.quit()
print "Saving video"
# This is to run this process asynchronously - we will skip that
# self.makefilmProcess = Process(target=saveFilmToDisk, args=(BUFFER_NAME, self.videoTitle))
# self.makefilmProcess.start()
# Callback function
cb()
def getBufferName(self):
global BUFFER_NAME
return BUFFER_NAME
def endCapture(self):
self.continueRecord = False
self.disp.quit()
print "Set variable to false"
def __init__(self, appendTitle):
self.topic = appendTitle
self.videoTitle += appendTitle + ".mp4"
示例8: show_video
def show_video():
dis = Display()
try:
while not dis.isDone():
capture_image().save(dis)
sleep(1 / 25.0)
except pygame.error:
return
示例9: run
def run(self):
m = alsaaudio.Mixer() # defined alsaaudio.Mixer to change volume
scale = (300,250) # increased from (200,150). works well
d = Display(scale)
cam = Camera()
prev = cam.getImage().scale(scale[0],scale[1])
sleep(0.5)
buffer = 20
count = 0
prev_t = time() # Note initial time
while d.isNotDone():
current = cam.getImage()
current = current.scale(scale[0],scale[1])
if( count < buffer ):
count = count + 1
else:
fs = current.findMotion(prev, method="LK") # find motion
# Tried BM, and LK, LK is better. need to learn more about LK
if fs: # if featureset found
dx = 0
dy = 0
for f in fs:
dx = dx + f.dx # add all the optical flow detected
dy = dy + f.dy
dx = (dx / len(fs)) # Taking average
dy = (dy / len(fs))
prev = current
sleep(0.01)
current.save(d)
if dy > 2 or dy < -2:
vol = int(m.getvolume()[0]) # getting master volume
if dy < 0:
vol = vol + (-dy*3)
else:
vol = vol + (-dy*3)
if vol > 100:
vol = 100
elif vol < 0:
vol = 0
print vol
m.setvolume(int(vol)) # setting master volume
if dx > 3:
cur_t = time()
if cur_t > 5 + prev_t: # adding some time delay
self.play("next") # changing next
prev_t = cur_t
if dx < -3:
cur_t = time()
if cur_t > 5 + prev_t:
prev_t = cur_t
self.play("previous") # changing previous
示例10: calibrate
def calibrate():
winsize = (640, 480)
display = Display(winsize)
bg_img = get_image()
bg_img.save(display)
while not display.isDone():
img = get_image()
img.save(display)
if display.mouseLeft:
return img.getPixel(display.mouseX, display.mouseY), bg_img, img
示例11: interactiveTranslation
def interactiveTranslation():
cam = Camera()
disp = Display()
current = " "
while disp.isNotDone():
image = cam.getImage()
if disp.mouseLeft: break
if disp.mouseRight:
text = image.readText()
text = cleanText(text)
translated = trans.translate(text, langpair)
if translated: current = translated
image.drawText(current, 0, 0, color=Color.BLACK, fontsize=40)
image.save(disp)
示例12: recordVideo
def recordVideo(self, cb, topic, length=5):
global BUFFER_NAME
BUFFER_NAME = topic + '_' + time.strftime("%Y_%m_%d_%H_%M_%S") + '.avi'
vs = VideoStream(fps=24, filename=BUFFER_NAME, framefill=True)
self.disp = Display((self.width, self.height))
cam = Camera(1, prop_set={"width":self.width,"height":self.height})
while self.continueRecord:
gen = (i for i in range(0, 30 * length) if self.continueRecord)
for i in gen:
img = cam.getImage()
vs.writeFrame(img)
img.save(self.disp)
self.continueRecord = False
print "Broke capture loop"
self.disp.quit()
print "Saving video"
# This is to run this process asynchronously - we will skip that
# self.makefilmProcess = Process(target=saveFilmToDisk, args=(BUFFER_NAME, self.videoTitle))
# self.makefilmProcess.start()
# Callback function
cb()
示例13: __init__
def __init__(self, size=(720, 540)):
self._layers = {
# Base layers
'raw': None,
'threshY': None,
'threshB': None,
'threshR': None,
# Overlay layers
'yellow': None,
'blue': None,
'ball' : None,
}
# These layers are drawn regardless of the current layerset
self._persistentLayers = {
'mouse': None
}
self._currentLayerset = self.layersets['default']
self._display = Display(size)
self._eventHandler = Gui.EventHandler()
self._lastMouseState = 0
self._showMouse = True
self._lastFrame = None
self._lastFrameTime = time.time()
示例14: ajusteFoto
def ajusteFoto(filename,brillo=50,resolucion=(1024,768),modoExposicion='auto'):
""" Va tomando fotos en un proceso de ensayo y error supervisado por el
usuario , hasta que se toma la adecuada y el metodo
devuelve el objeto imagen """
disp = Display(resolucion)
try:
while not disp.isDone():
img = tomaFoto(filename,brillo,resolucion,modoExposicion,altaVelocidad=False)
img.save(disp)
except:
pass
return img
示例15: init
class GUIManager:
def init(self):
self.dis = Display(title='FRC Team 3341 Targeting') # creates a window
def setImage(self, image):
self.img = image
def setImageText(self, imageText):
self.img.drawtext(imagetext, self.img.height/2, self.img.width/2)
# the height and width may need to be switched around
# it could also be that the image is bigger than the display
def setFeatures(self, blobs=None, ls=None): #draws the features like blobs and Ls
if self.blobs:
for b in blobs:
b.draw()
if ls:
for l in ls:
l.draw() # the L draw function draws the Ls upside down for some reason
def show(self):
# I took out the isFile parameter because a video is not displayed differently than an image in simplecv
# the thing where it waits for a key to be pressed was taken out too because it made the program crash
self.img.save(self.dis)
def disIsNotDone(self):
# this is used to find if the window has been exited out of
return self.dis.isNotDone()