Exemplo n.º 1
0
 def read(self):
     """Load exif data from disk."""
     self.exif      = ImageMetadata(self.filename)
     self.timestamp = None
     self.altitude  = None
     self.latitude  = None
     self.longitude = None
     self.timezone  = None
     self.manual    = False
     try:
         self.exif.read()
     except TypeError:
         raise IOError
     
     self.camera = get_camera(self)
     
     # Try to get a thumbnail.
     try:
         self.thumb = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 self.filename, self.thm_size, self.thm_size)
     except GObject.GError:
         if len(self.exif.previews) > 0:
             data = self.exif.previews[-1].data
         elif len(self.exif.exif_thumbnail.data) > 0:
             data = self.exif.exif_thumbnail.data
         else:
             raise IOError
         
         self.thumb = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
             Gio.MemoryInputStream.new_from_data(data, None),
             self.thm_size, self.thm_size, True, None)
     
     # If we're reloading, then hide the label and clear the ListStore,
     # but if we're loading afresh then we'll need a new iter...
     if self.label is not None:
         self.label.hide()
     if self.thm_size < 250:
         if self.iter is None:
             self.iter = self.liststore.append()
         self.liststore.set_row(self.iter,
             [self.filename, self.long_summary(), self.thumb, self.timestamp])
     
     self.calculate_timestamp()
     try:
         self.latitude = dms_to_decimal(
             *self.exif[GPS + 'Latitude'].value +
             [self.exif[GPS + 'LatitudeRef'].value]
         )
         self.longitude = dms_to_decimal(
             *self.exif[GPS + 'Longitude'].value +
             [self.exif[GPS + 'LongitudeRef'].value]
         )
     except KeyError:
         pass
     try:
         self.altitude = float(self.exif[GPS + 'Altitude'].value)
         if int(self.exif[GPS + 'AltitudeRef'].value) > 0:
             self.altitude *= -1
     except KeyError:
         pass
 def __init__(
     self: Detector,
     media: Optional[str],
     width: int,
     height: int,
     hflip: bool,
     vflip: bool,
     model_path: str,
     target: str,
     threshold: float,
     fontsize: int,
     fastforward: int
 ) -> None:
     if fastforward > 1:
         self.fastforward = fastforward
     else:
         self.fastforward = 1
     self.camera = get_camera(
         media=media,
         width=width,
         height=height,
         hflip=hflip,
         vflip=vflip,
         threshold=threshold,
         fontsize=fontsize,
         fastforward=self.fastforward
     )
     width, height = self.camera._dims
     self.predictor = get_predictor(
         model_path=model_path,
         target=target,
         threshold=threshold,
     )
     return
Exemplo n.º 3
0
def take_z_stack(
        name, step, n
):  #Take a Z-Stack-specify file name, step increments, number of images
    cam = camera.get_camera()
    m = motor.Motor()
    i = 0
    while i <= n * step:
        filename = name + str(i) + '.png'
        cam.capture(filename)
        m.steps(step)
        i += step
Exemplo n.º 4
0
    return parser

parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input-video', help="Input video", required=True)
parser.add_argument('-o', '--output-format', help="Output format", default="out%06d.png")
parser.add_argument('-c', '--camera-name', help="Camera name", required=True)
parser.add_argument('-r', '--rotate', help="Rotate input 90 degrees CCW n times", type=int, default=0)
parser.add_argument('-s', '--output-size', help="Size in pixels of output", type=make_tuple_parser(int, sep='x'), default=(500,1000))
parser.add_argument('-p', '--pixel-size', help="Metres per output pixel", type=float, default=0.02)
parser.add_argument('-H', '--camera-height', help="Camera height in metres", type=float, default=1.0)
parser.add_argument('-g', '--gravity-vector', help="Gravity vector", type=make_tuple_parser(float_parser), required=True)
parser.add_argument('--start-frame', help="Start frame", type=int, default=0)
parser.add_argument('--end-frame', help="End frame", type=int, default=-1)
args = parser.parse_args()

cam = camera.get_camera(args.camera_name)

# `camera_grav` is the direction of gravity in the camera's coordinate system.
camera_grav = numpy.matrix([list(args.gravity_vector)]).T
camera_grav[2,0] = -camera_grav[2,0]   # We want +Z to be in the direction of the camera
camera_grav = camera_grav / numpy.linalg.norm(camera_grav)

# `C` is the world-space to camera-space matrix.
# Choose `C` such that C * (0,-1,0).T = camera_grav, and C * (0,0,1).T is in the Y,Z plane.
C = numpy.matrix(numpy.zeros((3, 3)))
C[:,1] = -camera_grav
C[:,0] = numpy.matrix([[1.], [-C[0,1] / C[1,1]], [0]])
C[:,0] = C[:,0] / numpy.linalg.norm(C[:,0])
C[:,2] = numpy.matrix(numpy.cross(C[:,0].T, C[:,1].T).T)

# Make map_x and map_y to map output pixels to input pixels.
Exemplo n.º 5
0
from flask import Flask, request, stream_with_context, Response
from card import Card
from recorder import Recorder
from batcher import Batcher
import json
import camera
from live import genHeader
app = Flask(__name__)

_cam = camera.get_camera(0)
mixer = Card()
recorder = Recorder('Scarlett')
batcher = Batcher('./garden-sessions')


@app.route('/camera/feed')
def get_camera():
    def gen():
        while True:
            f = camera.get_frame(_cam)
            r = camera.fmt_frame(_cam)
            yield (r)

    return Response(gen(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')


@app.route('/cards')
def get_cards():
    cards = mixer.get_cards()
    json_cards = list(
Exemplo n.º 6
0
 def __init__(self):
     self._clients = []
     self._camera = get_camera()
Exemplo n.º 7
0
                    default=0.02)
parser.add_argument('-H',
                    '--camera-height',
                    help="Camera height in metres",
                    type=float,
                    default=1.0)
parser.add_argument('-g',
                    '--gravity-vector',
                    help="Gravity vector",
                    type=make_tuple_parser(float_parser),
                    required=True)
parser.add_argument('--start-frame', help="Start frame", type=int, default=0)
parser.add_argument('--end-frame', help="End frame", type=int, default=-1)
args = parser.parse_args()

cam = camera.get_camera(args.camera_name)

# `camera_grav` is the direction of gravity in the camera's coordinate system.
camera_grav = numpy.matrix([list(args.gravity_vector)]).T
camera_grav[
    2,
    0] = -camera_grav[2, 0]  # We want +Z to be in the direction of the camera
camera_grav = camera_grav / numpy.linalg.norm(camera_grav)

# `C` is the world-space to camera-space matrix.
# Choose `C` such that C * (0,-1,0).T = camera_grav, and C * (0,0,1).T is in the Y,Z plane.
C = numpy.matrix(numpy.zeros((3, 3)))
C[:, 1] = -camera_grav
C[:, 0] = numpy.matrix([[1.], [-C[0, 1] / C[1, 1]], [0]])
C[:, 0] = C[:, 0] / numpy.linalg.norm(C[:, 0])
C[:, 2] = numpy.matrix(numpy.cross(C[:, 0].T, C[:, 1].T).T)