commit after race

master
UnknownObject 2 years ago
parent 7dd9bd8b64
commit 4111395a42

@ -39,6 +39,8 @@ public class Commands
//形状颜色
public static byte COLOR_SHAPE_SUCCESS = (byte) 0xA6;
public static byte COLOR_SHAPE_DATA_PART2 = (byte) 0xC6;
public static byte COLOR_SHAPE_DATA_PART3 = (byte) 0xD6;
public static byte COLOR_SHAPE_FAILED = (byte) 0xB6;
//交通标志

@ -19,6 +19,18 @@ public class Flags
public static final int CAMERA_DOWN = 2;
public static final int CAMERA_LEFT = 4;
public static final int CAMERA_RIGHT = 6;
public static final int CAMERA_STEP_0 = 0;
public static final int CAMERA_STEP_1 = 1;
public static final int CAMERA_STEP_2 = 2;
public static final int CAMERA_RE_INIT = 2;
public static final int CAMERA_SET_POS_1 = 32;
public static final int CAMERA_GET_POS_1 = 33;
public static final int CAMERA_SET_POS_2 = 34;
public static final int CAMERA_GET_POS_2 = 35;
public static final int CAMERA_SET_POS_3 = 36;
public static final int CAMERA_GET_POS_3 = 37;
public static final int CAMERA_SET_POS_4 = 38;
public static final int CAMERA_GET_POS_4 = 39;
//主/从车移动控制指令
public static final byte CMD_PACKET_MAIN_CAR = (byte) 0xAA;

@ -57,11 +57,51 @@ public class ShapeColorResult
if (storage.containsKey(color) && Objects.requireNonNull(storage.get(color)).containsKey(shape))
return Objects.requireNonNull(Objects.requireNonNull(storage.get(color)).get(shape));
else
return -1;
return 0;
}
catch (Exception e)
{
return -2;
return 0;
}
}
public int GetValue(GlobalColor color)
{
try
{
if (storage.containsKey(color))
{
AtomicInteger cnt = new AtomicInteger();
HashMap<GlobalShape, Integer> spec_color = storage.get(color);
if (spec_color == null)
return 0;
spec_color.forEach((s, c) -> cnt.addAndGet(c));
return cnt.intValue();
}
else
return 0;
}
catch (Exception e)
{
return 0;
}
}
public int GetValue(GlobalShape shape)
{
try
{
AtomicInteger cnt = new AtomicInteger();
storage.forEach((c, map) -> map.forEach((s, _c) ->
{
if (s == shape)
cnt.addAndGet(_c);
}));
return cnt.intValue();
}
catch (Exception e)
{
return 0;
}
}

@ -43,6 +43,7 @@ import com.uns.maincar.constants.Commands;
import com.uns.maincar.constants.Flags;
import com.uns.maincar.constants.Flags.TrafficLightColors;
import com.uns.maincar.constants.GlobalColor;
import com.uns.maincar.constants.GlobalShape;
import com.uns.maincar.cpp_interface.CarLicense;
import com.uns.maincar.cpp_interface.ColoredQRDecoder;
import com.uns.maincar.cpp_interface.EnvTest;
@ -72,7 +73,7 @@ public class MainActivity extends AppCompatActivity
//数据接收处理器
private final Handler recvHandler;
//主车相机地址,默认值不重要
private String IPCamera = "192.168.1.101:81";
private String IPCamera = "10.254.254.100";
//摄像头当前图像
private Bitmap currImage;
//存储小车的IP
@ -199,7 +200,7 @@ public class MainActivity extends AppCompatActivity
break;
//收到SHAPE_COLOR指令开始识别形状颜色回传识别成功的数据
case Commands.RECEIVE_SHAPE_COLOR:
dtc_client.Send(RecognizeShapeColor());
RecognizeShapeColor();
break;
//收到CAR_ID指令开始识别车牌号回传识别成功的数据
case Commands.RECEIVE_CAR_ID:
@ -249,7 +250,7 @@ public class MainActivity extends AppCompatActivity
TextFilter filter = new TextFilter();
for (String data : qr_data)
{
String processed_data = filter.LetterAndNumber(data);
String processed_data = filter.ChineseOnly(data);
if (processed_data.length() > 0)
{
validate_result = processed_data;
@ -285,9 +286,11 @@ public class MainActivity extends AppCompatActivity
//识别二维码
private byte[] RecognizeQrCode(boolean colored, GlobalColor target_color)
{
ToastLog("Begin QR Code", false, true);
CommandEncoder encoder = new CommandEncoder();
if (!colored)
{
ToastLog("Start Black-White QR", false, true);
ArrayList<String> qr_result = new ArrayList<>();
if (!QRDecoder.BeginQRDecode(currImage))
return encoder.GenerateCommand(Commands.QR_FAILED, (byte) 0, (byte) 0, (byte) 0);
@ -296,11 +299,8 @@ public class MainActivity extends AppCompatActivity
if (qr_result.size() <= 0)
return encoder.GenerateCommand(Commands.QR_FAILED, (byte) 0, (byte) 0, (byte) 0);
else
{
qr_result.forEach(qr -> ToastLog(qr, false, true));
return ProcessQRData(qr_result);
}
}
else
{
boolean success = ColoredQRDecoder.BeginQRDecode(currImage, false);
@ -343,7 +343,7 @@ public class MainActivity extends AppCompatActivity
}
//识别形状颜色
private byte[] RecognizeShapeColor()
private void RecognizeShapeColor()
{
CommandEncoder encoder = new CommandEncoder();
/*if (!ShapeColor.RecognizeEverything(currImage))
@ -358,8 +358,20 @@ public class MainActivity extends AppCompatActivity
ShapeDetector detector = new ShapeDetector();
detector.shapePicProcess(currImage);
ShapeColorResult result = detector.GetAllResult();
byte blue_latter = (byte) result.GetValue(GlobalColor.BLUE, GlobalShape.RECTANGLE);
byte red_circle = (byte) result.GetValue(GlobalColor.RED, GlobalShape.CIRCLE);
byte yellow_triangle = (byte) result.GetValue(GlobalColor.YELLOW, GlobalShape.TRIANGLE);
byte all_squares = (byte) result.GetValue(GlobalShape.SQUARE);
byte all_cyan = (byte) result.GetValue(GlobalColor.CYAN);
byte all_purple = (byte) result.GetValue(GlobalColor.PURPLE);
byte all_green = (byte) result.GetValue(GlobalColor.GREEN);
byte all_red = (byte) result.GetValue(GlobalColor.RED);
dtc_client.Send(encoder.GenerateCommand(Commands.COLOR_SHAPE_DATA_PART3, all_purple, all_green, all_red));
Sleep(500);
dtc_client.Send(encoder.GenerateCommand(Commands.COLOR_SHAPE_SUCCESS, blue_latter, red_circle, yellow_triangle));
Sleep(500);
dtc_client.Send(encoder.GenerateCommand(Commands.COLOR_SHAPE_DATA_PART2, all_squares, (byte) 0x00, all_cyan));
ToastLog(result.toString(), false, true);
return encoder.GenerateCommand();
}
//识别车牌
@ -659,7 +671,7 @@ public class MainActivity extends AppCompatActivity
{
Thread th_send = new Thread(() ->
{
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_UP, 5))
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_UP, Flags.CAMERA_STEP_2))
ToastLog("Camera Command (UP) Failure.", false, true);
});
th_send.start();
@ -669,7 +681,7 @@ public class MainActivity extends AppCompatActivity
{
Thread th_send = new Thread(() ->
{
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_DOWN, 5))
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_DOWN, Flags.CAMERA_STEP_2))
ToastLog("Camera Command (DOWN) Failure.", false, true);
});
th_send.start();
@ -679,7 +691,7 @@ public class MainActivity extends AppCompatActivity
{
Thread th_send = new Thread(() ->
{
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_LEFT, 5))
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_LEFT, Flags.CAMERA_STEP_2))
ToastLog("Camera Command (LEFT) Failure.", false, true);
});
th_send.start();
@ -689,7 +701,7 @@ public class MainActivity extends AppCompatActivity
{
Thread th_send = new Thread(() ->
{
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_RIGHT, 5))
if (!CameraOperator.SendCommand(IPCamera, Flags.CAMERA_RIGHT, Flags.CAMERA_STEP_2))
ToastLog("Camera Command (RIGHT) Failure.", false, true);
});
th_send.start();
@ -737,7 +749,8 @@ public class MainActivity extends AppCompatActivity
context.findViewById(R.id.btn_start_color_shape).setOnClickListener(view ->
{
ToastLog("Color Shape Started", false, false);
ToastLog("CS Result: " + ByteArray2String(RecognizeShapeColor()), false, false);
ToastLog("CS Result: ", false, false);
RecognizeShapeColor();
context.finish();
});
@ -938,7 +951,7 @@ public class MainActivity extends AppCompatActivity
ToastLog(QRDecoder.SelfTest(BitmapFactory.decodeResource(getResources(), R.drawable.qr_decode_test)), false, false);
//初始化开源交通标志识别库
YoloV5_tfLite_TSDetector.minimumConfidence = 0.7f;
YoloV5_tfLite_TSDetector.minimumConfidence = 0.8f;
ToastLog("Open Source Traffic Sign Detector: " + (TS_Detector.LoadModel("CPU", 4, this.getAssets()) ? "Success" : "Failure"), false, false);
//初始化开源车型识别库
@ -981,7 +994,6 @@ public class MainActivity extends AppCompatActivity
while (!success); //避免”while循环具有空体“警告
IPCamera = cameraSearcher.GetCameraIP();
ToastLog("CameraSearchThread: Camera Found. IP: " + IPCamera, false, true);
IPCamera += ":81";
ToastLog("Camera Address: " + IPCamera, false, true);
StartCameraImageUpdate(50);
//这里是程序初始化的最后一步,能到达此处标志着自检通过

@ -22,11 +22,13 @@ import java.net.URL;
public class CameraOperator
{
private static final String Port = "100";
public static Bitmap GetImage(String IP)
{
try
{
URL url = new URL("http://" + IP + "/snapshot.cgi?loginuse=admin&loginpas=888888&res=0");
URL url = new URL("http://" + IP + ":" + Port + "/snapshot.cgi?loginuse=admin&loginpas=888888&res=0");
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
@ -48,7 +50,7 @@ public class CameraOperator
return false;
try
{
URL url = new URL("http://" + IP + "/decoder_control.cgi?loginuse=admin&loginpas=888888&" + "command=" + command + "&onestep=" + step);
URL url = new URL("http://" + IP + ":" + Port + "/decoder_control.cgi?loginuse=admin&loginpas=888888&command=" + command + "&onestep=" + step);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
urlConnection.disconnect();

@ -5,3 +5,6 @@ generate_cxx_metadata
[gap of 12ms]
generate_cxx_metadata completed in 72ms
# C/C++ build system timings
generate_cxx_metadata 48ms

@ -10,3 +10,9 @@ generate_cxx_metadata
create-invalidation-state 20ms
generate_cxx_metadata completed in 48ms
# C/C++ build system timings
generate_cxx_metadata
[gap of 18ms]
create-invalidation-state 22ms
generate_cxx_metadata completed in 49ms

@ -18,3 +18,9 @@ generate_cxx_metadata
create-invalidation-state 15ms
generate_cxx_metadata completed in 45ms
# C/C++ build system timings
generate_cxx_metadata
[gap of 15ms]
create-invalidation-state 26ms
generate_cxx_metadata completed in 50ms

@ -10,3 +10,6 @@ generate_cxx_metadata completed in 52ms
# C/C++ build system timings
generate_cxx_metadata 24ms
# C/C++ build system timings
generate_cxx_metadata 22ms

@ -11,7 +11,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 2083485280
"memoizedHashCode": -1092009220
},
{
"level_": 0,
@ -25,7 +25,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -1137068205
"memoizedHashCode": -17595409
},
{
"level_": 0,
@ -39,6 +39,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 956474728
"memoizedHashCode": 2075947524
}
]

@ -11,7 +11,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -724465594
"memoizedHashCode": -2033006184
},
{
"level_": 0,
@ -25,7 +25,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 517794169
"memoizedHashCode": -790746421
},
{
"level_": 0,
@ -39,6 +39,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 202140752
"memoizedHashCode": -1106399838
}
]

@ -11,7 +11,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 1460624558
"memoizedHashCode": 152083968
},
{
"level_": 0,
@ -25,7 +25,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -901653023
"memoizedHashCode": 2084773683
},
{
"level_": 0,
@ -39,6 +39,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -102853660
"memoizedHashCode": -1411394250
}
]

@ -11,7 +11,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 1382461888
"memoizedHashCode": 73921298
},
{
"level_": 0,
@ -25,7 +25,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 627810785
"memoizedHashCode": -680729805
},
{
"level_": 0,
@ -39,6 +39,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 1045521523
"memoizedHashCode": -263019067
}
]

@ -11,6 +11,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -1235839491
"memoizedHashCode": 1519124326
}
]

@ -1237,3 +1237,68 @@ create_cxx_tasks
create-initial-cxx-model completed in 99ms
create_cxx_tasks completed in 100ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 37ms
create-module-model completed in 40ms
create-module-model
create-cmake-model 38ms
create-module-model completed in 40ms
[gap of 10ms]
create-initial-cxx-model completed in 101ms
create_cxx_tasks completed in 102ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 36ms
create-module-model completed in 38ms
create-module-model
create-cmake-model 36ms
create-module-model completed in 38ms
[gap of 10ms]
create-initial-cxx-model completed in 96ms
create_cxx_tasks completed in 97ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 37ms
create-module-model completed in 39ms
create-module-model
create-cmake-model 35ms
create-module-model completed in 38ms
[gap of 11ms]
create-initial-cxx-model completed in 98ms
create_cxx_tasks completed in 101ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 38ms
create-module-model completed in 39ms
create-module-model
create-cmake-model 39ms
create-module-model completed in 40ms
[gap of 10ms]
create-initial-cxx-model completed in 99ms
create_cxx_tasks completed in 100ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 37ms
create-module-model completed in 39ms
create-module-model
create-cmake-model 34ms
create-module-model completed in 35ms
[gap of 10ms]
create-initial-cxx-model completed in 93ms
create_cxx_tasks completed in 95ms

@ -11,3 +11,15 @@ create_cxx_tasks
create-initial-cxx-model completed in 98ms
create_cxx_tasks completed in 98ms
# C/C++ build system timings
create_cxx_tasks
create-initial-cxx-model
create-module-model
create-cmake-model 34ms
create-module-model completed in 35ms
create-module-model
create-cmake-model 39ms
create-module-model completed in 44ms
create-initial-cxx-model completed in 97ms
create_cxx_tasks completed in 97ms

@ -11,7 +11,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -393804873
"memoizedHashCode": 725667923
},
{
"level_": 0,
@ -25,7 +25,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 398383230
"memoizedHashCode": 1517856026
},
{
"level_": 0,
@ -39,7 +39,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 1102844423
"memoizedHashCode": -2072650077
},
{
"level_": 0,
@ -53,7 +53,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -1329308803
"memoizedHashCode": -209836007
},
{
"level_": 0,
@ -67,7 +67,7 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": 2072968911
"memoizedHashCode": -1102525589
},
{
"level_": 0,
@ -81,6 +81,6 @@
"fieldsDescending": {}
},
"memoizedSize": -1,
"memoizedHashCode": -1886018166
"memoizedHashCode": -766545370
}
]
Loading…
Cancel
Save