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