Compare commits

...

No commits in common. 'master' and 'efe' have entirely different histories.
master ... efe

106 changed files with 271925 additions and 174210 deletions
Split View
  1. +35
    -22
      Ev3/main.py
  2. +0
    -1
      MyCity/README.md
  3. +14
    -0
      MyCity/gradle.properties
  4. +6
    -0
      MyCity/gradle/wrapper/gradle-wrapper.properties
  5. +0
    -1
      README.md
  6. +9
    -0
      bus_stop/bus_stop.iml
  7. +1
    -1
      client_side/app.py
  8. +9
    -0
      client_side/client_side.iml
  9. +37
    -0
      client_side/modules/qr/reader.py
  10. +24
    -45
      client_side/modules/qr/user_data.py
  11. +3
    -3
      master_app/nbactions.xml
  12. +141
    -293
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
  13. +332
    -382
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
  14. BIN
      master_app/src/main/java/me/yigitcolakoglu/master_app/thermometer.png
  15. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class
  16. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class
  17. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class
  18. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class
  19. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class
  20. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$6.class
  21. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$7.class
  22. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$8.class
  23. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$9.class
  24. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class
  25. +5
    -0
      master_app/target/maven-archiver/pom.properties
  26. +7
    -25
      server_side/api/ai_services.py
  27. +2
    -1
      server_side/api/app.py
  28. +3
    -3
      server_side/api/modules/SpotSelector.py
  29. +38
    -38
      server_side/api/modules/car_crash.py
  30. +6
    -6
      server_side/api/modules/complaint.py
  31. +47
    -6
      server_side/api/modules/databases/complaints.json
  32. +33
    -12
      server_side/api/modules/databases/locations.json
  33. +270901
    -172801
      server_side/api/modules/databases/park_data.json
  34. +149
    -298
      server_side/api/modules/databases/users.json
  35. +1
    -1
      server_side/api/modules/smart_park.py
  36. +0
    -162
      server_side/api/modules/smart_park.py.save
  37. +10
    -8
      server_side/api/modules/user_set.py
  38. +1
    -1
      server_side/api/object_detection/core/preprocessor.py
  39. +1
    -1
      server_side/api/object_detection/object_detection_tutorial.ipynb
  40. +1
    -1
      server_side/api/object_detection/protos/anchor_generator_pb2.py
  41. +1
    -1
      server_side/api/object_detection/protos/argmax_matcher_pb2.py
  42. +1
    -1
      server_side/api/object_detection/protos/bipartite_matcher_pb2.py
  43. +1
    -1
      server_side/api/object_detection/protos/box_coder_pb2.py
  44. +1
    -1
      server_side/api/object_detection/protos/box_predictor_pb2.py
  45. +1
    -1
      server_side/api/object_detection/protos/calibration_pb2.py
  46. +1
    -1
      server_side/api/object_detection/protos/eval_pb2.py
  47. +1
    -1
      server_side/api/object_detection/protos/faster_rcnn_box_coder_pb2.py
  48. +1
    -1
      server_side/api/object_detection/protos/faster_rcnn_pb2.py
  49. +1
    -1
      server_side/api/object_detection/protos/flexible_grid_anchor_generator_pb2.py
  50. +1
    -1
      server_side/api/object_detection/protos/graph_rewriter_pb2.py
  51. +1
    -1
      server_side/api/object_detection/protos/grid_anchor_generator_pb2.py
  52. +1
    -1
      server_side/api/object_detection/protos/hyperparams_pb2.py
  53. +1
    -1
      server_side/api/object_detection/protos/image_resizer_pb2.py
  54. +1
    -1
      server_side/api/object_detection/protos/input_reader_pb2.py
  55. +1
    -1
      server_side/api/object_detection/protos/keypoint_box_coder_pb2.py
  56. +1
    -1
      server_side/api/object_detection/protos/losses_pb2.py
  57. +1
    -1
      server_side/api/object_detection/protos/matcher_pb2.py
  58. +1
    -1
      server_side/api/object_detection/protos/mean_stddev_box_coder_pb2.py
  59. +1
    -1
      server_side/api/object_detection/protos/model_pb2.py
  60. +1
    -1
      server_side/api/object_detection/protos/multiscale_anchor_generator_pb2.py
  61. +1
    -1
      server_side/api/object_detection/protos/optimizer_pb2.py
  62. +1
    -1
      server_side/api/object_detection/protos/pipeline_pb2.py
  63. +1
    -1
      server_side/api/object_detection/protos/post_processing_pb2.py
  64. +1
    -1
      server_side/api/object_detection/protos/preprocessor_pb2.py
  65. +1
    -1
      server_side/api/object_detection/protos/region_similarity_calculator_pb2.py
  66. +1
    -1
      server_side/api/object_detection/protos/square_box_coder_pb2.py
  67. +1
    -1
      server_side/api/object_detection/protos/ssd_anchor_generator_pb2.py
  68. +1
    -1
      server_side/api/object_detection/protos/ssd_pb2.py
  69. +1
    -1
      server_side/api/object_detection/protos/string_int_label_map_pb2.py
  70. +1
    -1
      server_side/api/object_detection/protos/train_pb2.py
  71. +26
    -30
      traffic_analyzer/ambulance_detect.py
  72. +8
    -5
      traffic_analyzer/ml_setup.py
  73. +1
    -1
      traffic_analyzer/object_detection/.ipynb_checkpoints/object_detection_tutorial-checkpoint.ipynb
  74. +1
    -1
      traffic_analyzer/object_detection/core/preprocessor.py
  75. +1
    -1
      traffic_analyzer/object_detection/object_detection_tutorial.ipynb
  76. +1
    -1
      traffic_analyzer/object_detection/protos/anchor_generator_pb2.py
  77. +1
    -1
      traffic_analyzer/object_detection/protos/argmax_matcher_pb2.py
  78. +1
    -1
      traffic_analyzer/object_detection/protos/bipartite_matcher_pb2.py
  79. +1
    -1
      traffic_analyzer/object_detection/protos/box_coder_pb2.py
  80. +1
    -1
      traffic_analyzer/object_detection/protos/box_predictor_pb2.py
  81. +1
    -1
      traffic_analyzer/object_detection/protos/calibration_pb2.py
  82. +1
    -1
      traffic_analyzer/object_detection/protos/eval_pb2.py
  83. +1
    -1
      traffic_analyzer/object_detection/protos/faster_rcnn_box_coder_pb2.py
  84. +1
    -1
      traffic_analyzer/object_detection/protos/faster_rcnn_pb2.py
  85. +1
    -1
      traffic_analyzer/object_detection/protos/graph_rewriter_pb2.py
  86. +1
    -1
      traffic_analyzer/object_detection/protos/grid_anchor_generator_pb2.py
  87. +1
    -1
      traffic_analyzer/object_detection/protos/hyperparams_pb2.py
  88. +1
    -1
      traffic_analyzer/object_detection/protos/image_resizer_pb2.py
  89. +1
    -1
      traffic_analyzer/object_detection/protos/input_reader_pb2.py
  90. +1
    -1
      traffic_analyzer/object_detection/protos/keypoint_box_coder_pb2.py
  91. +1
    -1
      traffic_analyzer/object_detection/protos/losses_pb2.py
  92. +1
    -1
      traffic_analyzer/object_detection/protos/matcher_pb2.py
  93. +1
    -1
      traffic_analyzer/object_detection/protos/mean_stddev_box_coder_pb2.py
  94. +1
    -1
      traffic_analyzer/object_detection/protos/model_pb2.py
  95. +1
    -1
      traffic_analyzer/object_detection/protos/multiscale_anchor_generator_pb2.py
  96. +1
    -1
      traffic_analyzer/object_detection/protos/optimizer_pb2.py
  97. +1
    -1
      traffic_analyzer/object_detection/protos/pipeline_pb2.py
  98. +1
    -1
      traffic_analyzer/object_detection/protos/post_processing_pb2.py
  99. +1
    -1
      traffic_analyzer/object_detection/protos/preprocessor_pb2.py
  100. +1
    -1
      traffic_analyzer/object_detection/protos/region_similarity_calculator_pb2.py

+ 35
- 22
Ev3/main.py View File

@ -11,16 +11,18 @@ import json
print("[INFO]: Imported json")
state = True
moving = False
motor1 = ev3.LargeMotor("outA")
motor2 = ev3.LargeMotor("outD")
cam = ev3.MediumMotor('outB')
def move(speed):
if time:
motor1.run_forever(speed_sp=speed)
motor2.run_forever(speed_sp=speed)
cam.run_to_abs_pos(position_sp=0, speed_sp=500)
moving = True
motor1.run_forever(speed_sp=speed)
motor2.run_forever(speed_sp=speed)
cam.run_to_abs_pos(position_sp=0, speed_sp=500)
def stop():
moving = False
motor1.stop()
motor2.stop()
cam.stop()
@ -30,7 +32,7 @@ PORT = 3131
pid=os.fork()
if pid==0: # new process
mjpeg_loc = "/home/robot/mjpg-streamer/"
os.system('{0}mjpg_streamer -i "{0}input_uvc.so -f 15 -y" -o "{0}output_http.so -w {0}www"'.format(mjpeg_loc))
os.system('{0}mjpg_streamer -i "{0}input_uvc.so -f 5" -o "{0}output_http.so -w {0}www"'.format(mjpeg_loc))
exit()
power = PowerSupply()
if power.measured_volts < 7.1:
@ -46,37 +48,48 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
conn, addr = s.accept()
with conn:
print('[INFO]: Connected by', addr)
move(500)
while True:
if cam.speed == 0 and (motor1.speed > 0 and motor2.speed > 0):
if cam.speed == 0 and moving:
if state:
cam.run_to_abs_pos(position_sp=4000, speed_sp=500)
else:
cam.run_to_abs_pos(position_sp=0, speed_sp=500)
state = not state
try:
received = conn.recv(1024)
if not received:
raise BrokenPipeError("Client disconnect")
recieved = conn.recv(1024)
if not recieved:
raise BrokenPipeError
else:
received = received.decode().strip()[-1]
print(received)
if received == 's':
recieved = recieved.decode().strip()[-1]
print(recieved)
if recieved == 's':
stop()
elif received == 'm':
move(500)
elif received == 'i':
elif recieved == 'm':
move(200)
elif recieved == 'i':
data = {
"battery_voltage":str(round(power.measured_volts,1)),
"current_drawn":str(round(power.measured_amps,1)),
"lat":"31",
"lng":"39"
"battery_voltage":power.measured_volts,
"current_drawn":power.measured_amps,
"lat":31,
"lng":39
}
conn.send((json.dumps(data, ensure_ascii=False)+"\n").encode('gbk'))
elif recieved == '+':
cam.run_timed(time_sp=50, speed_sp=750)
cam.run_timed(time_sp=100, speed_sp=750)
elif recieved == '-':
cam.run_timed(time_sp=50, speed_sp=-750)
cam.run_timed(time_sp=100, speed_sp=-750)
elif recieved == 'f':
stop()
motor1.run_forever(speed_sp=400)
motor2.run_forever(speed_sp=400)
elif recieved == 'b':
stop()
motor1.run_forever(speed_sp=-400)
motor2.run_forever(speed_sp=-400)
elif recieved == 'l':
motor1.run_forever(speed_sp=400)
elif recieved == 'r':
motor2.run_forever(speed_sp=400)
except BrokenPipeError:
print("[INFO]: Client disconnected")


+ 0
- 1
MyCity/README.md View File

@ -1 +0,0 @@
MyCity

+ 14
- 0
MyCity/gradle.properties View File

@ -0,0 +1,14 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
GOOGLE_MAPS_API_KEY=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

+ 6
- 0
MyCity/gradle/wrapper/gradle-wrapper.properties View File

@ -0,0 +1,6 @@
#Wed Mar 13 09:22:39 EET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

+ 0
- 1
README.md View File

@ -1,2 +1 @@
Smart_Management
https://pastebin.com/XKGWpYQK

+ 9
- 0
bus_stop/bus_stop.iml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 1
- 1
client_side/app.py View File

@ -80,4 +80,4 @@ def send_img(path):
return send_from_directory('interface/UserData', path)
if __name__ == '__main__':
socketio.run(app,host="0.0.0.0",port=4000,debug=True)
socketio.run(app,port=4000,debug=True)

+ 9
- 0
client_side/client_side.iml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 37
- 0
client_side/modules/qr/reader.py View File

@ -0,0 +1,37 @@
import cv2
from pyzbar import pyzbar
class Read():
instance = 0
sid = 0
def __init__(self,inst):
self.instance = inst
def detect(self):
cam = cv2.VideoCapture(0)
barcodeData_prev = 0
while 1:
ret , img = cam.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyzbar.decode(gray)
if len(barcode) > 0:
barcode = barcode[0]
(x, y, w, h) = barcode.rect
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if barcodeData_prev == 0 or barcodeData_prev != barcodeData:
barcodeData_prev = barcodeData
self.instance.received(barcodeData)
continue
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(img, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 0), 2)
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
cv2.imshow("a", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cam.release()
cv2.destroyAllWindows()

+ 24
- 45
client_side/modules/qr/user_data.py View File

@ -1,64 +1,43 @@
from flask import Flask, jsonify, request, abort,Response
from multiprocessing import Process
from PIL import Image
from io import BytesIO
from imutils.video import VideoStream
import requests
import cv2
import pickle
import base64
import reader
import json
from pyzbar import pyzbar
import subprocess
import urllib3
import imutils
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
app = Flask(__name__)
user = {}
image = None
def im2str(im):
crop_img = Image.fromarray(im, "RGB")
buffered = BytesIO()
crop_img.save(buffered, format="JPEG")
img = base64.b64encode(buffered.getvalue()).decode("ascii")
return img
class Reader():
def __init__(self):
read = reader.Read(self)
p1 = Process(target=read.detect)
p1.start()
def received(self, data):
r = requests.get('https://0.0.0.0:5000/users/{}'.format(data), verify=False)
requests.get('http://0.0.0.0:3000/set', data={'data': r.text})
vs=VideoStream().start()
barcodeData_prev = 0
qr_reader = Reader()
@app.route('/set')
def set_data():
global user
user = json.loads(request.form['data'])
resp = Response("OK")
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
@app.route('/get')
def get_qr():
global user
global image
global barcodeData_prev
if user == {}:
abort(404)
frame = vs.read()
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
barcode = pyzbar.decode(gray)
if len(barcode) > 0:
barcode = barcode[0]
(x, y, w, h) = barcode.rect
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
if barcodeData_prev == 0 or barcodeData_prev != barcodeData:
barcodeData_prev = barcodeData
r = requests.get('https://192.168.2.203:5000/users/{}'.format(barcodeData), verify=False)
user = json.loads(r.text)
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(img, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 0, 0), 2)
cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
else:
user = {}
result = subprocess.check_output(['vcgencmd', 'measure_temp'])
temp = result.split("=")[1][:-2] +"C"
image = im2str(img)
resp = Response(json.dumps({"user":user,"img":image,"temp":temp}))
resp = Response(json.dumps(user))
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp


+ 3
- 3
master_app/nbactions.xml View File

@ -12,7 +12,7 @@
<properties>
<exec.args>-classpath %classpath me.yigitcolakoglu.master_app.Main ips.json</exec.args>
<exec.executable>java</exec.executable>
<exec.workingdir>/home/tedankara/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
<exec.workingdir>/home/colakoglu/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
</properties>
</action>
<action>
@ -28,7 +28,7 @@
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName} ips.json</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
<exec.workingdir>/home/tedankara/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
<exec.workingdir>/home/colakoglu/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
</properties>
</action>
<action>
@ -43,7 +43,7 @@
<properties>
<exec.args>-classpath %classpath ${packageClassName} ips.json</exec.args>
<exec.executable>java</exec.executable>
<exec.workingdir>/home/tedankara/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
<exec.workingdir>/home/colakoglu/Downloads/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
</properties>
</action>
</actions>

+ 141
- 293
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form View File

@ -91,42 +91,40 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
<Component id="intersection_label" min="-2" pref="1024" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="286" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="302" max="-2" attributes="0"/>
<Component id="fps_label" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="ambulance_label" min="-2" pref="333" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="75" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="ambulance_label" min="-2" pref="440" max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="31" max="32767" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="intersection_label" min="-2" pref="576" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="intersection_label" alignment="0" min="-2" pref="768" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="ambulance_label" min="-2" pref="333" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="fps_label" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="71" max="32767" attributes="0"/>
<EmptySpace pref="19" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -163,52 +161,47 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="68" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="cpu_usage" min="-2" max="-2" attributes="0"/>
<Component id="ram_usage" min="-2" max="-2" attributes="0"/>
<Component id="gpu_usage" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="cpu_usage" min="-2" max="-2" attributes="0"/>
<Component id="ram_usage" min="-2" max="-2" attributes="0"/>
<Component id="gpu_usage" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="ram_temp" min="-2" max="-2" attributes="0"/>
<Component id="cpu_temp" min="-2" max="-2" attributes="0"/>
<Component id="gpu_temp" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="ram_temp" min="-2" max="-2" attributes="0"/>
<Component id="cpu_temp" min="-2" max="-2" attributes="0"/>
<Component id="gpu_temp" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="fan_rpm" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="118" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="fan_rpm" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="118" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="44" max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -238,19 +231,16 @@
<Component id="gpu_temp" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
<Component id="fan_rpm" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="26" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -321,14 +311,6 @@
<Property name="text" type="java.lang.String" value="1000RPM"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="2" name="/home/tedankara/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Fan"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
@ -349,24 +331,44 @@
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="robot_cam_label" min="-2" pref="576" max="-2" attributes="0"/>
<EmptySpace pref="231" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="battery_voltage_label" min="-2" max="-2" attributes="0"/>
<Component id="current_drawn_label" min="-2" max="-2" attributes="0"/>
<Component id="longitude_label" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="latitude_label" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="278" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Component id="move_robot" min="-2" max="-2" attributes="0"/>
<Component id="robot_stop" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="battery_voltage_label" min="-2" max="-2" attributes="0"/>
<Component id="current_drawn_label" min="-2" max="-2" attributes="0"/>
<Component id="longitude_label" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="latitude_label" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="278" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Component id="move_robot" min="-2" max="-2" attributes="0"/>
<Component id="robot_stop" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="ai_checkbox" min="-2" max="-2" attributes="0"/>
<Component id="cam_slider" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="204" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="cam_slider" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="forward_button" max="32767" attributes="0"/>
<Component id="back_button" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="453" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="left_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<Component id="right_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="393" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="204" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -398,9 +400,20 @@
<Component id="cam_slider" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="ai_checkbox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="121" max="-2" attributes="0"/>
<Component id="forward_button" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="right_button" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="left_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Component id="back_button" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -440,7 +453,6 @@
<Property name="text" type="java.lang.String" value="Stop Robot"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="robot_stopMousePressed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="robot_stopActionPerformed"/>
</Events>
</Component>
@ -449,7 +461,6 @@
<Property name="text" type="java.lang.String" value="Move Robot"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="move_robotMousePressed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="move_robotActionPerformed"/>
</Events>
</Component>
@ -458,6 +469,47 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="cam_sliderStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="ai_checkbox">
<Properties>
<Property name="text" type="java.lang.String" value="Send to AI"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="forward_button">
<Properties>
<Property name="text" type="java.lang.String" value="&#x2227;"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="forward_buttonMousePressed"/>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="forward_buttonMouseReleased"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="back_button">
<Properties>
<Property name="text" type="java.lang.String" value="&#x2228;"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="back_buttonMousePressed"/>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="back_buttonMouseReleased"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="right_button">
<Properties>
<Property name="text" type="java.lang.String" value="&gt;"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="right_buttonMousePressed"/>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="right_buttonMouseReleased"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="left_button">
<Properties>
<Property name="text" type="java.lang.String" value="&lt;"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="left_buttonMousePressed"/>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="left_buttonMouseReleased"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6">
@ -698,219 +750,15 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="qr_label" min="-2" pref="720" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="143" max="-2" attributes="0"/>
<Component id="rpi_temp" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="83" max="-2" attributes="0"/>
<Component id="jPanel9" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="48" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="1622" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="qr_label" min="-2" pref="720" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jPanel9" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="83" max="-2" attributes="0"/>
<Component id="rpi_temp" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="63" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="816" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="qr_label">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/>
</Border>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel9">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Component id="user_pic" min="-2" pref="307" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="name_label" min="-2" pref="165" max="-2" attributes="0"/>
<Component id="tc_label" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<Component id="jLabel12" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="phone_label" min="-2" max="-2" attributes="0"/>
<Component id="mail_label" min="-2" max="-2" attributes="0"/>
<Component id="plate_label" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="trust_label" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="161" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="name_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tc_label" alignment="3" min="-2" pref="15" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="mail_label" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="phone_label" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="plate_label" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="trust_label" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="user_pic" min="-2" pref="307" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="18" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="user_pic">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/>
</Border>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="name_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="text" type="java.lang.String" value="TC:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="text" type="java.lang.String" value="E-Mail:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="Phone:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="text" type="java.lang.String" value="License:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="Trust:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="tc_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel14"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="mail_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="phone_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="plate_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="trust_label">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel8"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="rpi_temp">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="24" style="1"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="2" name="/home/tedankara/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/thermometer.png"/>
</Property>
<Property name="text" type="java.lang.String" value="30 &#xb0;C"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>


+ 332
- 382
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java View File

@ -5,6 +5,9 @@
*/
package me.yigitcolakoglu.master_app;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.io.*;
import java.net.*;
import java.awt.Graphics2D;
@ -28,6 +31,7 @@ import java.security.cert.*;
import java.security.*;
import javax.net.ssl.*;
import javax.swing.JSlider;
import org.json.JSONArray;
/**
*
@ -45,11 +49,10 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
private ServerSocket server;
private Socket client;
private Thread running = null;
private Thread moverThread = null;
private boolean listening = false;
private String ROBOT_IP = "10.42.0.9";
private String QR_IP = "192.168.2.166";
private String LIGHT_IP = "192.168.2.174";
private String AI_IP = "127.0.0.1";
private String AI_IP = "10.10.26.161";
private Socket robotSocket;
private DataOutputStream out;
private BufferedReader in;
@ -83,7 +86,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
gpu_temp = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
fan_rpm = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
robot_cam_label = new javax.swing.JLabel();
battery_voltage_label = new javax.swing.JLabel();
@ -93,6 +95,11 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
robot_stop = new javax.swing.JButton();
move_robot = new javax.swing.JButton();
cam_slider = new javax.swing.JSlider();
ai_checkbox = new javax.swing.JCheckBox();
forward_button = new javax.swing.JButton();
back_button = new javax.swing.JButton();
right_button = new javax.swing.JButton();
left_button = new javax.swing.JButton();
jPanel6 = new javax.swing.JPanel();
light_1_label = new javax.swing.JLabel();
light_2_label = new javax.swing.JLabel();
@ -106,22 +113,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
intersection_2_G = new javax.swing.JLabel();
intersection_2_R = new javax.swing.JLabel();
jPanel8 = new javax.swing.JPanel();
qr_label = new javax.swing.JLabel();
jPanel9 = new javax.swing.JPanel();
user_pic = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
name_label = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
tc_label = new javax.swing.JLabel();
mail_label = new javax.swing.JLabel();
phone_label = new javax.swing.JLabel();
plate_label = new javax.swing.JLabel();
trust_label = new javax.swing.JLabel();
rpi_temp = new javax.swing.JLabel();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@ -183,48 +174,42 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
fan_rpm.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N
fan_rpm.setText("1000RPM");
jLabel8.setIcon(new javax.swing.ImageIcon("/home/tedankara/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png")); // NOI18N
jLabel8.setText("Fan");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel6)
.addGap(24, 24, 24)
.addGap(68, 68, 68)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel8)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(9, 9, 9)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(cpu_usage)
.addComponent(ram_usage)
.addComponent(gpu_usage))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(cpu_usage)
.addComponent(ram_usage)
.addComponent(gpu_usage))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ram_temp)
.addComponent(cpu_temp)
.addComponent(gpu_temp))
.addGap(118, 118, 118))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ram_temp)
.addComponent(cpu_temp)
.addComponent(gpu_temp))
.addGap(118, 118, 118))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(fan_rpm)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(fan_rpm)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(118, 118, 118)
.addComponent(jLabel2)))
.addGap(80, 80, 80))))))
.addComponent(jLabel1)
.addGap(118, 118, 118)
.addComponent(jLabel2)))
.addGap(80, 80, 80))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel6)
.addGap(0, 0, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -249,15 +234,13 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
.addComponent(gpu_usage)
.addComponent(gpu_temp))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(fan_rpm))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel6))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(fan_rpm)))
.addContainerGap(26, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
@ -265,34 +248,32 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGap(15, 15, 15)
.addComponent(intersection_label, javax.swing.GroupLayout.PREFERRED_SIZE, 1024, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(286, 286, 286)
.addGap(302, 302, 302)
.addComponent(fps_label))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(59, 59, 59)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ambulance_label, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(59, 59, 59)))
.addContainerGap(31, Short.MAX_VALUE))
.addGap(75, 75, 75)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ambulance_label, javax.swing.GroupLayout.PREFERRED_SIZE, 440, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(22, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(49, 49, 49)
.addGap(29, 29, 29)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intersection_label, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(intersection_label, javax.swing.GroupLayout.PREFERRED_SIZE, 768, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(ambulance_label, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(26, 26, 26)
.addComponent(fps_label)
.addGap(18, 18, 18)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(71, Short.MAX_VALUE))
.addContainerGap(19, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Intersection & Ambulance", jPanel5);
@ -308,11 +289,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
longitude_label.setText("Longitude");
robot_stop.setText("Stop Robot");
robot_stop.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
robot_stopMousePressed(evt);
}
});
robot_stop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
robot_stopActionPerformed(evt);
@ -320,11 +296,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
});
move_robot.setText("Move Robot");
move_robot.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
move_robotMousePressed(evt);
}
});
move_robot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
move_robotActionPerformed(evt);
@ -337,6 +308,48 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
});
ai_checkbox.setText("Send to AI");
forward_button.setText("∧");
forward_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
forward_buttonMousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
forward_buttonMouseReleased(evt);
}
});
back_button.setText("∨");
back_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
back_buttonMousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
back_buttonMouseReleased(evt);
}
});
right_button.setText(">");
right_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
right_buttonMousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
right_buttonMouseReleased(evt);
}
});
left_button.setText("<");
left_button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
left_buttonMousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
left_buttonMouseReleased(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
@ -345,20 +358,34 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
.addGap(19, 19, 19)
.addComponent(robot_cam_label, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 231, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(battery_voltage_label)
.addComponent(current_drawn_label)
.addComponent(longitude_label)
.addComponent(latitude_label))
.addGap(278, 278, 278)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(move_robot)
.addComponent(robot_stop))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(cam_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(204, 204, 204))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(battery_voltage_label)
.addComponent(current_drawn_label)
.addComponent(longitude_label)
.addComponent(latitude_label))
.addGap(278, 278, 278)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(move_robot)
.addComponent(robot_stop))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ai_checkbox)
.addComponent(cam_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(204, 204, 204))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(forward_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(back_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(453, 453, 453))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(left_button)
.addGap(70, 70, 70)
.addComponent(right_button)
.addGap(393, 393, 393))))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -383,8 +410,18 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
.addGap(18, 18, 18)
.addComponent(robot_stop)
.addGap(18, 18, 18)
.addComponent(cam_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(cam_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(ai_checkbox)
.addGap(121, 121, 121)
.addComponent(forward_button)
.addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(right_button)
.addComponent(left_button))
.addGap(13, 13, 13)
.addComponent(back_button)))
.addContainerGap(30, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Robot", jPanel2);
@ -518,130 +555,15 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jTabbedPane1.addTab("Traffic Lights", jPanel6);
qr_label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
user_pic.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jLabel7.setText("Name:");
name_label.setText("jLabel8");
jLabel9.setText("TC:");
jLabel10.setText("E-Mail:");
jLabel11.setText("Phone:");
jLabel12.setText("License:");
jLabel13.setText("Trust:");
tc_label.setText("jLabel14");
mail_label.setText("jLabel8");
phone_label.setText("jLabel8");
plate_label.setText("jLabel8");
trust_label.setText("jLabel8");
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(user_pic, javax.swing.GroupLayout.PREFERRED_SIZE, 307, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel9))
.addGap(18, 18, 18)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(name_label, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tc_label)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel9Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel11)
.addComponent(jLabel10)
.addComponent(jLabel12)
.addComponent(jLabel13))
.addGap(18, 18, 18)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(phone_label)
.addComponent(mail_label)
.addComponent(plate_label)
.addComponent(trust_label))))
.addContainerGap(161, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(name_label)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(tc_label, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(mail_label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(phone_label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(plate_label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(trust_label)))
.addComponent(user_pic, javax.swing.GroupLayout.PREFERRED_SIZE, 307, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(18, Short.MAX_VALUE))
);
rpi_temp.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
rpi_temp.setIcon(new javax.swing.ImageIcon("/home/tedankara/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/thermometer.png")); // NOI18N
rpi_temp.setText("30 °C");
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(qr_label, javax.swing.GroupLayout.PREFERRED_SIZE, 720, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(143, 143, 143)
.addComponent(rpi_temp))
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(83, 83, 83)
.addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(48, Short.MAX_VALUE))
.addGap(0, 1622, Short.MAX_VALUE)
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(qr_label, javax.swing.GroupLayout.PREFERRED_SIZE, 720, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel8Layout.createSequentialGroup()
.addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(83, 83, 83)
.addComponent(rpi_temp)))
.addContainerGap(63, Short.MAX_VALUE))
.addGap(0, 816, Short.MAX_VALUE)
);
jTabbedPane1.addTab("QR Code", jPanel8);
@ -673,6 +595,29 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
settings.initIp();
}//GEN-LAST:event_manage_buttonActionPerformed
private void ambulance_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ambulance_buttonActionPerformed
if(running!=null){
try{
server.close();
client.close();
running.stop();
}catch(IOException e){
System.out.println("IO Exception occured");
}catch(Exception e){
System.out.println(e.toString());
}
}else{
running = new Thread(() -> {
try{
onCreate(8485,"Ambulance");
}catch(Exception e){
System.out.println(e.toString());
}
});
running.start();
}
}//GEN-LAST:event_ambulance_buttonActionPerformed
private void jTabbedPane1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseEntered
if(!listening){
jTabbedPane1.addChangeListener(this);
@ -693,14 +638,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
}//GEN-LAST:event_move_robotActionPerformed
private void move_robotMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_move_robotMousePressed
try {
out.writeUTF("m");
} catch (IOException ex) {
System.out.println(ex.toString());
}
}//GEN-LAST:event_move_robotMousePressed
private void robot_stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_robot_stopActionPerformed
try {
out.writeUTF("s");
@ -709,14 +646,6 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
}//GEN-LAST:event_robot_stopActionPerformed
private void robot_stopMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_robot_stopMousePressed
try {
out.writeUTF("s");
} catch (IOException ex) {
System.out.println(ex.toString());
}
}//GEN-LAST:event_robot_stopMousePressed
private void cam_sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cam_sliderStateChanged
JSlider source = (JSlider)evt.getSource();
if (!source.getValueIsAdjusting()) {
@ -738,6 +667,70 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
}//GEN-LAST:event_cam_sliderStateChanged
private void forward_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forward_buttonMousePressed
try {
out.writeUTF("f");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_forward_buttonMousePressed
private void forward_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_forward_buttonMouseReleased
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_forward_buttonMouseReleased
private void back_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_back_buttonMousePressed
try {
out.writeUTF("b");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_back_buttonMousePressed
private void back_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_back_buttonMouseReleased
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_back_buttonMouseReleased
private void left_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_left_buttonMousePressed
try {
out.writeUTF("r");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_left_buttonMousePressed
private void left_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_left_buttonMouseReleased
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_left_buttonMouseReleased
private void right_buttonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMousePressed
try {
out.writeUTF("l");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_right_buttonMousePressed
private void right_buttonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_right_buttonMouseReleased
try {
out.writeUTF("s");
} catch(Exception ex){
System.out.println(ex.toString());
}
}//GEN-LAST:event_right_buttonMouseReleased
/**
* @param args the command line arguments
*/
@ -812,16 +805,22 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
boolean run = true;
if (name.equals("robot")) {
robotSocket = new Socket(ROBOT_IP, 3131);
robotSocket.setSoTimeout(1000);
out = new DataOutputStream(robotSocket.getOutputStream());
in = new BufferedReader(new InputStreamReader(robotSocket.getInputStream()));
while (run) {
out.writeUTF("i");
String resp = in.readLine();
String resp;
try {
resp = in.readLine();
} catch (SocketTimeoutException ex) {
resp = "{\"battery_voltage\":\"TIMEOUT\",\"current_drawn\":\"TIMEOUT\",\"lat\":\"TIMEOUT\",\"lng\":\"TIMEOUT\"}";
}
JSONObject values = new JSONObject(resp);
latitude_label.setText("Latitude: " + values.getString("lat"));
longitude_label.setText("Longitude: " + values.getString("lng"));
battery_voltage_label.setText("Battery Voltage: " + values.getString("battery_voltage"));
current_drawn_label.setText("Current Drawn: " + values.getString("current_drawn"));
latitude_label.setText("Latitude: " + values.get("lat"));
longitude_label.setText("Longitude: " + values.get("lng"));
battery_voltage_label.setText("Battery Voltage: " + values.get("battery_voltage"));
current_drawn_label.setText("Current Drawn: " + values.get("current_drawn"));
BufferedImage image;
URL img_url = new URL(String.format("http://%s:8080/?action=snapshot", ROBOT_IP));
@ -833,121 +832,64 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
graphics2D.translate((height - width) / 2, (height - width) / 2);
graphics2D.rotate(Math.PI / 2, height / 2, width / 2);
graphics2D.drawRenderedImage(image, null);
robot_cam_label.setIcon(new ImageIcon(resizeImage(dest,1000,1000)));
URL obj = new URL(String.format("https://%s:5001/ai", AI_IP));
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(dest, "PNG", out);
byte[] bytes = out.toByteArray();
String base64 = Base64.getEncoder().encodeToString(bytes);
String params = "type=damage&img=" + encodeValue(base64);
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(params);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
JSONObject json = new JSONObject(response.toString());
}
return;
}else if(name.equals("qr")){
while(run){
BufferedImage image;
URL myurl = new URL(String.format("http://%s:3000/get", QR_IP));
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
con.setRequestMethod("GET");
StringBuilder content;
try (BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()))) {
String line;
content = new StringBuilder();
while ((line = in.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
dest = resizeImage(dest,576,768);
width = dest.getWidth();
height = dest.getHeight();
// robot_cam_label.setIcon(new ImageIcon(dest));
if (ai_checkbox.isSelected()) {
URL obj = new URL(String.format("https://%s:5001/ai", AI_IP));
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(dest, "PNG", out);
byte[] bytes = out.toByteArray();
String base64 = Base64.getEncoder().encodeToString(bytes);
String params = "type=damage&img=" + encodeValue(base64);
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(params);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
}
System.out.println(content.toString());
JSONObject json = new JSONObject(content.toString());
this.rpi_temp.setText(json.getString("temp"));
byte[] decodedBytes = Base64.getDecoder().decode(json.getString("img"));
ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes);
image = ImageIO.read(bis);
this.qr_label.setIcon(new ImageIcon(image));
bis.close();
if(!json.getJSONObject("user").toString().equals("{}")){
JSONObject user = json.getJSONObject("user");
decodedBytes = Base64.getDecoder().decode(user.getString("image"));
bis = new ByteArrayInputStream(decodedBytes);
image = ImageIO.read(bis);
ImageIcon avatar = new ImageIcon(image);
bis.close();
this.user_pic.setIcon(avatar);
this.name_label.setText(user.getString("realname"));
this.tc_label.setText(user.getString("TC"));
this.mail_label.setText(user.getString("email"));
this.phone_label.setText(user.getString("tel"));
this.plate_label.setText(user.getString("plate"));
this.trust_label.setText(user.getString("trustability"));
}else{
this.user_pic.setIcon(null);
this.name_label.setText("None");
this.tc_label.setText("None");
this.mail_label.setText("None");
this.phone_label.setText("None");
this.plate_label.setText("None");
this.trust_label.setText("None");
}
}
return;
}else if(name.equals("lights")){
int[][] colors = {{204,0,0},{204,204,0},{0,204,0}};
javax.swing.JLabel[][] labels = {{intersection_1_R,intersection_1_Y,intersection_1_G},{intersection_2_R,intersection_2_Y,intersection_2_G}};
int[] lights = {0,0};
while(run) {
Socket lightSocket = new Socket(LIGHT_IP, 69);
in = new BufferedReader(new InputStreamReader(lightSocket.getInputStream()));
String fromClient = in.readLine();
if(fromClient != null) {
if(fromClient.trim().equals("Bye")) {
run = false;
System.out.println("socket closed");
}else{
System.out.println("received data in size: " + fromClient.length());
System.out.println(fromClient);
lights[0] = Character.getNumericValue(fromClient.charAt(0));
lights[1] = Character.getNumericValue(fromClient.charAt(2));
for(int i = 0;i < 2;i++){
for(int j = 0;j<3;j++){
if(lights[i] == j){
labels[i][j].setBackground(new java.awt.Color(colors[j][0], colors[j][1], colors[j][2]));
continue;
}
labels[i][j].setBackground(new java.awt.Color(204,204,204));
}
in.close();
JSONObject json = new JSONObject(response.toString());
JSONArray detection_classes = json.getJSONArray("detection_classes");
System.out.println(detection_classes);
JSONArray detection_scores = json.getJSONArray("detection_scores");
System.out.println(detection_scores);
JSONArray detection_boxes = json.getJSONArray("detection_boxes");
Graphics2D graph = dest.createGraphics();
graph.setColor(Color.RED);
graph.setStroke(new BasicStroke(10));
graph.setFont(new Font("Arial Black", Font.BOLD, 20));
for (int i = 0; i < detection_scores.length(); i++) {
if (detection_scores.getDouble(i) < 0.3) {
continue;
}
JSONArray box = detection_boxes.getJSONArray(i);
int left = (int)(box.getDouble(1) * width);
int right = (int)(box.getDouble(3) * width);
int top = (int)(box.getDouble(0) * height);
int bottom = (int)(box.getDouble(2) * height);
graph.setColor(Color.RED);
graph.drawRect(left, top, right - left, bottom - top);
graph.setColor(Color.BLUE);
graph.drawString(Integer.toString((int)(detection_scores.getDouble(i) * 100)) + "%", left, top - 5);
}
}
robot_cam_label.setIcon(new ImageIcon(dest));
}
return;
}
this.ambulance_label.setIcon(new ImageIcon());
this.intersection_label.setIcon(new ImageIcon());
@ -984,8 +926,8 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
image = ImageIO.read(bis);
bis.close();
JSONObject dims = json.getJSONObject("image_sizes");
this.intersection_label.setIcon(new ImageIcon(resizeImage(image,1024,576)));
this.ambulance_label.setIcon(new ImageIcon(resizeImage(image.getSubimage(dims.getInt("x"), dims.getInt("y"), dims.getInt("width"), dims.getInt("height")),333,333)));
this.intersection_label.setIcon(new ImageIcon(resizeImage(image,1280,720)));
this.ambulance_label.setIcon(new ImageIcon(resizeImage(image.getSubimage(dims.getInt("x"), dims.getInt("y"), dims.getInt("width"), dims.getInt("height")),300,300)));
JSONObject data = json.optJSONObject("load");
this.gpu_temp.setText(data.getString("gpu_temp"));
this.gpu_usage.setText(data.getString("gpu_load"));
@ -1024,6 +966,36 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
this.intersection_label.setIcon(new ImageIcon());
JOptionPane.showMessageDialog(this, name +" socket server down!");
running.stop();
}else if(name.equals("lights")){
int[][] colors = {{204,0,0},{204,204,0},{0,204,0}};
javax.swing.JLabel[][] labels = {{intersection_1_R,intersection_1_Y,intersection_1_G},{intersection_2_R,intersection_2_Y,intersection_2_G}};
int[] lights = {0,0};
while(run) {
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
fromClient = in.readLine();
if(fromClient != null) {
if(fromClient.trim().equals("Bye")) {
run = false;
System.out.println("socket closed");
}else{
System.out.println("received data in size: " + fromClient.length());
System.out.println(fromClient);
lights[0] = Character.getNumericValue(fromClient.charAt(0));
lights[1] = Character.getNumericValue(fromClient.charAt(2));
for(int i = 0;i < 2;i++){
for(int j = 0;j<3;j++){
if(lights[i] == j){
labels[i][j].setBackground(new java.awt.Color(colors[j][0], colors[j][1], colors[j][2]));
continue;
}
labels[i][j].setBackground(new java.awt.Color(204,204,204));
}
}
}
}
}
}
}
@ -1045,13 +1017,13 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
if(running!=null){
try{
server.close();
client.close();
running.stop();
}catch(IOException ex){
System.out.println("IO Exception occured");
}catch(Exception ex){
System.out.println(ex.toString());
}
client.close();
running.stop();
}catch(IOException ex){
System.out.println("IO Exception occured");
}catch(Exception ex){
System.out.println(ex.toString());
}
}
switch (jTabbedPane1.getSelectedIndex()) {
case 0:
@ -1084,27 +1056,20 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
});
running.start();
break;
case 3:
running = new Thread(() -> {
try{
onCreate(0,"qr");
}catch(Exception ex){
System.out.println(ex.toString());
}
});
running.start();
break;
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox ai_checkbox;
private javax.swing.JLabel ambulance_label;
private javax.swing.JButton back_button;
private javax.swing.JLabel battery_voltage_label;
private javax.swing.JSlider cam_slider;
private javax.swing.JLabel cpu_temp;
private javax.swing.JLabel cpu_usage;
private javax.swing.JLabel current_drawn_label;
private javax.swing.JLabel fan_rpm;
private javax.swing.JButton forward_button;
private javax.swing.JLabel fps_label;
private javax.swing.JLabel gpu_temp;
private javax.swing.JLabel gpu_usage;
@ -1118,18 +1083,11 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
private javax.swing.JLabel intersection_R_3;
private javax.swing.JLabel intersection_label;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
@ -1138,26 +1096,18 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel latitude_label;
private javax.swing.JButton left_button;
private javax.swing.JLabel light_1_label;
private javax.swing.JLabel light_2_label;
private javax.swing.JLabel longitude_label;
private javax.swing.JLabel mail_label;
private javax.swing.JButton move_robot;
private javax.swing.JLabel name_label;
private javax.swing.JLabel phone_label;
private javax.swing.JLabel plate_label;
private javax.swing.JLabel qr_label;
private javax.swing.JLabel ram_temp;
private javax.swing.JLabel ram_usage;
private javax.swing.JButton right_button;
private javax.swing.JLabel robot_cam_label;
private javax.swing.JButton robot_stop;
private javax.swing.JLabel rpi_temp;
private javax.swing.JLabel tc_label;
private javax.swing.JLabel trust_label;
private javax.swing.JLabel user_pic;
// End of variables declaration//GEN-END:variables


BIN
master_app/src/main/java/me/yigitcolakoglu/master_app/thermometer.png View File

Before After
Width: 128  |  Height: 128  |  Size: 3.1 KiB

BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$6.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$7.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$8.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$9.class View File


BIN
master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class View File


+ 5
- 0
master_app/target/maven-archiver/pom.properties View File

@ -0,0 +1,5 @@
#Generated by Maven
#Mon Jul 08 11:26:41 EET 2019
groupId=me.yigitcolakoglu
artifactId=master_app
version=1.0-SNAPSHOT

+ 7
- 25
server_side/api/ai_services.py View File

@ -9,10 +9,9 @@ from PIL import Image
import base64
import io
import json
import re
import tensorflow as tf
import sys,getpass
import sys
import numpy as np
from flask import Flask, send_from_directory
from flask_restful import Api
@ -31,7 +30,7 @@ PATH_TO_FROZEN_DAMAGE_GRAPH = 'modules/trainedModels/ssd_mobilenet_RoadDamageDe
linux_def = {"detection_boxes":[(106, 188, 480, 452)],"detection_scores":[0.99],"detection_classes":[1]}
detection_graph_coco = None
detection_graph_damage = None
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
detection_graph_coco = tf.Graph()
detection_graph_damage = tf.Graph()
with detection_graph_coco.as_default():
@ -52,24 +51,11 @@ def load_image_into_numpy_array(image):
return np.array(image.getdata()).reshape(
(im_height, im_width, 3)).astype(np.uint8)
def decode_base64(data, altchars=b'+/'):
"""Decode base64, padding being optional.
:param data: Base64 data as an ASCII byte string
:returns: The decoded byte string.
"""
data = re.sub(rb'[^a-zA-Z0-9%s]+' % altchars, b'', bytes(data,"utf-8")) # normalize
missing_padding = len(data) % 4
if missing_padding:
data += b'='* (4 - missing_padding)
return base64.b64decode(data, altchars)
def run_inference_for_single_image(image, graph,type):
global switches
global sess_coco
global sess_damage
if not getpass.getuser() == "tedankara":
if not sys.platform == "win32":
return linux_def
with graph.as_default():
if(switches[type]):
@ -131,7 +117,7 @@ def run_inference_for_single_image(image, graph,type):
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: image})
output_dict = {'detection_classes': np.squeeze(classes).astype(np.int32), 'detection_scores': np.squeeze(scores),'detection_boxes': np.squeeze(boxes)}
output_dict = {'detection_classes': np.squeeze(classes).astype(np.int32), 'detection_scores': np.squeeze(scores)}
return output_dict
@ -139,8 +125,7 @@ def run_inference_for_single_image(image, graph,type):
class Process(Resource):
def post(self):
base64_img = request.form['img']
image = Image.open(io.BytesIO(decode_base64(base64_img)))
image = Image.open(io.BytesIO(base64.b64decode(base64_img)))
type = request.form["type"]
image_np = load_image_into_numpy_array(image)
image_np_expanded = np.expand_dims(image_np, axis=0)
@ -148,12 +133,9 @@ class Process(Resource):
output_dict = run_inference_for_single_image(image_np_expanded, detection_graph_coco,type)
elif type == "damage":
output_dict = run_inference_for_single_image(image_np_expanded, detection_graph_damage,type)
if getpass.getuser() == "tedankara":
output_dict["detection_boxes"] = output_dict["detection_boxes"].tolist()
output_dict["detection_scores"] = output_dict["detection_scores"].tolist()
output_dict["detection_classes"] = output_dict["detection_classes"].tolist()
return output_dict
return json.dumps(output_dict,cls=NumpyEncoder)
class NumpyEncoder(json.JSONEncoder):


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

@ -2,8 +2,9 @@ from flask import Flask, send_from_directory
from flask_restful import Api
from flask_cors import CORS, cross_origin
from modules import user_info, voting_system, rating_system, denunciation, announcements, complaint, car_crash, smart_park,navigation,bus_stops
from modules import user_info, voting_system, rating_system, denunciation, navigation, bus_stops, announcements, complaint, car_crash, smart_park
from modules import utility
from modules import user_set
app = Flask(__name__)
api = Api(app)


+ 3
- 3
server_side/api/modules/SpotSelector.py View File

@ -4,9 +4,9 @@ import json
rects = []
cam = cv2.VideoCapture(5)
ret,im = cam.read()
#im = cv2.imread("lot.jpg")
#cam = cv2.VideoCapture("http://192.168.43.246:4747/mjpegfeed")
#ret,im = cam.read()
im = cv2.imread("lot.jpg")
if __name__ == '__main__' :
while(True):


+ 38
- 38
server_side/api/modules/car_crash.py View File

@ -8,7 +8,7 @@ import cv2
import base64
import json
import sys,getpass
import sys
import os
import io
import itertools
@ -28,7 +28,7 @@ import numpy as np
MIN_SCORE_THRESH = 0.6
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
sys.path.insert(0, r'C:\Users\Tednokent01\Downloads\MyCity\traffic_analyzer')
PATH_TO_LABELS = os.path.join('object_detection/data', 'mscoco_label_map.pbtxt')
@ -75,10 +75,10 @@ def find_name(image):
return None
def rotate_img(img, angle):
if angle == 90:
return np.rot90(img)
elif angle == 270:
return np.rot90(np.rot90(np.rot90(img)))
if angle == 90:
return np.rot90(img)
elif angle == 270:
return np.rot90(np.rot90(np.rot90(img)))
def process_img(img_base64):
url = 'https://{}:5001/ai'.format(AI_IP) # Set destination URL here
@ -150,23 +150,23 @@ def process_img(img_base64):
pass
(height_person,width_person) = person.shape[:2]
if name is None:
rotated = rotate_img(person, 270)
face_locs = face_recognition.face_locations(rotated)[0]
name = find_name(rotated)
(top_face, right_face, bottom_face, left_face) = face_locs
face_locs_processed = (top + height_person - right_face,left+bottom_face,top + height_person - left_face,left+top_face)
else:
(top_face, right_face, bottom_face, left_face) = face_locs
person = cv2.rectangle(person, (width_person - bottom_face, left_face), (width_person - top_face, right_face), (0, 255, 0), 3)
face_locs_processed = (top + left_face,left + width_person - top_face,top + right_face,left + width_person - bottom_face)
people[index] = [0, face_locs_processed, name]
else:
face_locs = face_recognition.face_locations(person)[0]
(top_face, right_face, bottom_face, left_face) = face_locs
face_locs_processed = (top+face_locs[0],left+face_locs[1],top+face_locs[2],left+face_locs[3])
name = find_name(person)
people[index] = [1, face_locs_processed, name]
if name is None:
rotated = rotate_img(person, 270)
face_locs = face_recognition.face_locations(rotated)[0]
name = find_name(rotated)
(top_face, right_face, bottom_face, left_face) = face_locs
face_locs_processed = (top + height_person - right_face,left+bottom_face,top + height_person - left_face,left+top_face)
else:
(top_face, right_face, bottom_face, left_face) = face_locs
person = cv2.rectangle(person, (width_person - bottom_face, left_face), (width_person - top_face, right_face), (0, 255, 0), 3)
face_locs_processed = (top + left_face,left + width_person - top_face,top + right_face,left + width_person - bottom_face)
people[index] = [0, face_locs_processed, name]
else:
face_locs = face_recognition.face_locations(person)[0]
(top_face, right_face, bottom_face, left_face) = face_locs
face_locs_processed = (top+face_locs[0],left+face_locs[1],top+face_locs[2],left+face_locs[3])
name = find_name(person)
people[index] = [1, face_locs_processed, name]
@ -188,21 +188,21 @@ class Crash(Resource):
id = request.form['id']
lat, long = request.form['lat'], request.form['long']
image, car_count, injured,out,people = process_img(base64_img)
(top, right, bottom, left) = people[0][1]
top = int(top)
right = int(right)
left = int(left)
bottom = int(bottom)
img = load_image_into_numpy_array(Image.open(io.BytesIO(base64.b64decode(base64_img))))
cv2.rectangle(img,(left,top),(right,bottom),(0,255,0),3)
cv2.imshow('test.jpg', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(people)
priority = car_count + injured
if priority > 10:
priority = 10
image, car_count, injured,out,people = process_img(base64_img)
(top, right, bottom, left) = people[0][1]
top = int(top)
right = int(right)
left = int(left)
bottom = int(bottom)
img = load_image_into_numpy_array(Image.open(io.BytesIO(base64.b64decode(base64_img))))
cv2.rectangle(img,(left,top),(right,bottom),(0,255,0),3)
cv2.imshow('test.jpg', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(people)
priority = car_count + injured
if priority > 10:
priority = 10
crash = {
'img': image,


+ 6
- 6
server_side/api/modules/complaint.py View File

@ -5,7 +5,7 @@ import json
import io
import base64
from PIL import Image
import sys,getpass
import sys
import datetime
import cv2
import ssl
@ -13,7 +13,7 @@ from urllib.parse import urlencode
from urllib.request import Request, urlopen
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
import tensorflow as tf
import numpy as np
import pickle
@ -42,7 +42,7 @@ score_dict = {
with open("modules/databases/complaints.json","r") as f:
complaints = json.load(f)
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
# Path to frozen detection graph. This is the actual model that is used for the object detection.
# List of the strings that is used to add correct label for each box.
@ -60,15 +60,15 @@ def load_image_into_numpy_array(image):
def process_img(img_base64):
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
url = 'https://127.0.0.1:5001/ai' # Set destination URL here
url = 'https://127.0.0.1:5000/ai' # Set destination URL here
post_fields = {'img': img_base64,"type":"damage"} # Set POST fields here
request = Request(url, urlencode(post_fields).encode())
img = load_image_into_numpy_array(Image.open(io.BytesIO(base64.b64decode(img_base64))))
output_dict = json.loads(urlopen(request, context=context).read())
output_dict = json.loads(json.loads(urlopen(request, context=context).read()))
print(output_dict)
vis_util.visualize_boxes_and_labels_on_image_array(
img,


+ 47
- 6
server_side/api/modules/databases/complaints.json
File diff suppressed because it is too large
View File


+ 33
- 12
server_side/api/modules/databases/locations.json View File

@ -1,23 +1,44 @@
{
"0": {
"x1": 40,
"y1": 64,
"x2": 258,
"y2": 204,
<<<<<<< Updated upstream
"x1": 2,
"y1": 94,
"x2": 198,
"y2": 206,
"priority": 0
},
"1": {
"x1": 262,
"y1": 96,
"x2": 386,
"y2": 206,
"x1": 190,
"y1": 88,
"x2": 400,
"y2": 196,
"priority": 1
},
"2": {
"x1": 390,
"y1": 66,
"x2": 640,
"y2": 200,
=======
"x1": 208,
"y1": 356,
"x2": 374,
"y2": 460,
"priority": 0
},
"1": {
"x1": 114,
"y1": 358,
"x2": 230,
"y2": 450,
"priority": 1
},
"2": {
"x1": 426,
"y1": 100,
"x2": 564,
"y2": 204,
"x1": 0,
"y1": 346,
"x2": 106,
"y2": 478,
>>>>>>> Stashed changes
"priority": 2
}
}

+ 270901
- 172801
server_side/api/modules/databases/park_data.json
File diff suppressed because it is too large
View File


+ 149
- 298
server_side/api/modules/databases/users.json
File diff suppressed because it is too large
View File


+ 1
- 1
server_side/api/modules/smart_park.py View File

@ -108,7 +108,7 @@ with open("modules/databases/locations.json","r") as f:
with open("modules/databases/park_data.json","r") as f:
data = json.loads(f.read())
cam=cv2.VideoCapture(5)
if 0:
ret,im = cam.read()
data = generateAvg(locs,im,data)


+ 0
- 162
server_side/api/modules/smart_park.py.save View File

@ -1,162 +0,0 @@
import cv2
import numpy as np
import json
from pysolar.solar import *
from datetime import datetime
from flask import Flask, request
from flask_restful import Resource, Api, abort
import base64
import pickle
from PIL import Image
from matplotlib import pyplot as plt
from io import BytesIO
app = Flask(__name__)
api = Api(app)
def generateAvg(locs, img, avgs):
time = datetime.strptime( "2019-04-27 17:52:00 -0300","%Y-%m-%d %H:%M:%S %z")
altitude = int(get_altitude(39.9127938,32.8073577,time))
loc_images = {}
for i in locs:
temp = locs[i]
crop_img = img[temp["y1"]:temp["y2"], temp["x1"]:temp["x2"]]
loc_images[i]=[crop_img]
vals = {}
if str(altitude) in avgs:
vals = avgs[str(altitude)]
else:
for spot in loc_images:
vals[spot] = loc_images[spot]
for spot in loc_images:
for col in range(len(vals[spot][0])):
for pix in range(len(vals[spot][0][col])):
vals[spot][0][col][pix] = [
np.uint8((int(vals[spot][0][col][pix][0]) + int(loc_images[spot][0][col][pix][0]))/2),
np.uint8((int(vals[spot][0][col][pix][1]) + int(loc_images[spot][0][col][pix][1]))/2),
np.uint8((int(vals[spot][0][col][pix][2]) + int(loc_images[spot][0][col][pix][2]))/2)]
for i in vals:
vals[i] = vals[i][0].tolist()
avgs[altitude] = vals
return avgs
def generateData(locs, img, avgs,show):
time = datetime.strptime( "2019-04-27 17:52:00 -0300","%Y-%m-%d %H:%M:%S %z")
altitude = int(get_altitude(39.9127938,32.8073577,time))
loc_images = {}
distances = {}
for i in locs:
temp = locs[i]
crop_img = img[temp["y1"]:temp["y2"], temp["x1"]:temp["x2"]]
loc_images[i]=[crop_img]
vals = {}
if str(altitude) in avgs:
for spot in avgs[str(altitude)]:
vals[spot] = np.array(avgs[str(altitude)][spot])
else:
for spot in loc_images:
vals[spot] = loc_images[spot]
for spot in loc_images:
foo = np.zeros((len(vals[spot]),len(vals[spot][0])),dtype=int)
distances[spot] = 0
for col in range(len(vals[spot])):
for pix in range(len(vals[spot][col])):
vals[spot][col][pix] = [
np.uint8(abs(int(vals[spot][col][pix][0]) - int(loc_images[spot][0][col][pix][0]))),
np.uint8(abs(int(vals[spot][col][pix][1]) - int(loc_images[spot][0][col][pix][1]))),
np.uint8(abs(int(vals[spot][col][pix][2]) - int(loc_images[spot][0][col][pix][2])))]
distances[spot] += np.sum(vals[spot][col][pix])
foo[col][pix] = np.max(vals[spot][col][pix])
distances[spot] = int(distances[spot]/vals[spot].size)
vals[spot] = foo
if spot in show:
plt.imshow(vals[spot], interpolation='nearest')
#plt.show()
return distances
def im2str(im):
imdata = pickle.dumps(im)
return base64.b64encode(imdata).decode('ascii')
plt.axis("off")
with open("modules/databases/locations.json","r") as f:
locs = json.loads(f.read())
with open("modules/databases/park_data.json","r") as f:
data = json.loads(f.read())
cam = cv2.VideoCapture(5)
if 1:
ret,im = cam.read()
data = generateAvg(locs,im,data)
with open("modules/databases/park_data.json","w") as f:
f.write(json.dumps(data,indent=2))
class Empty(Resource):
def get(self):
image = cv2.imread("modules/lot.jpg")
backup = image.copy()
spot_data = generateData(locs,image,data,["0","1","2"])
print(spot_data)
best_spot = -1
for loc in spot_data:
spot_data[loc] = spot_data[loc] < 30
color = (0,255*spot_data[loc],255*(not spot_data[loc]))
cv2.rectangle(image,(locs[loc]["x1"],locs[loc]["y1"]),(locs[loc]["x2"],locs[loc]["y2"]),color,5)
if spot_data[loc]:
if best_spot == -1:
best_spot = loc
continue
if locs[loc]["priority"] < locs[best_spot]["priority"]:
best_spot = loc
print(spot_data)
if best_spot == -1:
print("Sorry, no spot found :(")
return
else:
print("Empty spot found at {}".format(int(best_spot) + 1))
foo = locs[best_spot]
crop_img = backup[foo["y1"]:foo["y2"], foo["x1"]:foo["x2"]].copy(order='C')
crop_img = Image.fromarray(crop_img,"RGB")
buffered = BytesIO()
crop_img.save(buffered, format="JPEG")
img = base64.b64encode(buffered.getvalue()).decode("ascii")
return {"lat":foo["lat"], "lng":foo["lng"], "img":img}

+ 10
- 8
server_side/api/modules/user_set.py View File

@ -1,24 +1,26 @@
import os
import sys,getpass
import sys
import json
import base64
import face_recognition
import utils
from modules import utils
with open('databases/users.json') as f:
with open('modules/databases/users.json') as f:
users = json.load(f)
for file in os.listdir("../images"):
for file in os.listdir("images"):
if file.endswith(".png") or file.endswith(".jpg"):
uid = file.split('.')[0]
if len(uid) == 32 and utils.find_by_id(users.values(), uid):
full_path = os.path.join("../images", file)
full_path = os.path.join("images", file)
image = face_recognition.load_image_file(full_path)
with open(full_path, 'rb') as f:
base64_image = base64.b64encode(f.read())
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
face_locations = face_recognition.face_locations(image, model="cnn")[0]
else:
face_locations = face_recognition.face_locations(image)[0]
face_encoding = face_recognition.face_encodings(image)[0]
@ -28,7 +30,7 @@ for file in os.listdir("../images"):
users[k]['face_locations'] = face_locations
users[k]['face_encoding'] = list(face_encoding)
with open('databases/users.json', 'w') as f:
with open('modules/databases/users.json', 'w') as f:
users = json.dump(users, f, indent=2)
os.remove(full_path)
os.remove(full_path)

+ 1
- 1
server_side/api/object_detection/core/preprocessor.py View File

@ -65,7 +65,7 @@ back to rank 4.
import functools
import inspect
import sys,getpass
import sys
import tensorflow as tf
from tensorflow.python.ops import control_flow_ops


+ 1
- 1
server_side/api/object_detection/object_detection_tutorial.ipynb View File

@ -39,7 +39,7 @@
"import numpy as np\n",
"import os\n",
"import six.moves.urllib as urllib\n",
"import sys,getpass\n",
"import sys\n",
"import tarfile\n",
"import tensorflow as tf\n",
"import zipfile\n",


+ 1
- 1
server_side/api/object_detection/protos/anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/argmax_matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/argmax_matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/bipartite_matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/bipartite_matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/box_predictor_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/box_predictor.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/calibration_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/calibration.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/eval_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/eval.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/faster_rcnn_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/faster_rcnn_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/faster_rcnn_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/faster_rcnn.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/flexible_grid_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/flexible_grid_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/graph_rewriter_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/graph_rewriter.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/grid_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/grid_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/hyperparams_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/hyperparams.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/image_resizer_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/image_resizer.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor


+ 1
- 1
server_side/api/object_detection/protos/input_reader_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/input_reader.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor


+ 1
- 1
server_side/api/object_detection/protos/keypoint_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/keypoint_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/losses_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/losses.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/mean_stddev_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/mean_stddev_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/model_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/model.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/multiscale_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/multiscale_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/optimizer_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/optimizer.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/pipeline_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/pipeline.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/post_processing_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/post_processing.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/preprocessor_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/preprocessor.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/region_similarity_calculator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/region_similarity_calculator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/square_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/square_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/ssd_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/ssd_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/ssd_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/ssd.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/string_int_label_map_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/string_int_label_map.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
server_side/api/object_detection/protos/train_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/train.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 26
- 30
traffic_analyzer/ambulance_detect.py View File

@ -2,19 +2,17 @@
import pickle
import threading
import sys,getpass
import sys
import cv2
import os
import numpy as np
import psutil
import subprocess
from telnetlib import Telnet
from utils import label_map_util
from utils import visualization_utils as vis_util
if getpass.getuser() == "tedankara":
if sys.platform == "win32":
import tensorflow as tf
from distutils.version import StrictVersion
@ -32,7 +30,6 @@ from PIL import Image
from io import BytesIO
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from imutils.video import VideoStream
import ssl
switch = 1
@ -44,9 +41,9 @@ sys.path.append("..")
import time
from object_detection.utils import ops as utils_ops
TELNET = True
TELNET = False
AI_IP = '127.0.0.1'
AI_IP = '10.10.26.161'
LIGHT_IP = '192.168.2.174'
context = ssl._create_unverified_context()
if TELNET:
@ -72,18 +69,16 @@ def load_image_into_numpy_array(image):
data = {"gpu_temp":"10C","gpu_load":"15%","cpu_temp":"47C","cpu_load":"15%","mem_temp":"NaN","mem_load":"17%","fan_speed":"10000RPM"}
"""
def get_temps():
global data
temps = psutil.sensors_temperatures()
result = subprocess.run(['nvidia-smi', '--query-gpu=utilization.memory', '--format=csv'] , stdout=subprocess.PIPE)
data["gpu_load"] = result.stdout.decode("utf-8").split("\n")[1]
result = subprocess.run(['nvidia-smi', '--query-gpu=temperature.gpu', '--format=csv'] , stdout=subprocess.PIPE)
data["gpu_temp"] = result.stdout.decode("utf-8").split("\n")[1]+"°C"
data["cpu_temp"] = str(int(temps["coretemp"][0][1]))+"°C"
data["cpu_load"] = str(psutil.cpu_percent())+"%"
data["mem_load"] = str(dict(psutil.virtual_memory()._asdict())["percent"])+"%"
data["fan_speed"] = str(psutil.sensors_fans()["dell_smm"][0][1])+"RPM"
if not sys.platform == "win32":
temps = psutil.sensors_temperatures()
data["cpu_temp"] = str(int(temps["dell_smm"][0][1]))+"°C"
data["cpu_load"] = str(psutil.cpu_percent())+"%"
data["mem_load"] = str(dict(psutil.virtual_memory()._asdict())["percent"])+"%"
data["fan_speed"] = str(psutil.sensors_fans()["dell_smm"][0][1])+"RPM"
"""
def run_inference_for_single_image(image):
@ -93,7 +88,7 @@ def run_inference_for_single_image(image):
post_fields = {'img': img_base64,"type":"coco"} # Set POST fields here
request = Request(url, urlencode(post_fields).encode())
data = urlopen(request, context=context).read().decode("ascii")
output_dict = json.loads(data)
output_dict = json.loads(json.loads(data))
return output_dict
kill = True
@ -127,19 +122,20 @@ socket_switch = True
thread = threading.Thread(target=listener)
thread.start()
cam = VideoStream(src=0).start()
cam = cv2.VideoCapture(1)
switch = 0
get_temps()
# get_temps()
# (left, right, top, bottom)
ambulance_coordinates = (150, 400, 250, 400)
ambulance_coordinates = (65, 190, 0, 140)
reps = -1
reps_vid = 0
while 1:
image = cam.read()
ret,image = cam.read()
image = cv2.imread('/home/efeaydin/Masaüstü/union-county-car-accident-attorneys.jpg')
reps_vid += 1
reps += 1
@ -149,7 +145,6 @@ while 1:
output_dict = run_inference_for_single_image(image_np)
height, width, channels = image_np.shape
cv2.imshow('frmmi', image[ambulance_coordinates[2]:ambulance_coordinates[3], ambulance_coordinates[0]:ambulance_coordinates[1]])
out_dict = {'detection_boxes': [], 'detection_classes': [], 'detection_scores': []}
for index,i in enumerate(output_dict['detection_classes']):
@ -197,10 +192,11 @@ while 1:
line_thickness=8,
min_score_thresh=0.3
)
#cv2.imshow('frame', image_np)
#ex_c = [27, ord("q"), ord("Q")]
#if cv2.waitKey(1) & 0xFF in ex_c:
# break
cv2.imwrite('/home/efeaydin/Masaüstü/foto.jpg', image_np)
cv2.imshow('frame', image_np)
ex_c = [27, ord("q"), ord("Q")]
if cv2.waitKey(1) & 0xFF in ex_c:
break
t2 = time.time()
print("time taken for {}".format(t2-t1))
@ -228,13 +224,13 @@ while 1:
if cut[i] < 0:
cut_send[i] = lens[i] + cut[i]
cut_send[i+1] = abs(cut[i])-abs(cut[i+1])
client_socket.sendall(json.dumps({"image_full":img,"image_sizes":{"x":90,"y":0,"width":140,"height":140},"load":data}).encode('gbk')+b"\n")
client_socket.sendall(json.dumps({"image_full":img,"image_sizes":{"x":65,"y":0,"width":125,"height":140},"load":data}).encode('gbk')+b"\n")
img_counter += 1
except:
socket_switch = True
if img_counter % 10 == 0:
get_temps()
# get_temps()
pass
except Exception as e:
@ -252,6 +248,6 @@ if not socket_switch:
cv2.destroyAllWindows()
cam.stop()
cam.release()
kill = False
thread.join()

+ 8
- 5
traffic_analyzer/ml_setup.py View File

@ -1,18 +1,21 @@
import requests
import os
import tarfile
import sys,getpass
import sys
urls = [
"https://s3-ap-northeast-1.amazonaws.com/mycityreport/trainedModels.tar.gz",
"http://download.tensorflow.org/models/object_detection/rfcn_resnet101_coco_2018_01_28.tar.gz",]
"http://download.tensorflow.org/models/object_detection/rfcn_resnet101_coco_2018_01_28.tar.gz",
"http://download.tensorflow.org/models/object_detection/faster_rcnn_resnet101_kitti_2018_01_28.tar.gz"
]
paths = ["../server_side/api/modules", "."]
paths = ["../server_side/api/modules", ".", '../server_side/api/modules']
for i in range(len(urls)):
if i == 0:
continue
url = urls[i]
print("[INFO]: Downloading file: {} to temp.tar.gz!".format(url.split("/")[-1]))
print("[INFO]: Downloadinng file: {} to temp.tar.gz!".format(url.split("/")[-1]))
with open("temp.tar.gz", 'wb') as f:
response = requests.get(url, stream=True)


+ 1
- 1
traffic_analyzer/object_detection/.ipynb_checkpoints/object_detection_tutorial-checkpoint.ipynb View File

@ -39,7 +39,7 @@
"import numpy as np\n",
"import os\n",
"import six.moves.urllib as urllib\n",
"import sys,getpass\n",
"import sys\n",
"import tarfile\n",
"import tensorflow as tf\n",
"import zipfile\n",


+ 1
- 1
traffic_analyzer/object_detection/core/preprocessor.py View File

@ -65,7 +65,7 @@ back to rank 4.
import functools
import inspect
import sys,getpass
import sys
import tensorflow as tf
from tensorflow.python.ops import control_flow_ops


+ 1
- 1
traffic_analyzer/object_detection/object_detection_tutorial.ipynb View File

@ -39,7 +39,7 @@
"import numpy as np\n",
"import os\n",
"import six.moves.urllib as urllib\n",
"import sys,getpass\n",
"import sys\n",
"import tarfile\n",
"import tensorflow as tf\n",
"import zipfile\n",


+ 1
- 1
traffic_analyzer/object_detection/protos/anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/argmax_matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/argmax_matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/bipartite_matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/bipartite_matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/box_predictor_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/box_predictor.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/calibration_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/calibration.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/eval_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/eval.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/faster_rcnn_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/faster_rcnn_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/faster_rcnn_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/faster_rcnn.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/graph_rewriter_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/graph_rewriter.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/grid_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/grid_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/hyperparams_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/hyperparams.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/image_resizer_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/image_resizer.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor


+ 1
- 1
traffic_analyzer/object_detection/protos/input_reader_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/input_reader.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor


+ 1
- 1
traffic_analyzer/object_detection/protos/keypoint_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/keypoint_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/losses_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/losses.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/matcher_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/matcher.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/mean_stddev_box_coder_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/mean_stddev_box_coder.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/model_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/model.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/multiscale_anchor_generator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/multiscale_anchor_generator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/optimizer_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/optimizer.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/pipeline_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/pipeline.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/post_processing_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/post_processing.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/preprocessor_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/preprocessor.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


+ 1
- 1
traffic_analyzer/object_detection/protos/region_similarity_calculator_pb2.py View File

@ -1,7 +1,7 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: object_detection/protos/region_similarity_calculator.proto
import sys,getpass
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save