Browse Source

EWERWER

yigit
Yiğit Çolakoğlu 6 years ago
parent
commit
70dbcb2460
33 changed files with 736 additions and 371 deletions
  1. +0
    -7
      Ev3/.idea/misc.xml
  2. +0
    -8
      Ev3/.idea/modules.xml
  3. +0
    -4
      Ev3/.idea/serialmonitor_settings.xml
  4. +0
    -6
      Ev3/.idea/vcs.xml
  5. +0
    -158
      Ev3/.idea/workspace.xml
  6. +0
    -6
      Ev3/CMakeLists.txt
  7. +0
    -6
      Ev3/main.cpp
  8. +43
    -0
      Ev3/main.py
  9. +237
    -34
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
  10. +450
    -135
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
  11. +0
    -0
      master_app/target/classes/.netbeans_automatic_build
  12. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/Main.class
  13. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class
  14. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class
  15. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class
  16. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class
  17. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class
  18. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$6.class
  19. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class
  20. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$1.class
  21. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$2.class
  22. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$3.class
  23. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$4.class
  24. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$5.class
  25. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$6.class
  26. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$7.class
  27. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$8.class
  28. BIN
      master_app/target/classes/me/yigitcolakoglu/master_app/managementForm.class
  29. BIN
      master_app/target/master_app-1.0-SNAPSHOT.jar
  30. +1
    -1
      master_app/target/maven-archiver/pom.properties
  31. +2
    -3
      master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  32. +3
    -3
      master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  33. +0
    -0
      master_app/target/test-classes/.netbeans_automatic_build

+ 0
- 7
Ev3/.idea/misc.xml View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

+ 0
- 8
Ev3/.idea/modules.xml View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Ev3.iml" filepath="$PROJECT_DIR$/.idea/Ev3.iml" />
</modules>
</component>
</project>

+ 0
- 4
Ev3/.idea/serialmonitor_settings.xml View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SerialMonitorSettings" BaudRate="9600" LineEndingsIndex="0" />
</project>

+ 0
- 6
Ev3/.idea/vcs.xml View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

+ 0
- 158
Ev3/.idea/workspace.xml View File

@ -1,158 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated>
<config projectName="Ev3" targetName="Ev3" />
</generated>
</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="3edb8083-75dc-49ce-8b6f-ab9c8216ff39" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/../MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java" beforeDir="false" afterPath="$PROJECT_DIR$/../MyCity/app/src/main/java/gq/yigit/mycity/MainFragment.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../server_side/api/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/../server_side/api/app.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../server_side/api/modules/car_crash.py" beforeDir="false" afterPath="$PROJECT_DIR$/../server_side/api/modules/car_crash.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../server_side/api/modules/databases/complaints.json" beforeDir="false" afterPath="$PROJECT_DIR$/../server_side/api/modules/databases/complaints.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../server_side/api/modules/user_info.py" beforeDir="false" afterPath="$PROJECT_DIR$/../server_side/api/modules/user_info.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../telnet/main.ino" beforeDir="false" afterPath="$PROJECT_DIR$/../telnet/main.ino" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.cpp">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectConfigurationFiles">
<option name="files">
<list>
<option value="$PROJECT_DIR$/.idea/misc.xml" />
<option value="$PROJECT_DIR$/.idea/modules.xml" />
<option value="$PROJECT_DIR$/.idea/vcs.xml" />
<option value="$PROJECT_DIR$/.idea/serialmonitor_settings.xml" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="31" />
<option name="width" value="1920" />
<option name="height" value="1049" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Ev3" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Ev3" TARGET_NAME="Ev3" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Ev3" RUN_TARGET_NAME="Ev3">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="3edb8083-75dc-49ce-8b6f-ab9c8216ff39" name="Default Changelist" comment="" />
<created>1562175685444</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1562175685444</updated>
<workItem from="1562175707454" duration="602000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="602000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="31" width="1920" height="1049" extended-state="6" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2497332" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="CMake" />
<window_info anchor="bottom" id="Arduino Support" />
<window_info anchor="bottom" id="Database Changes" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Serial Monitor" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/main.cpp">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</component>
</project>

+ 0
- 6
Ev3/CMakeLists.txt View File

@ -1,6 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(Ev3)
set(CMAKE_CXX_STANDARD 14)
add_executable(Ev3 main.cpp)

+ 0
- 6
Ev3/main.cpp View File

@ -1,6 +0,0 @@
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

+ 43
- 0
Ev3/main.py View File

@ -0,0 +1,43 @@
#!/usr/bin/env python3
print("[INFO]: Interpreter started")
from ev3dev.core import *
print("[INFO]: Imported ev3dev.ev3")
import socket
print("[INFO]: Imported socket")
import os
print("[INFO]: Imported os")
import json
print("[INFO]: Imported json")
HOST = '0.0.0.0'
PORT = 3131
mjpeg_loc = "/home/robot/mjpeg-streamer/mjpeg-streamer-experimantal/mjpeg-streamer"
os.spawnl(os.P_DETACH, ' -i "./input_uvc.so -f 15 -r 640x480" -o "./output_http.so -w ./www"')
power = PowerSupply()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.bind((HOST, PORT))
while True:
s.listen()
print("[INFO]: Listening...")
conn, addr = s.accept()
with conn:
print('[INFO]: Connected by', addr)
while True:
try:
data = {
"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'))
except BrokenPipeError:
print("[INFO]: Client disconnected")
break
except KeyboardInterrupt:
s.close()

+ 237
- 34
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form View File

@ -82,15 +82,19 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
<Component id="intersection_label" min="-2" pref="1024" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="185" max="-2" attributes="0"/>
<Component id="ambulance_label" min="-2" pref="250" max="-2" attributes="0"/>
<EmptySpace pref="204" max="32767" attributes="0"/>
<Component id="camera_full_label" min="-2" pref="1280" max="-2" attributes="0"/>
<EmptySpace pref="31" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="ambulance_button" min="-2" pref="247" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="475" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="fps_label" min="-2" max="-2" attributes="0"/>
@ -105,10 +109,13 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="52" max="-2" attributes="0"/>
<Component id="fps_label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="88" max="-2" attributes="0"/>
<Component id="ambulance_label" min="-2" pref="280" max="-2" attributes="0"/>
<Component id="camera_full_label" min="-2" pref="720" max="-2" attributes="0"/>
<EmptySpace pref="27" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="ambulance_button" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="manage_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
@ -121,31 +128,25 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="intersection_label">
<Component class="javax.swing.JLabel" name="camera_full_label">
<Properties>
<Property name="alignmentY" type="float" value="0.0"/>
<Property name="name" type="java.lang.String" value="" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="ambulance_label">
<Component class="javax.swing.JButton" name="ambulance_button">
<Properties>
<Property name="name" type="java.lang.String" value="" noResource="true"/>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ambulance_buttonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="fps_label">
<Component class="javax.swing.JLabel" name="camera_cut_label">
<Properties>
<Property name="text" type="java.lang.String" value="0 FPS"/>
<Property name="text" type="java.lang.String" value="camera_cut"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Traffic Lights">
<Property name="tabTitle" type="java.lang.String" value="Traffic Lights"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Container class="javax.swing.JPanel" name="jPanel3">
<Layout>
<DimensionLayout dim="0">
@ -188,8 +189,8 @@
<Container class="javax.swing.JPanel" name="jPanel4">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="tab2">
<Property name="tabTitle" type="java.lang.String" value="tab2"/>
<JTabbedPaneConstraints tabName="Lights">
<Property name="tabTitle" type="java.lang.String" value="Lights"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
@ -198,30 +199,232 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="493" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="276" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="1074" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="241" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="125" max="-2" attributes="0"/>
<Component id="jPanel5" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="526" max="32767" attributes="0"/>
<Component id="jPanel6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" 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="115" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="686" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel6" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel5" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel5">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="109" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="intersect_1_G" min="-2" pref="196" max="-2" attributes="0"/>
<Component id="intersect_1_R" min="-2" pref="196" max="-2" attributes="0"/>
<Component id="intersect_1_Y" min="-2" pref="196" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="107" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
<Component id="intersect_1_R" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
<Component id="intersect_1_Y" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
<Component id="intersect_1_G" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace pref="49" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="intersect_1_Y">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="intersect_1_G">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="intersect_1_R">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="159" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="intersect_2_G" min="-2" pref="196" max="-2" attributes="0"/>
<Component id="intersect_2_R" min="-2" pref="196" max="-2" attributes="0"/>
<Component id="intersect_2_Y" min="-2" pref="196" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="163" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Component id="intersect_2_R" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="53" max="-2" attributes="0"/>
<Component id="intersect_2_Y" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="intersect_2_G" min="-2" pref="196" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="intersect_2_Y">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="intersect_2_G">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="intersect_2_R">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="99" green="99" red="ff" type="rgb"/>
</Property>
<Property name="opaque" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="deneme"/>
<Property name="text" type="java.lang.String" value="Intersection 1"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="text" type="java.lang.String" value="Intersection 2"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel7">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Robot Cam">
<Property name="tabTitle" type="java.lang.String" value="Robot Cam"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="449" max="-2" attributes="0"/>
<Component id="robot_cam_label" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="1173" 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="243" max="-2" attributes="0"/>
<Component id="robot_cam_label" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="573" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="robot_cam_label">
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>


+ 450
- 135
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java View File

@ -13,11 +13,13 @@ import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.Base64;
import javax.imageio.ImageIO;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import net.schmizz.sshj.common.IOUtils;
import org.json.JSONObject;
/**
@ -36,6 +38,7 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
private ServerSocket server;
private Socket client;
private Thread running = null;
private boolean listening = false;
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@ -47,13 +50,40 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jPanel1 = new javax.swing.JPanel();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel5 = new javax.swing.JPanel();
intersection_label = new javax.swing.JLabel();
ambulance_label = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
camera_full_label = new javax.swing.JLabel();
ambulance_button = new javax.swing.JButton();
camera_cut_label = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
gpu_usage = new javax.swing.JLabel();
gpu_temp = new javax.swing.JLabel();
cpu_usage = new javax.swing.JLabel();
cpu_temp = new javax.swing.JLabel();
ram_usage = new javax.swing.JLabel();
ram_temp = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
fan_rpm = new javax.swing.JLabel();
fps_label = new javax.swing.JLabel();
manage_button = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
intersect_1_Y = new javax.swing.JLabel();
intersect_1_G = new javax.swing.JLabel();
intersect_1_R = new javax.swing.JLabel();
jPanel6 = new javax.swing.JPanel();
intersect_2_Y = new javax.swing.JLabel();
intersect_2_G = new javax.swing.JLabel();
intersect_2_R = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jPanel7 = new javax.swing.JPanel();
robot_cam_label = new javax.swing.JLabel();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@ -79,43 +109,14 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
});
intersection_label.setAlignmentY(0.0F);
ambulance_label.setName(""); // NOI18N
fps_label.setText("0 FPS");
camera_full_label.setText(" ");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(30, 30, 30)
.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(185, 185, 185)
.addComponent(ambulance_label, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(204, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(fps_label)
.addGap(168, 168, 168))))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(fps_label)
.addGap(88, 88, 88)
.addComponent(ambulance_label, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(intersection_label, javax.swing.GroupLayout.PREFERRED_SIZE, 768, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(181, Short.MAX_VALUE))
);
ambulance_button.setText("Start");
ambulance_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ambulance_buttonActionPerformed(evt);
}
});
jTabbedPane1.addTab("Intersection & Ambulance", jPanel5);
@ -146,39 +147,214 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jTabbedPane1.addTab("Traffic Lights", jPanel6);
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 1693, Short.MAX_VALUE)
fan_rpm.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
fan_rpm.setText("2500 RPM");
fps_label.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
fps_label.setText("60 FPS");
manage_button.setText("Management");
manage_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
manage_buttonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(camera_full_label, javax.swing.GroupLayout.PREFERRED_SIZE, 1280, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(ambulance_button, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(475, 475, 475)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fan_rpm, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(fps_label, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86)))
.addGap(18, 18, 18))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(camera_cut_label, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(manage_button, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(95, 95, 95))))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 978, Short.MAX_VALUE)
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(camera_full_label, javax.swing.GroupLayout.PREFERRED_SIZE, 720, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ambulance_button)
.addComponent(manage_button))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(camera_cut_label, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(180, 180, 180)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(fan_rpm, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(fps_label, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(110, 110, 110))))
);
jTabbedPane1.addTab("Loads", jPanel7);
jLabel8.setText("deneme");
jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
intersect_1_Y.setBackground(new java.awt.Color(204, 204, 204));
intersect_1_Y.setForeground(new java.awt.Color(204, 204, 204));
intersect_1_Y.setOpaque(true);
intersect_1_G.setBackground(new java.awt.Color(204, 204, 204));
intersect_1_G.setForeground(new java.awt.Color(204, 204, 204));
intersect_1_G.setOpaque(true);
intersect_1_R.setBackground(new java.awt.Color(204, 204, 204));
intersect_1_R.setForeground(new java.awt.Color(204, 204, 204));
intersect_1_R.setOpaque(true);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addContainerGap(109, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intersect_1_G, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(intersect_1_R, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(intersect_1_Y, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(107, 107, 107))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(intersect_1_R, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45)
.addComponent(intersect_1_Y, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45)
.addComponent(intersect_1_G, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(49, Short.MAX_VALUE))
);
jPanel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
intersect_2_Y.setBackground(new java.awt.Color(204, 204, 204));
intersect_2_Y.setForeground(new java.awt.Color(204, 204, 204));
intersect_2_Y.setOpaque(true);
intersect_2_G.setBackground(new java.awt.Color(204, 204, 204));
intersect_2_G.setForeground(new java.awt.Color(204, 204, 204));
intersect_2_G.setOpaque(true);
intersect_2_R.setBackground(new java.awt.Color(204, 204, 204));
intersect_2_R.setForeground(new java.awt.Color(255, 153, 153));
intersect_2_R.setOpaque(true);
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
.addContainerGap(159, Short.MAX_VALUE)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intersect_2_G, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(intersect_2_R, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(intersect_2_Y, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(163, 163, 163))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(intersect_2_R, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(53, 53, 53)
.addComponent(intersect_2_Y, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(intersect_2_G, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(38, 38, 38))
);
jLabel8.setText("Intersection 1");
jLabel9.setText("Intersection 2");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(493, 493, 493)
.addGap(276, 276, 276)
.addComponent(jLabel8)
.addContainerGap(1074, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel9)
.addGap(241, 241, 241))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addGap(125, 125, 125)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 526, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(115, 115, 115)
.addComponent(jLabel8)
.addContainerGap(686, Short.MAX_VALUE))
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jLabel8))
.addGap(4, 4, 4)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jTabbedPane1.addTab("Lights", jPanel4);
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGap(449, 449, 449)
.addComponent(robot_cam_label)
.addContainerGap(1173, Short.MAX_VALUE))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGap(243, 243, 243)
.addComponent(robot_cam_label)
.addContainerGap(573, Short.MAX_VALUE))
);
jTabbedPane1.addTab("tab2", jPanel4);
jTabbedPane1.addTab("Robot Cam", jPanel7);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -255,9 +431,42 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}//GEN-LAST:event_jTabbedPane1MouseExited
private void jTabbedPane1MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseEntered
if(!listening){
jTabbedPane1.addChangeListener(this);
System.out.println("Added listener");
listening = true;
}
}//GEN-LAST:event_jTabbedPane1MouseEntered
private void manage_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manage_buttonActionPerformed
managementForm settings = new managementForm();
settings.setVisible(true);
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
/**
* @param args the command line arguments
*/
@ -283,6 +492,7 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new cameraForm().setVisible(true);
}});
@ -290,31 +500,50 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
public void onCreate(int port, String name) throws Exception{
boolean run = true;
if ("lights".equals(name)) {
Socket clientSocket = new Socket("192.168.2.174",69);
int c;
InputStream in = clientSocket.getInputStream();
String message = "";
while((c=in.read()) != -1){
if (c == 10 || c == 13) {
break;
}
message += (char) c;
if (name == "robot") {
while (run) {
BufferedImage image = null;
URL img_url = new URL("http://10.10.26.141:8080/?action=snapshot");
image = ImageIO.read(img_url);
robot_cam_label.setIcon(new ImageIcon(image));
URL obj = new URL("http://10.10.26.164:5001/ai");
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
byte[] imageBytes = IOUtils.toByteArray(img_url);
String base64 = Base64.getEncoder().encodeToString(imageBytes);
String params = "type=coco&img=" + 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());
Graphics2D g2d = image.createGraphics();
}
this.light_1_label.setText("Light 1: " + message.charAt(0));
this.light_2_label.setText("Light 2: " + message.charAt(2));
System.out.println(message);
return;
}
this.intersection_label.setIcon(new ImageIcon());
this.ambulance_label.setIcon(new ImageIcon());
this.camera_cut_label.setIcon(new ImageIcon());
this.camera_full_label.setIcon(new ImageIcon());
String fromClient = "";
String toClient;
server = new ServerSocket(port);
System.out.println("wait for connection on port " + port);
jTabbedPane1.addChangeListener(this);
client = server.accept();
System.out.println("got connection on port " + port);
BufferedImage image = null;
@ -322,70 +551,99 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
int null_reps = 0;
int fps_sum = 0;
int reps = 0;
while(run) {
try{
long start = System.currentTimeMillis();
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());
JSONObject json = new JSONObject(fromClient);
byte[] decodedBytes = Base64.getDecoder().decode(json.getString("image_full"));
ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes);
image = ImageIO.read(bis);
bis.close();
if ("cams".equals(name)) {
this.intersection_label.setIcon(new ImageIcon(resizeImage(image,1024, 768)));
if(name.equals("cams")){
while(run) {
try{
long start = System.currentTimeMillis();
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());
JSONObject json = new JSONObject(fromClient);
byte[] decodedBytes = Base64.getDecoder().decode(json.getString("image_full"));
ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes);
image = ImageIO.read(bis);
bis.close();
JSONObject dims = json.getJSONObject("image_sizes");
this.ambulance_label.setIcon(new ImageIcon(resizeImage(image.getSubimage(dims.getInt("x"), dims.getInt("y"), dims.getInt("width"), dims.getInt("height")),250,280)));
} else if ("Loads".equals(name)) {
this.camera_full_label.setIcon(new ImageIcon(resizeImage(image,1280,720)));
this.camera_cut_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(daqqta.getString("gpu_load"));
this.gpu_temp.setText(data.getString("gpu_temp"));
this.gpu_usage.setText(data.getString("gpu_load"));
this.cpu_temp.setText(data.getString("cpu_temp"));
this.cpu_usage.setText(data.getString("cpu_load"));
this.ram_temp.setText(data.getString("mem_temp"));
this.ram_usage.setText(data.getString("mem_load"));
this.fan_rpm.setText(data.getString("fan_speed"));*/
}
null_reps=0;
long end = System.currentTimeMillis();
float sec = (end - start) / 1000F;
fps_sum += Math.round(1/sec);
reps+=1;
if(reps%10==0){
this.fps_label.setText(fps_sum/10 + " FPS");
fps_sum=0;
this.fan_rpm.setText(data.getString("fan_speed"));
null_reps=0;
long end = System.currentTimeMillis();
float sec = (end - start) / 1000F;
fps_sum += Math.round(1/sec);
reps+=1;
if(reps%10==0){
this.fps_label.setText(fps_sum/10 + " FPS");
fps_sum=0;
}
}
}else{
null_reps +=1;
}
}else{
null_reps +=1;
}
catch(Exception e){
System.out.println(fromClient);
System.out.println(e.toString());
null_reps+=1;
}
if (null_reps >= 1000000000){
run = false;
System.out.println("socket closed");
}
}
catch(Exception e){
System.out.println(fromClient);
System.out.println(e.toString());
null_reps+=1;
}
if (null_reps >= 1000000000){
run = false;
System.out.println("socket closed");
}
server.close();
client.close();
this.camera_cut_label.setIcon(new ImageIcon());
this.camera_full_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 = {{intersect_1_R,intersect_1_Y,intersect_1_G},{intersect_2_R,intersect_2_Y,intersect_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));
}
}
}
}
}
}
server.close();
client.close();
this.ambulance_label.setIcon(new ImageIcon());
this.intersection_label.setIcon(new ImageIcon());
JOptionPane.showMessageDialog(this, name +" socket server down!");
running.stop();
}
public static BufferedImage resizeImage(final Image image, int width, int height) {
@ -401,18 +659,69 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
return bufferedImage;
}
@Override
public void stateChanged(ChangeEvent changeEvent){
System.out.println("TEST");
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
int index = sourceTabbedPane.getSelectedIndex();
System.out.println("Tab changed to: " + sourceTabbedPane.getTitleAt(index));
public void stateChanged(ChangeEvent e){
System.out.println("Tab: " + jTabbedPane1.getSelectedIndex());
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());
}
}
switch (jTabbedPane1.getSelectedIndex()) {
case 0:
running = new Thread(() -> {
try{
onCreate(8485,"cams");
}catch(Exception ex){
System.out.println(e.toString());
}
});
running.start();
break;
case 1:
running = new Thread(() -> {
try{
onCreate(69,"lights");
}catch(Exception ex){
System.out.println(e.toString());
}
});
running.start();
break;
case 2:
running = new Thread(() -> {
try{
onCreate(0,"robot");
}catch(Exception ex){
System.out.println(e.toString());
}
});
running.start();
break;
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel ambulance_label;
private javax.swing.JButton ambulance_button;
private javax.swing.JLabel camera_cut_label;
private javax.swing.JLabel camera_full_label;
private javax.swing.JLabel cpu_temp;
private javax.swing.JLabel cpu_usage;
private javax.swing.JLabel fan_rpm;
private javax.swing.JLabel fps_label;
private javax.swing.JLabel gpu_temp;
private javax.swing.JLabel gpu_usage;
private javax.swing.JButton intersection_button;
private javax.swing.JLabel intersect_1_G;
private javax.swing.JLabel intersect_1_R;
private javax.swing.JLabel intersect_1_Y;
private javax.swing.JLabel intersect_2_G;
private javax.swing.JLabel intersect_2_R;
private javax.swing.JLabel intersect_2_Y;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
@ -421,13 +730,19 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
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;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel light_1_label;
private javax.swing.JLabel light_2_label;
private javax.swing.JButton manage_button;
private javax.swing.JLabel ram_temp;
private javax.swing.JLabel ram_usage;
private javax.swing.JLabel robot_cam_label;
// End of variables declaration//GEN-END:variables


+ 0
- 0
master_app/target/classes/.netbeans_automatic_build View File


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


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.class View File


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


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


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


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


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


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


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


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


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


BIN
master_app/target/master_app-1.0-SNAPSHOT.jar View File


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

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

+ 2
- 3
master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst View File

@ -2,14 +2,13 @@ me/yigitcolakoglu/master_app/managementForm$4.class
me/yigitcolakoglu/master_app/cameraForm$3.class
me/yigitcolakoglu/master_app/cameraForm$2.class
me/yigitcolakoglu/master_app/managementForm$3.class
me/yigitcolakoglu/master_app/cameraForm$5.class
me/yigitcolakoglu/master_app/Main.class
me/yigitcolakoglu/master_app/managementForm$7.class
me/yigitcolakoglu/master_app/cameraForm$1.class
me/yigitcolakoglu/master_app/managementForm$7.class
me/yigitcolakoglu/master_app/managementForm.class
me/yigitcolakoglu/master_app/managementForm$1.class
me/yigitcolakoglu/master_app/managementForm$2.class
me/yigitcolakoglu/master_app/managementForm$8.class
me/yigitcolakoglu/master_app/managementForm$2.class
me/yigitcolakoglu/master_app/managementForm$6.class
me/yigitcolakoglu/master_app/managementForm$9.class
me/yigitcolakoglu/master_app/cameraForm$4.class


+ 3
- 3
master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst View File

@ -1,3 +1,3 @@
/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
/home/yigit/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
/home/yigit/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
/home/yigit/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java

+ 0
- 0
master_app/target/test-classes/.netbeans_automatic_build View File


Loading…
Cancel
Save