Browse Source

update

old
Efe Aydın 6 years ago
parent
commit
7b2bb2514c
24 changed files with 149 additions and 8 deletions
  1. +57
    -0
      bus_stop/qr_reader/main.py
  2. +29
    -4
      client_side/interface/UserData/ratings.html
  3. +7
    -3
      client_side/interface/UserData/voting_results.html
  4. +1
    -1
      server_side/api/app.py
  5. +17
    -0
      server_side/api/modules/user_info.py
  6. BIN
      traffic_analyzer/3bug90h684ie.jpg
  7. BIN
      traffic_analyzer/5y0qqefgf8pm.jpg
  8. BIN
      traffic_analyzer/6xj0sv03e1rp.jpg
  9. BIN
      traffic_analyzer/7u38saf39803.jpg
  10. BIN
      traffic_analyzer/8giefz6t7blg.jpg
  11. BIN
      traffic_analyzer/9hbgjp8pr9ml.jpg
  12. BIN
      traffic_analyzer/bhcabz3ylbps.jpg
  13. BIN
      traffic_analyzer/bka4e0uyj819.jpg
  14. BIN
      traffic_analyzer/f6tjfpenclkn.jpg
  15. BIN
      traffic_analyzer/f8tjw066xd8k.jpg
  16. BIN
      traffic_analyzer/hcw6jsi4snvy.jpg
  17. BIN
      traffic_analyzer/iyh7h75p89qb.jpg
  18. BIN
      traffic_analyzer/jmv0qy8gh2hu.jpg
  19. BIN
      traffic_analyzer/lynlxwlxzovj.jpg
  20. BIN
      traffic_analyzer/q7xf4ijepqh0.jpg
  21. BIN
      traffic_analyzer/snpw5fj1pm5y.jpg
  22. +38
    -0
      traffic_analyzer/traffic.py
  23. BIN
      traffic_analyzer/tsrrxuybcpd8.jpg
  24. BIN
      traffic_analyzer/wau45wn0y7vr.jpg

+ 57
- 0
bus_stop/qr_reader/main.py View File

@ -0,0 +1,57 @@
from imutils.video import VideoStream
from pyzbar import pyzbar
import requests
import imutils
import cv2
vs = VideoStream().start()
dates = []
reps = 0
barcodes = None
prevcode = None
def main(host):
global vs
global dates
global reps
global barcodes
global prevcode
while True:
try:
while (barcodes == None or barcodes == []):
frame = vs.read()
frame = imutils.resize(frame, width=400)
barcodes = pyzbar.decode(frame)
cv2.imshow("Image", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
barcodes = pyzbar.decode(frame)
# loop over the detected barcodes
for barcode in barcodes:
(x, y, w, h) = barcode.rect
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if (barcodeData != prevcode):
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(frame, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
requests.post('https://' + host + '/reduce', data={'id': barcodeData, 'reduce': 2.5})
reps += 1
prevcode = barcodeData
barcodes = None
cv2.imshow("Image", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
except KeyboardInterrupt:
break
main(input('Host << '))
print("[INFO] cleaning up...")
cv2.destroyAllWindows()
vs.stop()

+ 29
- 4
client_side/interface/UserData/ratings.html View File

@ -4,8 +4,16 @@
<meta charset="UTF-8">
<title>Ratings</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="main" class="container">
<h1>Ratings</h1><br>
</div>
<br>
<div id="results" class="container">
</div>
<script>
$.get("https://127.0.0.1:5000/ratings", function(dataStr, status){
data = $.parseJSON(dataStr)
@ -16,8 +24,8 @@
a.appendChild(linkText);
a.title = element["name"];
a.href = "javascript:results(" + element["id"] + ");";
document.body.appendChild(a);
document.body.appendChild(document.createElement("br"));
document.getElementById("main").appendChild(a);
document.getElementById("main").appendChild(document.createElement("br"));
});
}
});
@ -28,13 +36,30 @@
if (status == "success") {
var results = document.getElementById("results")
results.innerHTML = '';
for (var key in data["rates"]) {
results.innerHTML += "<p>" + data["rates"][key]["note"] + "</p> " + data["rates"][key]["score"] + "/10 <br><br>"
var blockquote = document.createElement('blockquote');
blockquote.className = "blockquote text-right";
var text = document.createElement('p');
text.className = "mb-0";
text.innerHTML = data["rates"][key]["note"] + '<br>' + data["rates"][key]["score"] + '/10';
var by = document.createElement('footer');
by.className = "blockquote-footer";
$.get("https://127.0.0.1:5000/users/" + key, function(dataStr, status) {
data = $.parseJSON(dataStr)
by.innerHTML = data["realname"]
});
blockquote.appendChild(text);
blockquote.appendChild(by);
results.appendChild(blockquote);
}
}
});
}
</script>
<div id="results"></div>
</body>
</html>

+ 7
- 3
client_side/interface/UserData/voting_results.html View File

@ -5,11 +5,15 @@
<title>Voting Results</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="canvas-holder" style="width:40%">
<div class="row">
<div class="col-md-6">
<canvas id="voteResults"></canvas>
</div>
<div class="col-md-6" id="res"></div>
</div>
<br>
<script>
var ctx = document.getElementById('voteResults').getContext('2d');
@ -50,8 +54,8 @@
a.appendChild(linkText);
a.title = element["name"];
a.href = "javascript:graph(" + element["id"] + ");";
document.body.appendChild(a);
document.body.appendChild(document.createElement("br"));
document.getElementById("res").appendChild(a);
document.getElementById("res").appendChild(document.createElement("br"));
});
}
});


+ 1
- 1
server_side/api/app.py View File

@ -24,7 +24,7 @@ if __name__ == '__main__':
api.add_resource( user_info.Users, '/users', '/users/' )
api.add_resource( user_info.User, '/users/<path:user_id>', '/users/<path:user_id>/' )
api.add_resource( user_info.Login, '/login', '/login/' )
api.add_resource(user_info.ReducePoints, '/reduce', '/reduce/')
api.add_resource(utility.Resources, '/resources', '/resources/')


+ 17
- 0
server_side/api/modules/user_info.py View File

@ -84,6 +84,23 @@ class Login(Resource):
return [False, {}]
class ReducePoints(Resource):
def post(self):
user_id = request.form['id']
user = utils.find_by_id(users.values(), user_id)
if user:
username = ''
for k, v in users.items():
if user_id == v['id']:
username = k
users[username]['points'] -= request.form['reduce']
with open(db_path, 'w') as f:
json.dump(users, f, indent=4)
else:
abort(404, error="User {} doesn't exist".format(user_id))
if __name__ == '__main__':
api.add_resource(Users, '/users', '/users/')
api.add_resource(User, '/users/<path:user_id>', '/users/<path:user_id>/')


BIN
traffic_analyzer/3bug90h684ie.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 46 KiB

BIN
traffic_analyzer/5y0qqefgf8pm.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 55 KiB

BIN
traffic_analyzer/6xj0sv03e1rp.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 49 KiB

BIN
traffic_analyzer/7u38saf39803.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 48 KiB

BIN
traffic_analyzer/8giefz6t7blg.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 56 KiB

BIN
traffic_analyzer/9hbgjp8pr9ml.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 53 KiB

BIN
traffic_analyzer/bhcabz3ylbps.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 52 KiB

BIN
traffic_analyzer/bka4e0uyj819.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 54 KiB

BIN
traffic_analyzer/f6tjfpenclkn.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 53 KiB

BIN
traffic_analyzer/f8tjw066xd8k.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 56 KiB

BIN
traffic_analyzer/hcw6jsi4snvy.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 54 KiB

BIN
traffic_analyzer/iyh7h75p89qb.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 57 KiB

BIN
traffic_analyzer/jmv0qy8gh2hu.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 54 KiB

BIN
traffic_analyzer/lynlxwlxzovj.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 55 KiB

BIN
traffic_analyzer/q7xf4ijepqh0.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 55 KiB

BIN
traffic_analyzer/snpw5fj1pm5y.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 56 KiB

+ 38
- 0
traffic_analyzer/traffic.py View File

@ -0,0 +1,38 @@
import random, string
import numpy as np
import cv2
def generate_id(length=32):
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))
cap = cv2.VideoCapture(1)
cars = [
[(420, 375), (500, 480)],
[(505, 340), (590, 440)],
[(415, 240), (495, 330)],
[(485, 235), (550, 320)]
]
ambulance = [(250, 130), (400, 240)]
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
key = cv2.waitKey(1) & 0xFF
if key == ord('s'):
cv2.imwrite(generate_id(12) + ".jpg", frame[100:600, 240:600])
for i in cars:
cv2.rectangle(frame, *i, (0, 0, 255), 2)
cv2.rectangle(frame, *ambulance, (255, 0, 0), 2)
frame = frame[100:600, 240:600]
cv2.imshow('frame', frame)
if key == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

BIN
traffic_analyzer/tsrrxuybcpd8.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 54 KiB

BIN
traffic_analyzer/wau45wn0y7vr.jpg View File

Before After
Width: 360  |  Height: 380  |  Size: 56 KiB

Loading…
Cancel
Save