forked from akkana/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
executable file
·58 lines (42 loc) · 1.67 KB
/
__init__.py
File metadata and controls
executable file
·58 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# Copyright 2014 by Akkana Peck: share and enjoy under the GPL v2 or later.
'''picamera: find and use cameras of various types.
A pycamera object will have the following methods:
__init__(verbose) # Set verbose to True for chatter on stdout
take_still(outfile=None)
# If outfile is not specified, a name will be
# assigned that incorporates the data and time.
# take_still's other arguments will vary
# with the capability of the camera library.
There may also be other routines, like take_video().
'''
__version__ = "0.1"
__author__ = "Akkana Peck <[email protected]>"
__license__ = "GPL v2"
__all__ = [ 'gphoto', "webcam", "piphoto" ]
# from . import *
import os
def has_webcamera():
return os.path.exists('/dev/video0')
def has_picamera():
# Regular Linux machines may have /dev/fb0,
# but the Pi doesn't seem to have it unless a pi cam is connected.
return os.uname()[4].startswith("arm") and os.path.exists('/dev/fb0')
from . import gphoto
def has_gphoto_camera():
return gphoto.has_camera()
def find_cameras(verbose=False):
'''Find the cameras connected to this machine, and return them
in order of quality. That means
try gphoto2 first, then webcam, then Pi camera.
'''
cameras = []
if has_gphoto_camera():
cameras.append(gphoto.Gphoto(verbose=verbose))
if has_webcamera():
from . import webcam
cameras.append(webcam.WebCam(verbose=verbose))
if has_picamera():
from . import piphoto
cameras.append(piphoto.PiCamera(verbose=verbose))
return cameras