From 8dc3c9ac2c58eac24f1e0755d45f64c35864f71b Mon Sep 17 00:00:00 2001 From: Milo Date: Sat, 6 Apr 2019 22:45:01 +0200 Subject: [PATCH] fixed cam img strat again --- server/nightr/app.py | 1 - server/nightr/strategies/miloStrats.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/nightr/app.py b/server/nightr/app.py index b84d768..b7b4072 100644 --- a/server/nightr/app.py +++ b/server/nightr/app.py @@ -85,7 +85,6 @@ def probabilities(): # If this prediction disagrees with the consensus it contributed negatively if prediction["night"] != night: prediction["contribution"] *= -1 - return jsonify({ "predictions": predictions, "weighted_probabilities_mean": mean, diff --git a/server/nightr/strategies/miloStrats.py b/server/nightr/strategies/miloStrats.py index d0418f7..0b51e43 100644 --- a/server/nightr/strategies/miloStrats.py +++ b/server/nightr/strategies/miloStrats.py @@ -11,15 +11,18 @@ def camImgStrat(context : Context) -> Prediction: The contents of the camera image """ img = context.image - average = img.mean() + average = float(img.mean()) p = Prediction() - p.weight = 0.7 - if average < 100: - p.probability = 1.0 + p.weight = 1.0 + + p.probability = 1 - round((average/255),3) + if average < 128: + p.weight = round(1 - (average/255), 3) p.reasons.append('Image was dark') + else: + p.weight = round(average / 255, 3) p.reasons.append('Image was light') - p.probability = 0.0 return p @@ -45,7 +48,11 @@ def tv2newsStrat(context : Context) -> Prediction: """ The number of articles releases in the last few hours on TV2.dk """ + + print('before') r = requests.get('http://mpx.services.tv2.dk/api/latest') + print('after') + data = r.json() publish_dates = [(x['pubDate'])//1000 for x in data][:10] delta_times = []