phytopi/phytopi/models.py
2019-01-31 14:49:46 +01:00

45 lines
No EOL
1.7 KiB
Python

from datetime import datetime
from phytopi import db
class Dataset(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(64), index=True)
datetime_created = db.Column(db.DateTime, default=datetime.utcnow, )
images = db.relationship('Image', backref='dataset', lazy='dynamic')
def __repr__(self):
return '<Dataset {}>'.format(self.datetime_created)
def __index__(self):
return int(self.id)
class Image(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
filename = db.Column(db.String(128), index=True, unique=True)
datetime_created = datetime_created = db.Column(db.DateTime, default=datetime.utcnow)
dataset_id = db.Column(db.Integer, db.ForeignKey('dataset.id'))
def __repr__(self):
return '<Image {}>'.format(self.filename)
class CameraSettings(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(64), index=True, unique=True)
iso = db.Column(db.Integer, default=100)
fps = db.Column(db.Integer, default=5)
width = db.Column(db.Integer, default=3280)
height = db.Column(db.Integer, default=2464)
fix_shutter = db.Column(db.Boolean, default=False)
fix_wb = db.Column(db.Boolean, default=False)
def __init__(self, name, iso=100, fps=5, width=3280, height=2464, fix_shutter=False, fix_wb=False):
self.name = name
self.iso = iso
self.fps = fps
self.width = width
self.height = height
self.fix_shutter = fix_shutter
self.fix_wb = fix_wb
def __repr__(self):
return '<CameraSettings {}>'.format(self.name)