Tracking Camera Network - person-in-hangang/HanRiver GitHub Wiki
Connect with Server - Socket Settings
This is a connection operation for socket communication with the server. Through this connection, Tracking Application can send Trajectory and Falling point(coordinate) .
Step 1. Add the following permission to the manifest.
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
...
Step 2. Enter the IP address and PORT number of the server.
In CameraFragment.java
line 755 -send trajectory
public void send_server(Bitmap bm){
try{
Socket socket = new Socket("210.102.181.248",7002);
OutputStream outputStream = socket.getOutputStream();
DataOutputStream dos = new DataOutputStream(outputStream);
}
ByteArrayOutputStream baos =new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG,100,baos);
byte[] bImage = baos.toByteArray();
base64 = Base64.encodeToString(bImage,0);
img_data =getImageByte(bm);
String token = "@";
byte[]size =getByte(img_data.length);
byte[]total =new byte[size.length + token.getBytes(Charset.defaultCharset()).length + img_data.length];
System.arraycopy(size, 0, total, 0,size.length);
System.arraycopy(token.getBytes(), 0, total, size.length, token.getBytes().length);
System.arraycopy(img_data,0,total,(size.length + token.getBytes().length), img_data.length);
meg = ":6:" ;
dos.writeUTF(meg + "camera2_img");
dos.write(total,0,total.length);
dos.flush();
dos.close();
socket.close();
}
line 830 - send corrdinates
public void send_server2(double x, double y){
try{
Socket socket = new Socket("210.102.181.248",7002);
OutputStream outputStream = socket.getOutputStream();
DataOutputStream dos = new DataOutputStream(outputStream);
meg = ":4:" + Double.toString(x) + "," + Double.toString(y);
dos.writeUTF(meg);
dos.close();
}