implemented context-prediction interface in milostrats

This commit is contained in:
Mikkel Milo 2019-04-06 13:52:25 +02:00
parent 31012f4216
commit 33edbcc743

View File

@ -1,24 +1,31 @@
import cv2
from datetime import datetime, timedelta
from pytz import timezone
from server.nightr.util import Context, Prediction
def camImgStrat():
def camImgStrat(context : Context) -> Prediction:
img = cv2.imread('night.jpg',0)
average = img.mean(axis=0).mean(axis=0)
print(average)
p = Prediction()
if average < 100:
return 1.0
p.probability = 1.0
p.reasons.append('Image was dark')
else:
return 0.0
p.reasons.append('Image was light')
p.probability = 0.0
return p
def australiaStrat():
def australiaStrat(context : Context) -> Prediction:
australia = timezone('Australia/Melbourne')
t = datetime.now().astimezone(australia)
hour = t.hour
p = Prediction()
if hour > 22 or hour < 6:
return 1.0
p.probability = 1.0
p.reasons.append('It\'s day-time in Australia')
else:
return 0.0
p.probability = 0.0
p.reasons.append('It\'s night-time in Australia')
return p