bug fix
git-svn-id: http://192.168.1.226/svn/proxy@545 454eff88-639b-444f-9e54-f578c98de674
| | |
| | | int16_t cmd; // EVPCommand::EVPC
|
| | | uint32_t size; // sizeof(EVPHeader)+sizeof(subcmd)
|
| | |
|
| | | void hton();
|
| | | void ntoh();
|
| | | |
| | | EVPHeader() : _padding1(0), proto(EVPProto::EVPP__FIRST), cmd(EVPCommand::EVPC__FIRST), size(8)
|
| | | {}
|
| | | };
|
| | |
| | | struct EVP_Status
|
| | | {
|
| | | int16_t status;
|
| | | |
| | | void hton();
|
| | | void ntoh();
|
| | | };
|
| | |
|
| | | struct EVP_VariableBuffer
|
| | | {
|
| | | int16_t type;
|
| | | uint8_t buff[0];
|
| | | |
| | | void hton();
|
| | | void ntoh();
|
| | | };
|
| | |
|
| | | //#todo
|
| | |
| | | }
|
| | |
|
| | | evpHeader = (EVPHeader*)headerBuff;
|
| | | evpHeader->ntoh();
|
| | |
|
| | | // check header
|
| | | if (evpHeader->proto <= EVPProto::EVPP__FIRST || evpHeader->proto >= EVPProto::EVPP__LAST ||
|
| | |
| | | do
|
| | | {
|
| | | readSize = bufferevent_read(bufev, client->recvbuff + client->recvbuff_end, client->recvbuff_max - client->recvbuff_end);
|
| | | client->read_times++;
|
| | | if (readSize == 0)
|
| | | break;
|
| | | else
|
| | | client->read_times++;
|
| | |
|
| | | client->recvbuff_end += readSize;
|
| | | } while (readSize > 0);
|
| | |
| | | EVPHeader* evpHeader = new (client.sendBuff) EVPHeader;
|
| | | evpHeader->cmd = EVPCommand::EVPC_STATUS;
|
| | | evpHeader->size = client.sendBuffSize;
|
| | | evpHeader->hton();
|
| | |
|
| | | EVP_Status* evpStatus = new (client.sendBuff + sizeof(EVPHeader)) EVP_Status;
|
| | | evpStatus->status = status;
|
| | | evpHeader->hton();
|
| | | }
|
| | |
| | | #define SERVER_PORT 5432
|
| | | #endif
|
| | | #define REUSEADDR_ON 1
|
| | | #define CLIENT_BUFFER_MAX 100*1024 // 100KB
|
| | | #define CLIENT_BUFFER_MAX 1*1024*1024 // 1MB
|
| | | #define CLIENT_READ_TIMES_MAX 100
|
| | | #define CLIENT_MAX 100 // max count of clients connected //#todo not support
|
| | |
|
| | |
| | | int16_t height;
|
| | | uint8_t buff[0];
|
| | |
|
| | | void hton();//#todo
|
| | | void hton();
|
| | | void ntoh();
|
| | | };
|
| | | //sizeof(FDP_Image)=10
|
| | |
|
| | | struct FDP_FaceDetectPB
|
| | | {
|
| | |
| | | FDP_FaceDetectPB(int32_t _db_id) : db_id(_db_id)
|
| | | {}
|
| | |
|
| | | void hton();//#todo
|
| | | void hton();
|
| | | void ntoh();
|
| | | };
|
| | |
|
| | | struct FDP_FaceDetectResult
|
| | |
| | | FDP_FaceDetectResult(int32_t _db_id, int32_t _st_id) : db_id(_db_id), st_id(_st_id)
|
| | | {}
|
| | |
|
| | | void hton();//#todo
|
| | | void hton();
|
| | | void ntoh();
|
| | | };
|
| | |
|
| | | #pragma pack()
|
| | |
| | | {
|
| | | EVPHeader* evpHeader = (EVPHeader*)client.recvBuff;
|
| | | FDP_Image* fdpImage = (FDP_Image*)(client.recvBuff + sizeof(EVPHeader));
|
| | | fdpImage->ntoh();
|
| | |
|
| | | STFaceImage stfaceImg;
|
| | | stfaceImg.db_id = fdpImage->db_id;
|
| | |
| | | stfaceImg.size = evpHeader->size - sizeof(EVPHeader) - sizeof(FDP_Image);
|
| | | stfaceImg.buff = fdpImage->buff;
|
| | |
|
| | | //char imgfn[100 * 1024];
|
| | | //static int i = 0;
|
| | | //sprintf(imgfn, "IMG_%d_%d_w%d_h%d.rgb565", stfaceImg.db_id, ++i, stfaceImg.width, stfaceImg.height);
|
| | | //FILE * pFile = fopen(imgfn, "wb");
|
| | | //fwrite(stfaceImg.buff, sizeof(char), stfaceImg.size, pFile);
|
| | | //fclose(pFile);
|
| | | //pFile = nullptr;
|
| | | LOGP(DEBUG, "stfaceImg db_id=%d, mb_type=%d, width=%d, height=%d, size=%d", |
| | | (int)stfaceImg.db_id, (int)stfaceImg.mb_type, (int)stfaceImg.width, (int)stfaceImg.height, (int)stfaceImg.size);
|
| | | |
| | | char imgfn[100 * 1024];
|
| | | static int i = 0;
|
| | | sprintf(imgfn, "IMG_%d_%d_w%d_h%d.rgb565", stfaceImg.db_id, ++i, stfaceImg.width, stfaceImg.height);
|
| | | FILE * pFile = fopen(imgfn, "wb");
|
| | | fwrite(stfaceImg.buff, sizeof(char), stfaceImg.size, pFile);
|
| | | fclose(pFile);
|
| | | pFile = nullptr;
|
| | |
|
| | | fdr_vec_t result;
|
| | | FDP_FaceDetectResult fdrResult = g_STFaceCache.add(stfaceImg);
|
| | |
| | |
|
| | | bool ev_dispatcher_proto_rawbin(EVClientStub& client)
|
| | | {
|
| | | LOG_DEBUG << "ev_dispatcher_proto_pb" << LOG_ENDL;
|
| | | LOG_DEBUG << "ev_dispatcher_proto_rawbin" << LOG_ENDL;
|
| | |
|
| | | EVPHeader* evpHeader = (EVPHeader*)client.recvBuff;
|
| | | if (evpHeader->size != client.recvBuffSize)
|
| | |
| | | |
| | | g++ $PIPELINE_BASE/Logger/src/logger.cc $CFLAGS $CPPFLAGS |
| | | g++ ev_server.cpp -DUSER_DEFINE_EVCLIENT_PROC $CFLAGS $CPPFLAGS |
| | | g++ proto_hton_ntoh.cpp $CFLAGS $CPPFLAGS |
| | | g++ $VISITFACE_BASE/PbFaceList.pb.cc $CFLAGS $CPPFLAGS |
| | | g++ main_face_daemon.cpp $CFLAGS $CPPFLAGS |
| | | g++ sample_face_search.cpp $CFLAGS $CPPFLAGS |
| | |
| | | g++ -g -std=c++11 \ |
| | | logger.o \ |
| | | ev_server.o \ |
| | | proto_hton_ntoh.o \ |
| | | PbFaceList.pb.o \ |
| | | main_face_daemon.o \ |
| | | sample_face_search.o \ |
New file |
| | |
| | | #include "ev_proto.h"
|
| | | #include "face_daemon_proto.h"
|
| | | #include <netinet/in.h>
|
| | |
|
| | | void EVPHeader::hton()
|
| | | {
|
| | | cmd = htons(cmd);
|
| | | size = htonl(size);
|
| | | }
|
| | |
|
| | | void EVPHeader::ntoh()
|
| | | {
|
| | | cmd = ntohs(cmd);
|
| | | size = ntohl(size);
|
| | | }
|
| | |
|
| | | void EVP_Status::hton()
|
| | | {
|
| | | status = htons(status);
|
| | | }
|
| | |
|
| | | void EVP_Status::ntoh()
|
| | | {
|
| | | status = ntohs(status);
|
| | | }
|
| | |
|
| | | void EVP_VariableBuffer::hton()
|
| | | {
|
| | | type = htons(type);
|
| | | }
|
| | |
|
| | | void EVP_VariableBuffer::ntoh()
|
| | | {
|
| | | type = ntohs(type);
|
| | | }
|
| | |
|
| | | void FDP_Image::hton()
|
| | | {
|
| | | db_id = htonl(db_id);
|
| | | mb_type = htons(mb_type);
|
| | | width = htons(width);
|
| | | height = htons(height);
|
| | | }
|
| | |
|
| | | void FDP_Image::ntoh()
|
| | | {
|
| | | db_id = ntohl(db_id);
|
| | | mb_type = ntohs(mb_type);
|
| | | width = ntohs(width);
|
| | | height = ntohs(height);
|
| | | }
|
| | |
|
| | | void FDP_FaceDetectPB::hton()
|
| | | {
|
| | | db_id = htonl(db_id);
|
| | | }
|
| | |
|
| | | void FDP_FaceDetectPB::ntoh()
|
| | | {
|
| | | db_id = ntohl(db_id);
|
| | | }
|
| | |
|
| | | void FDP_FaceDetectResult::hton()
|
| | | {
|
| | | db_id = htonl(db_id);
|
| | | st_id = htonl(st_id);
|
| | | }
|
| | |
|
| | | void FDP_FaceDetectResult::ntoh()
|
| | | {
|
| | | db_id = ntohl(db_id);
|
| | | st_id = ntohl(st_id);
|
| | | }
|