[update] pzmq close && base64 size

This commit is contained in:
dianjixz
2024-11-27 17:06:14 +08:00
parent 1a9971d23c
commit f5e81ca161
6 changed files with 18 additions and 11 deletions
@@ -386,14 +386,20 @@ static int base64_decode(const char *in, unsigned int inlen, unsigned char *out)
int StackFlows::decode_base64(const std::string &in, std::string &out)
{
out.resize(BASE64_DECODE_OUT_SIZE(in.length()));
return base64_decode((const char *)in.c_str(), in.length(), (unsigned char *)out.data());
int out_size = BASE64_DECODE_OUT_SIZE(in.length());
out.resize(out_size);
int ret = base64_decode((const char *)in.c_str(), in.length(), (unsigned char *)out.data());
if ((ret > 0) && (ret != out_size)) out.erase(ret);
return ret;
}
int StackFlows::encode_base64(const std::string &in, std::string &out)
{
out.resize(BASE64_ENCODE_OUT_SIZE(in.length()));
return base64_encode((const unsigned char *)in.c_str(), in.length(), (char *)out.data());
int out_size = BASE64_ENCODE_OUT_SIZE(in.length());
out.resize(out_size);
int ret = base64_encode((const unsigned char *)in.c_str(), in.length(), (char *)out.data());
if ((ret > 0) && (ret != out_size)) out.erase(ret);
return ret;
}
std::string StackFlows::unit_call(const std::string &unit_name, const std::string &unit_action, const std::string &data)
+2 -2
View File
@@ -348,9 +348,9 @@ public:
if (!zmq_socket_) {
return;
}
flage_ = true;
zmq_ctx_shutdown(zmq_ctx_);
if (zmq_thread_) {
flage_ = true;
zmq_ctx_shutdown(zmq_ctx_);
zmq_thread_->join();
}
close_zmq();
@@ -519,21 +519,21 @@ void unit_action_match(int com_id, const std::string &json_str)
std::string request_id;
error = doc["request_id"].get_string(request_id);
if (error) {
SLOGE("miss request_id");
SLOGE("miss request_id, error:%s", simdjson::error_message(error));
usr_print_error("0", "sys", "{\"code\":-2, \"message\":\"json format error\"}", com_id);
return;
}
std::string work_id;
error = doc["work_id"].get_string(work_id);
if (error) {
SLOGE("miss work_id");
SLOGE("miss work_id, error:%s", simdjson::error_message(error));
usr_print_error("0", "sys", "{\"code\":-2, \"message\":\"json format error\"}", com_id);
return;
}
std::string action;
error = doc["action"].get_string(action);
if (error) {
SLOGE("miss action");
SLOGE("miss action, error:%s", simdjson::error_message(error));
usr_print_error("0", "sys", "{\"code\":-2, \"message\":\"json format error\"}", com_id);
return;
}
@@ -77,6 +77,7 @@ void zmq_bus_com::on_raw_data(const std::string &data)
memcpy((void *)new_data.data(), json_str_.c_str(), json_str_.length());
sprintf((char *)(new_data.data() + json_str_.length() - 1), ",\"data\":\"");
memcpy((void *)(new_data.data() + json_str_.length() + 8), base64_data.c_str(), base64_data.length());
new_data[json_str_.length() + 8 + base64_data.length()] = '"';
new_data[json_str_.length() + 9 + base64_data.length()] = '}';
on_data(new_data);
}
@@ -324,7 +324,7 @@ void post_process(AX_ENGINE_IO_INFO_T* io_info, AX_ENGINE_IO_T* io_data, const c
cls_num);
}
detection::get_out_bbox(proposals, objects, nms_threshold, input_h, input_w, mat.rows, mat.cols);
detection::draw_objects(mat, objects, CLASS_NAMES, "yolo11_out");
// detection::draw_objects(mat, objects, CLASS_NAMES, "yolo11_out");
} else if (model_type == "segment") {
float* output_ptr[3] = {(float*)io_data->pOutputs[0].pVirAddr, (float*)io_data->pOutputs[1].pVirAddr,
(float*)io_data->pOutputs[2].pVirAddr};
@@ -275,7 +275,7 @@ public:
if (finish) count = 0;
llm_channel->send(llm_task_obj->response_format_, data_body, LLM_NO_ERROR);
} else if (finish) {
SLOGI("send utf-8");
// SLOGI("send utf-8");
llm_channel->send(llm_task_obj->response_format_, data, LLM_NO_ERROR);
}
}