当前位置: 首页>>代码示例>>Python>>正文


Python Display.quit方法代码示例

本文整理汇总了Python中SimpleCV.Display.quit方法的典型用法代码示例。如果您正苦于以下问题:Python Display.quit方法的具体用法?Python Display.quit怎么用?Python Display.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleCV.Display的用法示例。


在下文中一共展示了Display.quit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Process

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
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"
开发者ID:vsudhakar,项目名称:TedVideoBooth,代码行数:61,代码来源:videoModule.py

示例2: show_img

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
def show_img(img):
    display = Display()
    img.show()

    # Wait for user to close the window or break out of it.
    while display.isNotDone():
        try:
            pass
        except KeyboardInterrupt:
            display.done = True
        if display.mouseRight:
            display.done = True
    display.quit()
开发者ID:david-crespo,项目名称:py-super-hexagon,代码行数:15,代码来源:util.py

示例3: record

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
def record(filename):
    from SimpleCV import Camera, Display
    import time
    neg_dir = "rawdata/%s" % filename
    if not os.path.exists(neg_dir):
        os.makedirs(neg_dir)
    cam = Camera()
    dis = Display()
    time.sleep(2)
    targetFps = 15.0
    fps = targetFps
    sleepTime = 1/targetFps
    start = time.time()
    prevTime = None
    count = 0
    try:
        print "Recording... [keyboard interrupt to quit]"
        while dis.isNotDone():
            img = cam.getImage()
            img = scaleDown(img)
            if fps > targetFps + .5:
                sleepTime += 0.005
            elif fps < targetFps:
                sleepTime = max(sleepTime - 0.005, 0.01)
            if prevTime is not None:
                fps = 1.0 / (time.time() - prevTime)
            prevTime = time.time()
            img.save("%s/%05d.jpg" % (neg_dir, count + 1600))
            count += 1
            img.dl().ezViewText("{0:.3f} fps".format(fps), (0, 0))
            img.save(dis)
            if dis.mouseRight:
                dis.quit()
            time.sleep(sleepTime)

    except KeyboardInterrupt:
        print "Done recording"
开发者ID:DenerosArmy,项目名称:asterisk,代码行数:39,代码来源:asterisk.py

示例4: FingerTrackerPeaks

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
class FingerTrackerPeaks(FingerTracker):
    """Finger tracking using peak-findings
    """

    def __init__(self, camera=None):
        """Initialize the finger tracker

        :param TrackerIn ti: Tracker input
        :param camera: Camera index, filename, or None
        """
        FingerTracker.__init__(self, camera)
        self.display = None

    def crop_img(self, img):
        return img.crop(50, 150, img.width - 100, img.height - 150)
        return img.crop(490, 95, img.width - 1000, img.height - 290).rotate(90, fixed=False)

    def find_fingers3(self, img, prev_img):
        if img is None or prev_img is None:
            return []

        crop_spec = [0, 0, img.width, img.height]
        scale_factor = 2
        r1 = img.grayscale().crop(*crop_spec)
        r2 = prev_img.grayscale().crop(*crop_spec)

        # modified
        diff = (r2 - r1).binarize(40)
        edge_mask = diff.erode(5).dilate(5) - diff.erode(5)
        edge_mask = edge_mask.dilate(5)
        scaled = (diff.edges() & edge_mask).resize(r1.width / scale_factor)

        points = []
        for x in range(scaled.width):
            points.append(scaled.edgeIntersections((x, 0), (x, scaled.height))[0])
        points = [xy for xy in points if xy is not None]
        if not points:
            return []

        xs = range(scaled.width)
        ys = scipy.interp(range(scaled.width), [a[0] for a in points], [a[1] for a in points])
        peaks = scipy.signal.find_peaks_cwt(-ys, np.arange(7, 11))
        if len(peaks) == 0:
            return []

        positions = np.array(zip(peaks, np.array(ys)[peaks])) * scale_factor + np.array(crop_spec[:2])

        return positions

    def run_frame(self, ti, img):
        """Run the algorithm for one frame

        :param TrackerIn ti: TrackerIn object to send events to
        :return: True if I should be called with the next frame
        """
        img = self.crop_img(img)

        if self.display is None:
            # Consume one frame for the initialization
            self.display = Display(img.size())
            self.prev_img = img
            self.bg_img = None
            self.count = 20
            self.last_time = time.time()
            return True
        elif self.display.isDone():
            return False

        if self.bg_img is None and img:
            self.bg_img = img

        positions = self.find_fingers3(img, self.bg_img)
        if self.count > 0:
            self.bg_img = img
            self.count -= 1
            print "SETTING BG IMAGE"

        di = img  # (bg_img.grayscale() - img.grayscale()).binarize(40)
        for x, y in positions:
            di.dl().circle((int(x), int(y)), 15, color=Color.RED, width=3)
        self.add_positions(ti, positions)

        fps = 1.0 / (time.time() - self.last_time)
        di.dl().ezViewText("{0:.3f} fps".format(fps), (0, 0))
        di.save(self.display)

        self.last_time = time.time()
        self.last_img = True

        if self.display.mouseLeft or self.display.mouseRight:
            self.display.done = True
            return False
        else:
            return True

    def finish(self):
        if self.display is not None:
            self.display.done = True
            self.display.quit()
开发者ID:DenerosArmy,项目名称:asterisk,代码行数:101,代码来源:fingertracker_peaks.py

示例5: Return

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
        else:
            origImg.sideBySide(snapshot).save(display)
            origImg.sideBySide(snapshot).save(imgStreamer)
    else:
        origImg.save(display)
        origImg.save(imgStreamer)

    # Take a snapshot and save it when you press Return (aka Enter)
    # Exit the display when you press Escape (for some reason, pressing the "X" to close the window doesn't work)
    # Run the Color Detection code when you press Space
    # Press Space again to end Color Detection code
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:           
            if event.key == pygame.K_RETURN:
                snapshot = cam.getImage()

                #Change this directory if needed
                snapshot.save('F:\stuff\img.png')
                
                snapshotTaken = True
                print 'Took snapshot'
            if event.key == pygame.K_ESCAPE:
                display.quit()
            if event.key == pygame.K_SPACE and snapshotTaken:
                print 'Image Processing initiated'
                if not doImageProcessing:
                        doImageProcessing = True
                else:
                        doImageProcessing = False

开发者ID:cal-roboops,项目名称:roboops,代码行数:31,代码来源:proj_ver2.py

示例6: Camera

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
                    rate=44100,
                    output=True)

    snapshotTime = time.time()
    # check if capture device is OK
    # Initialize the camera
    cam = Camera()
    print 'Camera : ', cam.getProperty("height"), cam.getProperty("width")
    print ' Startup time ', (time.time() - snapshotTime)*1000, ' ms'
    snapshotTime = time.time()

    try:
        img = cam.getImage()
        disp = Display(img.size(), title = "SimpleCellDemo, Draw the RF's bounding box with mouse")
        bb = getBBFromUser(cam, disp)
        disp.quit()
        disp = Display(img.size())
        disp = Display(img.size(), title = "SimpleCellDemo, Press Esc to exit")
        img, RF = do_RF(bb)
        while disp.isNotDone():
            snapshotTime = time.time()
            img, im = do_RF(bb)
            corr, Vm = neuron(im, voltage, hist)
            print corr, Vm
            backshotTime = time.time()
            fps = 1. / (backshotTime - snapshotTime)
            img.drawText("FPS:" + str(fps), 10, 10, fontsize=30, color=Color.GREEN)
            img.show()
        disp.quit()

    finally:
开发者ID:meduz,项目名称:SimpleCellDemo,代码行数:33,代码来源:SimpleReceptiveField.py

示例7: print

# 需要导入模块: from SimpleCV import Display [as 别名]
# 或者: from SimpleCV.Display import quit [as 别名]
    print (txt , 'click to continue')
    while d.isNotDone():
        if d.mouseLeft:
            d.done = True
        if d.mouseRight:
            #Gprb.append(Gfilename)
            rb = (d.rightButtonDownPosition())
            print(rb)
            if rb[1] < 15 and rb[1] > 0:
                 d.done = True
                 d.quit()
                 sys.exit(1)
                 pass
        time.sleep(.2) 

if  __name__ == '__main__':
    print ' rnum  module regression Test'
 #  Gd  = Display((1040,410))
    for tst in [Rtype]:      #'fat','wt', 'h2o', 
        img = Image(tst +'Test.png') 
        db = True #False  #True
        img.save(Gd)
        #cpause('test image',Gd)
        wt  = hunt(img,tst )     
        print  'result  is', wt 
        print 'iHunt',iHunt
##    print 'blob dictionary'
##    for k, v in d.iteritems():
##        print k, v
    Gd.quit()
开发者ID:charleswest,项目名称:Weight,代码行数:32,代码来源:rnum.py


注:本文中的SimpleCV.Display.quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。