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


Python VideoCapture.Device类代码示例

本文整理汇总了Python中VideoCapture.Device的典型用法代码示例。如果您正苦于以下问题:Python Device类的具体用法?Python Device怎么用?Python Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: saveSnapshot

 def saveSnapshot(self):
     webcam_source = self.webcam_source
     if os.path.isdir(webcam_source):
         logger.debug('%s webcam choosing random image from "%s"' %
                      (self, webcam_source))
         from random import choice
         webcam_source = os.path.join(webcam_source,
                                      choice(os.listdir(webcam_source)))
     print webcam_source
     if is_file_image(webcam_source):
         logger.debug('Webcam %s returning mock image file "%s"' %
                      (self, webcam_source))
         return webcam_source
     snapshot_file = self.snapshot_file
     if not snapshot_file:
         snapshot_file = _get_tmp_filename()
         logger.debug('Using temporary file "%s"' % (snapshot_file))
     if WIN:
         try:
             cam = Device(int(self.webcam_source))
             cam.saveSnapshot(snapshot_file)
             time.sleep(1.0)
             cam.saveSnapshot(snapshot_file)
         except Exception:
             return ''
     elif LINUX:
         callargs = [self.webcam_source, '-v', 'v4l2src', '!',
                     'decodebin', '!', 'ffmpegcolorspace', '!', 'pngenc',
                     '!', 'filesink', 'location="%s"' % (snapshot_file)]
         if 0 != subprocess.call(callargs):
             return ''
     return snapshot_file
开发者ID:itamaro,项目名称:home-control-RPC,代码行数:32,代码来源:models.py

示例2: getImage

def getImage():
    if testImg == False:
        cam = Device()
        img = cam.getImage()
        img = array(img)
    else:
        img = cv2.imread('16.jpg',0)
        img = rotateImage(img, 270)
        # img = Image.open(str(testImg) + '.jpg')
        # img = img.rotate(270)

    # img = PIL.ImageOps.fit(img, (1500,3000))
    # img = PIL.ImageOps.solarize(img,128)
    # img = PIL.ImageOps.autocontrast(img)
    # img = PIL.ImageOps.grayscale(img)
    # img = PILa2rray(img)
    # img = cv2.medianBlur(img,5)
    # img = img.mean(img, -1)
    img = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, \
            cv2.THRESH_BINARY, 11, 3)

    if debugImage == True:
        pyplot.imshow(img)
        pyplot.show()

    return img
开发者ID:ssmoley,项目名称:QuizUpPlayer,代码行数:26,代码来源:Quizup.py

示例3: VCCamera

class VCCamera():

    ## __init__
    #
    # @param camera_num (Optional) The camera number, defaults to 0.
    # @param xmin (Optional) The x position of the start of the ROI, defaults to 0.
    # @param xmax (Optional) The x position of the end of the ROI, defaults to 150.
    # @param ymin (Optional) The y position of the start of the ROI, defaults to 0.
    # @param ymax (Optional) The y position of the end of the ROI, defaults to 300.
    #
    def __init__(self, camera_num = 0, xmin = 0, xmax = 150, ymin = 0, ymax = 300):
        self.xmin = xmin
        self.xmax = xmax
        self.ymin = ymin
        self.ymax = ymax
        self.cam = Device(devnum = camera_num)

    ## capture
    #
    # @return The current camera image as a numpy uint8 array.
    #
    def capture(self):
        # These do the same thing, but the second one is much faster..
        if 0:
            image = self.cam.getImage()
            data = numpy.array(image.getdata(), numpy.uint8).reshape(image.size[1], image.size[0], 3)
        if 1:
            buf = self.cam.getBuffer()
            x_size = buf[1]
            y_size = buf[2]
            data = numpy.fromstring(buf[0], numpy.uint8).reshape(y_size, x_size, 3)
            data = data[self.xmin:self.xmax,self.ymin:self.ymax]
        data = numpy.average(data, 2)
        return data
开发者ID:AlistairBoettiger,项目名称:storm-control,代码行数:34,代码来源:USBCamera.py

示例4: take_picture

def take_picture():
	# Start camera device
	cam = Device()

	# Some machines take longer to initialize the camera and so 
	# black images can occur if the module is loaded too quickly. 
	# We will keep taking images until the image is not completely
	# black.
	while True:
		img = cam.getImage()
		if not is_black(img):
			break
		
	# Get a quick image count in the directory
	image_count = len([fi for fi in os.listdir(SNAPSHOT_DIR) if re.search('.jpg$',fi)])
	if not image_count:
		location = '\\'.join([SNAPSHOT_DIR,'lolock']) + '.jpg'
	else:
		location = '\\'.join([SNAPSHOT_DIR,'lolock.'+str(image_count+1)]) + '.jpg'

	# Save image to disk
	img.save(location)

	# Unload device
	del(cam)

	# Send email if enabled
	if SEND_MAIL:
		send_email(location)
开发者ID:rickysaltzer,项目名称:lolock,代码行数:29,代码来源:video.py

示例5: capImage

 def capImage(self, name, resolution=(1280, 720)):
     logger.info("capture picture to %s", name)
     cam = Device()
     logger.debug("start camera")
     cam.setResolution(*resolution)
     cam.saveSnapshot(name)
     logger.debug("capture picture")
开发者ID:kbm1422,项目名称:New_Framework,代码行数:7,代码来源:webcam.py

示例6: __init__

	def __init__(self, **kwargs):
		super(TouchStream, self).__init__(**kwargs)
		self.cam1 = Device(devnum=0)
		self.cam2 = Device(devnum=1)

		# For using a different filename each time... not needed for now
		self.count = 0

		self.return_lines = []
开发者ID:taybenlor,项目名称:apothecarian,代码行数:9,代码来源:touch.py

示例7: videoCaptureStart

def videoCaptureStart(fromIP):
    cam = Device()
    buffers,width,height = cam.getBuffer()
    packData(buffers[0:MESSAGE_SIZE], 5, fromIP)
    packData(buffers[MESSAGE_SIZE:], 6, fromIP)
    while conversationWindow[fromIP]['VIDEO_CAPTURE_FLAG']:
        buffers,width,height = cam.getBuffer()
        packData(buffers[0:MESSAGE_SIZE], 7, fromIP)
        packData(buffers[MESSAGE_SIZE:], 6, fromIP)
    packData(buffers, 8, fromIP)
开发者ID:sid093,项目名称:python_chat,代码行数:10,代码来源:client.py

示例8: main

def main(s_time=5):
    path1 = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")+'.jpg'
    cam = Device()
    time.sleep(2)
    path2 = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")+'.jpg'
    cam.saveSnapshot(path1)
    for i in range(10):
        time.sleep(s_time)
        cam.saveSnapshot(path2)
        if calc_similar_by_path(path1,path2)<0.8:
            path1 = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")+'.jpg'
        tmp = path2
        path2 = path1
        path1 = tmp
    del cam
开发者ID:wujianguo,项目名称:tools,代码行数:15,代码来源:remote.py

示例9: main

def main():
	cam = Device(devnum=0)
	print "press 'ctrl + c' to terminate"	
	i = 0
	quant = interval * .1
	starttime = time.time()
	while 1:
	    lasttime = now = int((time.time() - starttime) / interval)
	    vs = current_datetime_str()
	    print i,'|',vs
	    cam.saveSnapshot('photos/ssc%s.jpg' %vs, timestamp=3, boldfont=1)
	    i += 1
	    while now == lasttime:
	        now = int((time.time() - starttime) / interval)
	        time.sleep(quant)
开发者ID:ArathoN,项目名称:learning-python,代码行数:15,代码来源:exa3_observer.py

示例10: do_cam

def do_cam():
    L = []
    i = 0
    cam = Device()
    thread.start_new_thread(input_thread, (L,))
    while 1:
        time.sleep(waitTime)
        i = i + 1
        istr = str(i)

        cam.saveSnapshot("imgs/" + istr + ".png")
        print "saved" + istr
        if L:
            main()
            break
开发者ID:ilbonte,项目名称:screenlapse,代码行数:15,代码来源:main.py

示例11: Webcam

class Webcam():
    def __init__(self, webcam_name=None, webcam_id=None, **kargs):
        self.device = None
        print 'Webcam\t__init__ called with webcam_name=%s and webcam_id=%s' % (webcam_name, webcam_id)
        if webcam_name is not None:
            self.connect(device_name=webcam_name)
        elif webcam_id is not None:
            self.connect(device_number=webcam_id)
    
    def options(self, device_name=None, device_number=None):
        # I doubt people will have more than 5 webcams plugged in
        print 'Webcam\toptions() called'
        opts = []
        for i in range(2):
            try:
                print 'Webcam\toptions - attempting to connect to %s' % i
                d = Device(devnum=i)
                if device_name is not None and device_name == d.getDisplayName():
                    del self.device
                    self.device = d
                elif device_number is not None and device_number == i:
                    del self.device
                    self.device = d
                opts.append((i, d.getDisplayName()))
                del d
            except:
                pass
        print 'Webcam\toptions() returning %s' % opts
        return opts
    
    def connect(self, device_name=None, device_number=None):
        if device_name is not None:
            self.options(device_name=device_name)
        elif device_number is not None:
            self.options(device_number=device_number)
        else:
            self.device = Device()
    
    def disconnect(self):
        del self.device
        self.device = None 
    
    def savePicture(self, path, iterations=15):
        for i in range(iterations):
            self.device.saveSnapshot(path)

    def connected(self):
        return (self.device != None)
开发者ID:brendan-esda,项目名称:Project-Gado,代码行数:48,代码来源:Webcam.py

示例12: Webcam

class Webcam(object):
    def __init__(self, app, interval=0.5, log_interval=0.5):
        self.app = app

        self.interval = interval
        self.log_interval = log_interval
        self.last_log = 0.0
        self.jpeg_data = None

        self.cam = None
        try:
            from VideoCapture import Device
            # NOTE: must initialize this from the main thread, it seems
            self.cam = Device()
            # ???
            self.cam.getImage()
        except:
            import traceback
            traceback.print_exc()
            log.warn('webcam failed to initialize')

    def get_image(self):
        return self.jpeg_data

    def tick(self):
        file = StringIO()
        image = self.cam.getImage(1)
        image.save(file, 'jpeg')
        self.jpeg_data = file.getvalue()

        now = time.time()
        if self.log_interval and self.last_log+self.log_interval < now:
            self.last_log = now
            fname = 'logs/webcam/cam.%s.jpg' % \
                time.strftime('%Y-%m-%d.%H.%M.%S')
            open(fname, 'wb').write(self.jpeg_data)

        time.sleep(self.interval)

    def start(self):
        if not self.cam:
            return
        def loop():
            while 1:
                self.tick()
        thread = threading.Thread(target=loop)
        thread.daemon = True
        thread.start()
开发者ID:Acidburn0zzz,项目名称:carhack,代码行数:48,代码来源:webcam.py

示例13: camera_capture

def camera_capture():
    #抓取频率
    SLEEP_TIME=3
    i=0
    cam=Device(devnum=0, showVideoWindow=0)
    while i<10:

        cam_time=time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
        cam_name='camera'+cam_time+'.jpg'

        cam.saveSnapshot(cam_name,3,1,'bl')
        camera_upload(cam_name)
        print str(i)+cam_name
        os.remove(cam_name)
        time.sleep(SLEEP_TIME)
        i+=1
开发者ID:wangjiachuan,项目名称:csv,代码行数:16,代码来源:camera_ctl.py

示例14: connect

 def connect(self, device_name=None, device_number=None):
     if device_name is not None:
         self.options(device_name=device_name)
     elif device_number is not None:
         self.options(device_number=device_number)
     else:
         self.device = Device()
开发者ID:brendan-esda,项目名称:Project-Gado,代码行数:7,代码来源:Webcam.py

示例15: __init__

    def __init__(self, root):
        self.root=root
        self.root.wm_title("Video Chatting: Coded by Rogue")
        self.root.protocol('WM_DELETE_WINDOW', self.safeExit)

        self.sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

        self.cam=Device()
        self.photo=ImageTk.PhotoImage(self.cam.getImage())

        p = pyaudio.PyAudio()
        self.audStream = p.open(format = self.FORMAT,
                        channels = self.CHANNELS,
                        rate = self.RATE,
                        input = True,
                        output = True,
                        frames_per_buffer = self.chunk)
        self.design()
        t1=threading.Thread(target=self.sndData)
        t2=threading.Thread(target=self.recvData)
        t3=threading.Thread(target=self.showMe)
        t4=threading.Thread(target=self.callrecv)
        t1.daemon=True
        t2.daemon=True
        t3.daemon=True
        t4.daemon=True
        t1.start()
        t2.start()
        t3.start()
        t4.start()
开发者ID:himanshu-shekhar,项目名称:VideoChat,代码行数:30,代码来源:videoChat.py


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