|
@@ -15,8 +15,8 @@ void YoloSegmentMqttAsyncClient::init(const std::string &file) {
|
|
|
|
|
|
// 识别结果数据包含识别结果、时间序号、具体识别信息
|
|
|
int YoloSegmentMqttAsyncClient::CloudDataArrived(void *client, char *topicName, int topicLen,
|
|
|
- MQTTAsync_message *message) {
|
|
|
- auto *tof_client = (YoloSegmentMqttAsyncClient *)client;
|
|
|
+ MQTTAsync_message *message) {
|
|
|
+ auto *tof_client = (YoloSegmentMqttAsyncClient *) client;
|
|
|
// TODO:测试
|
|
|
std::string topic = topicName;
|
|
|
if (topic == "tof/ir") {
|
|
@@ -46,19 +46,24 @@ int YoloSegmentMqttAsyncClient::CloudDataArrived(void *client, char *topicName,
|
|
|
auto seg_points = tof_client->detector->getPointsFromObj(*iter);
|
|
|
int device_index = (int(iter->rect.x / 640) * 0x01) | (int(iter->rect.y / 480) << 1);
|
|
|
// 校验识别矩形框是否越界
|
|
|
- int device_index_check = (int((iter->rect.x + iter->rect.width) / 640) * 0x01) | (int((iter->rect.y + iter->rect.height) / 480) << 1);
|
|
|
+ int device_index_check = (int((iter->rect.x + iter->rect.width) / 640) * 0x01) |
|
|
|
+ (int((iter->rect.y + iter->rect.height) / 480) << 1);
|
|
|
if (device_index != device_index_check) {
|
|
|
// TODO:存图
|
|
|
objs.erase(iter);
|
|
|
iter--;
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+ int x_alpha = (device_index & 0x1);
|
|
|
+ int y_alpha = ((device_index & 0x2) >> 1);
|
|
|
+ seg_results.mutable_boxes(device_index)->set_x(iter->rect.x - x_alpha * merge_mat.cols / 2);
|
|
|
+ seg_results.mutable_boxes(device_index)->set_y(iter->rect.y - y_alpha * merge_mat.rows / 2);
|
|
|
+ seg_results.mutable_boxes(device_index)->set_width(iter->rect.width);
|
|
|
+ seg_results.mutable_boxes(device_index)->set_height(iter->rect.height);
|
|
|
seg_results.mutable_boxes(device_index)->set_confidence(iter->prob);
|
|
|
if (iter->prob > 0.6) {
|
|
|
+ // LOG(INFO) << device_index << ": " << iter->prob;
|
|
|
int box_contour[480][2] = {0};
|
|
|
- int x_alpha = (device_index & 0x1);
|
|
|
- int y_alpha = ((device_index & 0x2) >> 1);
|
|
|
for (auto &pt: seg_points) { // use 7.5~9ms
|
|
|
pt.x -= x_alpha * merge_mat.cols / 2;
|
|
|
pt.y -= y_alpha * merge_mat.rows / 2;
|
|
@@ -70,7 +75,7 @@ int YoloSegmentMqttAsyncClient::CloudDataArrived(void *client, char *topicName,
|
|
|
box_contour[pt.y][1] = MAX(pt.x, box_contour[pt.y][1]);
|
|
|
}
|
|
|
}
|
|
|
- for (auto & ends : box_contour) {
|
|
|
+ for (auto &ends: box_contour) {
|
|
|
auto line = seg_results.mutable_boxes(device_index)->add_lines();
|
|
|
line->set_begin(ends[0]);
|
|
|
line->set_end(ends[1]);
|
|
@@ -79,7 +84,7 @@ int YoloSegmentMqttAsyncClient::CloudDataArrived(void *client, char *topicName,
|
|
|
}
|
|
|
|
|
|
char data[seg_results.ByteSizeLong()];
|
|
|
- seg_results.SerializeToArray((void *)data, seg_results.ByteSizeLong());
|
|
|
+ seg_results.SerializeToArray((void *) data, seg_results.ByteSizeLong());
|
|
|
tof_client->SendMessage("tof/seg", data, seg_results.ByteSizeLong());
|
|
|
}
|
|
|
return 1;
|