| | |
| | | server_stop();
|
| | | }
|
| | |
|
| | | bool send_SensetimeFaceDetectResultJson(EVClientStub& client, const fdr_vec_t& result)
|
| | | bool send_SensetimeFaceDetectResultJson(EVClientStub& client, const fdr_vec_t& result, int ret = 0)
|
| | | {
|
| | | std::stringstream ss;
|
| | | ss << "{" << LOG_ENDL;
|
| | | ss << "\"ret\":" << WRAPPER_TEXT(0) << "," << LOG_ENDL;
|
| | | ss << "\"ret\":" << WRAPPER_TEXT(ret) << "," << LOG_ENDL;
|
| | | ss << "\"count\":" << WRAPPER_TEXT(result.size()) << "," << LOG_ENDL;
|
| | | ss << "\"result\":[";
|
| | | for(fdr_vec_t::const_iterator iter = result.begin(); iter != result.end(); ++iter)
|
| | |
| | | return send_SensetimeFaceDetectResultJson(client, result);
|
| | | }
|
| | |
|
| | | bool ev_proc_SensetimeFaceDetectSave(EVClientStub& client)
|
| | | {
|
| | | EVPHeader* evpHeader = (EVPHeader*)client.recvBuff;
|
| | | FDP_Image* fdpImage = (FDP_Image*)(client.recvBuff + sizeof(EVPHeader));
|
| | | |
| | | STFaceImage stfaceImg;
|
| | | stfaceImg.db_id = fdpImage->db_id;
|
| | | stfaceImg.mb_type = fdpImage->mb_type;
|
| | | stfaceImg.width = fdpImage->width;
|
| | | stfaceImg.height = fdpImage->height;
|
| | | stfaceImg.size = evpHeader->size - sizeof(EVPHeader) - sizeof(FDP_Image);
|
| | | stfaceImg.buff = fdpImage->buff;
|
| | | |
| | | fdr_vec_t result;
|
| | | FDP_FaceDetectResult fdrResult = g_STFaceCache.add(stfaceImg);
|
| | | result.push_back(fdrResult);
|
| | | |
| | | int ret = (fdrResult.db_id == 0 ? -1 : 0);
|
| | | return send_SensetimeFaceDetectResultJson(client, result, ret);
|
| | | }
|
| | |
|
| | | bool ev_dispatcher_proto_pb(EVClientStub& client)
|
| | | {
|
| | | LOG_DEBUG << "ev_dispatcher_proto_pb" << LOG_ENDL;
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | bool ev_dispatcher_proto_rawbin(EVClientStub& client)
|
| | | {
|
| | | LOG_DEBUG << "ev_dispatcher_proto_pb" << LOG_ENDL;
|
| | | |
| | | EVPHeader* evpHeader = (EVPHeader*)client.recvBuff;
|
| | | if (evpHeader->size != client.recvBuffSize)
|
| | | {
|
| | | LOG_WARN << "Truncated buffer " << (evpHeader->size - client.recvBuffSize) << " bytes" << LOG_ENDL;
|
| | | return false;
|
| | | }
|
| | |
|
| | | switch(evpHeader->cmd)
|
| | | {
|
| | | case FaceDaemonCommand::FDC_SENSETIMEFACEDETECT_SAVE:
|
| | | return ev_proc_SensetimeFaceDetectSave(client);
|
| | | break;
|
| | | default:
|
| | | LOG_WARN << "Unknown command" << LOG_ENDL;
|
| | | ev_send_status_packet(client, EVPStatus::EVPS_COMMAND_ERROR);
|
| | | return false;
|
| | | break;
|
| | | }
|
| | | |
| | | // return false to disconnect
|
| | | return false;
|
| | | }
|
| | |
|
| | | bool ev_dispatcher_proto(EVClientStub& client)
|
| | | {
|
| | | LOG_DEBUG << "ev_dispatcher_proto" << LOG_ENDL;
|
| | |
| | | case EVPProto::EVPP_PROTOBUF:
|
| | | return ev_dispatcher_proto_pb(client);
|
| | | break;
|
| | | case EVPProto::EVPP_RAW_BIN:
|
| | | return ev_dispatcher_proto_rawbin(client);
|
| | | break;
|
| | | default:
|
| | | LOG_WARN << "Unknown proto" << LOG_ENDL;
|
| | | ev_send_status_packet(client, EVPStatus::EVPS_PROTO_ERROR);
|