Efe Aydın 6 years ago
parent
commit
aed1c3a239
5 changed files with 384 additions and 934 deletions
  1. +50
    -11
      Ev3/main.py
  2. +1
    -1
      master_app/nbactions.xml
  3. +5
    -0
      master_app/pom.xml
  4. +104
    -451
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
  5. +224
    -471
      master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java

+ 50
- 11
Ev3/main.py View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
print("[INFO]: Interpreter started")
from ev3dev.core import *
import ev3dev.ev3 as ev3
print("[INFO]: Imported ev3dev.ev3")
import socket
print("[INFO]: Imported socket")
@ -9,12 +10,32 @@ print("[INFO]: Imported os")
import json
print("[INFO]: Imported json")
state = True
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)
def stop():
motor1.stop()
motor2.stop()
cam.stop()
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"')
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))
exit()
power = PowerSupply()
if power.measured_volts < 7.1:
print("Change the battery.")
exit()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
@ -25,19 +46,37 @@ 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 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:
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'))
recieved = conn.recv(1024)
if not recieved:
pass
else:
recieved = recieved.decode().strip()[-1]
print(recieved)
if recieved == 's':
stop()
elif recieved == 'm':
move(500)
elif recieved == 'i':
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")
stop()
break
except KeyboardInterrupt:
stop()
s.close()

+ 1
- 1
master_app/nbactions.xml View File

@ -10,7 +10,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-classpath %classpath ${packageClassName} ips.json</exec.args>
<exec.args>-classpath %classpath me.yigitcolakoglu.master_app.Main ips.json</exec.args>
<exec.executable>java</exec.executable>
<exec.workingdir>/home/efeaydin/Masaüstü/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app</exec.workingdir>
</properties>


+ 5
- 0
master_app/pom.xml View File

@ -16,6 +16,11 @@
<artifactId>sshj</artifactId>
<version>0.27.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>


+ 104
- 451
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form View File

@ -82,19 +82,15 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" 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="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="camera_full_label" min="-2" pref="1280" max="-2" attributes="0"/>
<EmptySpace pref="31" max="32767" 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"/>
</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"/>
@ -109,13 +105,10 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" 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"/>
<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"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
@ -128,25 +121,31 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="camera_full_label">
<Component class="javax.swing.JLabel" name="intersection_label">
<Properties>
<Property name="name" type="java.lang.String" value="" noResource="true"/>
<Property name="alignmentY" type="float" value="0.0"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="ambulance_button">
<Component class="javax.swing.JLabel" name="ambulance_label">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
<Property name="name" type="java.lang.String" value="" noResource="true"/>
</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="camera_cut_label">
<Component class="javax.swing.JLabel" name="fps_label">
<Properties>
<Property name="text" type="java.lang.String" value="camera_cut"/>
<Property name="text" type="java.lang.String" value="0 FPS"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel3">
</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>
<Layout>
<DimensionLayout dim="0">
@ -186,216 +185,11 @@
</Component>
</SubComponents>
</Container>
<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="Lights">
<Property name="tabTitle" type="java.lang.String" value="Lights"/>
</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="276" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" 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 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="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 tabName="Loads">
<Property name="tabTitle" type="java.lang.String" value="Loads"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
@ -403,33 +197,21 @@
<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>
<EmptySpace min="0" pref="1693" 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="243" max="-2" attributes="0"/>
<Component id="robot_cam_label" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="573" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="978" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="robot_cam_label">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Lights">
<Property name="tabTitle" type="java.lang.String" value="Lights"/>
<JTabbedPaneConstraints tabName="Robot">
<Property name="tabTitle" type="java.lang.String" value="Robot"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
@ -437,19 +219,33 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="276" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" 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 type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="robot_cam_label" pref="1469" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="move_robot" min="-2" max="-2" attributes="0"/>
<Component id="robot_stop" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="current_drawn_label" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="longitude_label" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="battery_voltage_label" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="latitude_label" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
@ -457,210 +253,67 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" 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"/>
<Component id="robot_cam_label" min="-2" pref="480" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="move_robot" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="robot_stop" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="battery_voltage_label" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="current_drawn_label" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="longitude_label" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="latitude_label" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="182" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel5">
<Component class="javax.swing.JLabel" name="robot_cam_label">
</Component>
<Component class="javax.swing.JLabel" name="battery_voltage_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.BevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="text" type="java.lang.String" value="Battery Voltage"/>
</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">
</Component>
<Component class="javax.swing.JLabel" name="current_drawn_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.BevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
<Property name="text" type="java.lang.String" value="Current Drawn"/>
</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">
</Component>
<Component class="javax.swing.JLabel" name="latitude_label">
<Properties>
<Property name="text" type="java.lang.String" value="Intersection 1"/>
<Property name="text" type="java.lang.String" value="Latitude"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Component class="javax.swing.JLabel" name="longitude_label">
<Properties>
<Property name="text" type="java.lang.String" value="Intersection 2"/>
<Property name="text" type="java.lang.String" value="Longitude"/>
</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 class="javax.swing.JButton" name="robot_stop">
<Properties>
<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>
<Component class="javax.swing.JButton" name="move_robot">
<Properties>
<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>
</SubComponents>
</Container>


+ 224
- 471
master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java View File

@ -12,6 +12,8 @@ import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.Base64;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.ImageIcon;
@ -19,7 +21,7 @@ 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.apache.commons.io.IOUtils;
import org.json.JSONObject;
/**
@ -33,12 +35,16 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
*/
public cameraForm() {
initComponents();
initialize();
}
private ServerSocket server;
private Socket client;
private Thread running = null;
private boolean listening = false;
private String ROBOT_IP = "10.42.0.9";
private String AI_IP = "10.10.26.161";
private Socket robotSocket;
private DataOutputStream out;
private BufferedReader in;
/**
* 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
@ -50,40 +56,22 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jPanel1 = new javax.swing.JPanel();
jTabbedPane1 = new javax.swing.JTabbedPane();
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();
intersection_label = new javax.swing.JLabel();
ambulance_label = new javax.swing.JLabel();
fps_label = 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();
light_1_label = new javax.swing.JLabel();
light_2_label = new javax.swing.JLabel();
jPanel7 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
robot_cam_label = new javax.swing.JLabel();
battery_voltage_label = new javax.swing.JLabel();
current_drawn_label = new javax.swing.JLabel();
latitude_label = new javax.swing.JLabel();
longitude_label = new javax.swing.JLabel();
robot_stop = new javax.swing.JButton();
move_robot = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@ -109,14 +97,43 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
});
camera_full_label.setText(" ");
intersection_label.setAlignmentY(0.0F);
ambulance_button.setText("Start");
ambulance_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ambulance_buttonActionPerformed(evt);
}
});
ambulance_label.setName(""); // NOI18N
fps_label.setText("0 FPS");
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))
);
jTabbedPane1.addTab("Intersection & Ambulance", jPanel5);
@ -147,16 +164,48 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jTabbedPane1.addTab("Traffic Lights", jPanel6);
fan_rpm.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
fan_rpm.setText("2500 RPM");
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)
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 978, Short.MAX_VALUE)
);
jTabbedPane1.addTab("Loads", jPanel7);
fps_label.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
fps_label.setText("60 FPS");
battery_voltage_label.setText("Battery Voltage");
manage_button.setText("Management");
manage_button.addActionListener(new java.awt.event.ActionListener() {
current_drawn_label.setText("Current Drawn");
latitude_label.setText("Latitude");
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) {
manage_buttonActionPerformed(evt);
robot_stopActionPerformed(evt);
}
});
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);
}
});
@ -165,328 +214,48 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.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()
.addComponent(robot_cam_label, javax.swing.GroupLayout.DEFAULT_SIZE, 1469, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(move_robot)
.addComponent(robot_stop))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(current_drawn_label)
.addComponent(longitude_label))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(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))))
.addComponent(battery_voltage_label)
.addComponent(latitude_label))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(robot_cam_label, javax.swing.GroupLayout.PREFERRED_SIZE, 480, javax.swing.GroupLayout.PREFERRED_SIZE)
.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);
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(276, 276, 276)
.addComponent(jLabel8)
.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()
.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("Robot Cam", jPanel7);
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(276, 276, 276)
.addComponent(jLabel8)
.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()
.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))
.addComponent(move_robot)
.addGap(18, 18, 18)
.addComponent(robot_stop)))
.addGap(18, 18, 18)
.addComponent(battery_voltage_label)
.addGap(18, 18, 18)
.addComponent(current_drawn_label, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(longitude_label)
.addGap(18, 18, 18)
.addComponent(latitude_label)
.addContainerGap(182, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Robot Cam", jPanel7);
jTabbedPane1.addTab("Robot", jPanel2);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -507,56 +276,7 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
pack();
}// </editor-fold>//GEN-END:initComponents
public void initialize() {
jTabbedPane1.addChangeListener(new ChangeListener() {
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(e.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(8484,"lights");
}catch(Exception ex){
System.out.println(e.toString());
}
});
running.start();
break;
case 2:
running = new Thread(() -> {
try{
onCreate(8483,"Loads");
}catch(Exception ex){
System.out.println(e.toString());
}
});
running.start();
break;
}
}
});
}
private void jTabbedPane1MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseExited
// TODO add your handling code here:
@ -599,6 +319,38 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
}//GEN-LAST:event_ambulance_buttonActionPerformed
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 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 move_robotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_move_robotActionPerformed
try {
out.writeUTF("m");
} catch (IOException ex) {
System.out.println(ex.toString());
}
}//GEN-LAST:event_move_robotActionPerformed
private void robot_stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_robot_stopActionPerformed
try {
out.writeUTF("s");
} catch (IOException ex) {
System.out.println(ex.toString());
}
}//GEN-LAST:event_robot_stopActionPerformed
/**
* @param args the command line arguments
*/
@ -632,22 +384,43 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
public void onCreate(int port, String name) throws Exception{
boolean run = true;
if (name == "robot") {
if (name.equals("robot")) {
robotSocket = new Socket(ROBOT_IP, 3131);
out = new DataOutputStream(robotSocket.getOutputStream());
in = new BufferedReader(new InputStreamReader(robotSocket.getInputStream()));
while (run) {
BufferedImage image = null;
URL img_url = new URL("http://10.10.26.141:8080/?action=snapshot");
out.writeUTF("i");
String resp = in.readLine();
System.out.println(resp);
JSONObject values = new JSONObject(resp);
System.out.println(values.getString("lat"));
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"));
BufferedImage image;
URL img_url = new URL(String.format("http://%s:8080/?action=snapshot", ROBOT_IP));
image = ImageIO.read(img_url);
robot_cam_label.setIcon(new ImageIcon(image));
int width = image.getWidth();
int height = image.getHeight();
BufferedImage dest = new BufferedImage(height, width, image.getType());
Graphics2D graphics2D = dest.createGraphics();
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(dest));
URL obj = new URL("http://10.10.26.164:5001/ai");
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, "jpg", out);
byte[] bytes = out.toByteArray();
String base64 = Base64.getEncoder().encodeToString(bytes);
byte[] imageBytes = IOUtils.toByteArray(img_url);
String base64 = Base64.getEncoder().encodeToString(imageBytes);
String params = "type=coco&img=" + base64;
String params = "type=damage&img=" + base64;
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
@ -665,10 +438,10 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
in.close();
JSONObject json = new JSONObject(response.toString());
Graphics2D g2d = image.createGraphics();
}
return;
}
this.camera_cut_label.setIcon(new ImageIcon());
/*this.camera_cut_label.setIcon(new ImageIcon());
this.camera_full_label.setIcon(new ImageIcon());
String fromClient = "";
String toClient;
@ -748,34 +521,32 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
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()));
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
fromClient = in.readLine();
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));
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));
}
}
}
}
}
}
}
}*/
}
public static BufferedImage resizeImage(final Image image, int width, int height) {
@ -810,7 +581,7 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
try{
onCreate(8485,"cams");
}catch(Exception ex){
System.out.println(e.toString());
System.out.println(ex.toString());
}
});
running.start();
@ -825,12 +596,12 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
});
running.start();
break;
case 2:
case 3:
running = new Thread(() -> {
try{
onCreate(0,"robot");
}catch(Exception ex){
System.out.println(e.toString());
System.out.println(ex.toString());
}
});
running.start();
@ -839,42 +610,24 @@ public class cameraForm extends javax.swing.JFrame implements ChangeListener{
}
// Variables declaration - do not modify//GEN-BEGIN:variables
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 ambulance_label;
private javax.swing.JLabel battery_voltage_label;
private javax.swing.JLabel current_drawn_label;
private javax.swing.JLabel fps_label;
private javax.swing.JLabel gpu_temp;
private javax.swing.JLabel gpu_usage;
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;
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.JLabel intersection_label;
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.JButton manage_button;
private javax.swing.JLabel ram_temp;
private javax.swing.JLabel ram_usage;
private javax.swing.JLabel latitude_label;
private javax.swing.JLabel light_1_label;
private javax.swing.JLabel light_2_label;
private javax.swing.JLabel longitude_label;
private javax.swing.JButton move_robot;
private javax.swing.JLabel robot_cam_label;
private javax.swing.JButton robot_stop;
// End of variables declaration//GEN-END:variables


Loading…
Cancel
Save