From d9125b1f5e3bfd1c657d75c4ef812f1202dc406d Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期一, 10 七月 2017 10:12:44 +0800 Subject: [PATCH] proto support st_track_id --- FaceServer/STFaceCache.cpp | 61 +++++- FaceServer/PbFaceList.pb.h | 112 ++++++++---- FaceServer/PbFaceList | 19 +- FaceServer/main_face_daemon.cpp | 22 ++ FaceServer/face_daemon_proto.h | 9 FaceServer/PbFaceList.pb.cc | 288 +++++++++++++++++++------------ FaceServer/STFaceCache.h | 17 + FaceServer/proto_hton_ntoh.cpp | 6 8 files changed, 356 insertions(+), 178 deletions(-) diff --git a/FaceServer/PbFaceList b/FaceServer/PbFaceList index aec8661..6909943 100644 --- a/FaceServer/PbFaceList +++ b/FaceServer/PbFaceList @@ -8,7 +8,7 @@ required uint32 image_count = 2; optional uint32 src_width = 3; optional uint32 src_height = 4; - + message FaceListImage { enum ImageType @@ -43,14 +43,15 @@ } required uint32 idx = 1; - required uint32 size = 2; - required ImageType type = 3 [default = MBFT_Y8]; - - required uint32 width = 4; - required uint32 height = 5; - optional uint32 top_left_x = 6; - optional uint32 top_left_y = 7; - repeated bytes img = 8; + required uint32 st_track_id = 2; + required uint32 size = 3; + required ImageType type = 4 [default = MBFT_Y8]; + + required uint32 width = 5; + required uint32 height = 6; + optional uint32 top_left_x = 7; + optional uint32 top_left_y = 8; + repeated bytes img = 9; } repeated FaceListImage images = 5; diff --git a/FaceServer/PbFaceList.pb.cc b/FaceServer/PbFaceList.pb.cc index 38d9ab6..5550951 100644 --- a/FaceServer/PbFaceList.pb.cc +++ b/FaceServer/PbFaceList.pb.cc @@ -37,6 +37,7 @@ ~0u, // no _extensions_ ~0u, // no _oneof_case_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, idx_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, st_track_id_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, size_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, type_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, width_), @@ -46,11 +47,12 @@ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, img_), 0, 1, - 6, 2, + 7, 3, 4, 5, + 6, ~0u, GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, _has_bits_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, _internal_metadata_), @@ -69,8 +71,8 @@ }; static const ::google::protobuf::internal::MigrationSchema schemas[] = { - { 0, 12, sizeof(PbFaceList_FaceListImage)}, - { 20, 29, sizeof(PbFaceList)}, + { 0, 13, sizeof(PbFaceList_FaceListImage)}, + { 22, 31, sizeof(PbFaceList)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { @@ -123,26 +125,27 @@ void AddDescriptorsImpl() { InitDefaults(); static const char descriptor[] = { - "\n\nPbFaceList\"\227\005\n\nPbFaceList\022\027\n\005magic\030\001 \002" + "\n\nPbFaceList\"\254\005\n\nPbFaceList\022\027\n\005magic\030\001 \002" "(\r:\01011706629\022\023\n\013image_count\030\002 \002(\r\022\021\n\tsrc" "_width\030\003 \001(\r\022\022\n\nsrc_height\030\004 \001(\r\022)\n\006imag" - "es\030\005 \003(\0132\031.PbFaceList.FaceListImage\032\210\004\n\r" - "FaceListImage\022\013\n\003idx\030\001 \002(\r\022\014\n\004size\030\002 \002(\r" - "\022:\n\004type\030\003 \002(\0162#.PbFaceList.FaceListImag" - "e.ImageType:\007MBFT_Y8\022\r\n\005width\030\004 \002(\r\022\016\n\006h" - "eight\030\005 \002(\r\022\022\n\ntop_left_x\030\006 \001(\r\022\022\n\ntop_l" - "eft_y\030\007 \001(\r\022\013\n\003img\030\010 \003(\014\"\313\002\n\tImageType\022\014" - "\n\010MBFT_SDP\020\001\022\r\n\tMBFT_FMTP\020\002\022\016\n\nMBFT_INDE" - "X\020\003\022\024\n\020MBFT_PTR_AVFRAME\020\004\022\022\n\016MBFT_H264_N" - "ALU\020\005\022\026\n\022MBFT_H264_NALU_AUX\020\006\022\r\n\tMBFT_JP" - "EG\020\007\022\014\n\010MBFT_YUV\020\010\022\013\n\007MBFT_Y8\020\t\022\017\n\013MBFT_" - "YUV420\020\n\022\r\n\tMBFT_NV12\020\013\022\014\n\010MBFT_RGB\020\014\022\017\n" - "\013MBFT_RGB888\020\r\022\017\n\013MBFT_RGB565\020\016\022\r\n\tMBFT_" - "RGBA\020\017\022\r\n\tMBFT_BGRA\020\020\022\021\n\rMBFT_BGRA8888\020\021" - "\022\021\n\rMBFT_ABGR8888\020\022\022\021\n\rMBFT_ARGB8888\020\023" + "es\030\005 \003(\0132\031.PbFaceList.FaceListImage\032\235\004\n\r" + "FaceListImage\022\013\n\003idx\030\001 \002(\r\022\023\n\013st_track_i" + "d\030\002 \002(\r\022\014\n\004size\030\003 \002(\r\022:\n\004type\030\004 \002(\0162#.Pb" + "FaceList.FaceListImage.ImageType:\007MBFT_Y" + "8\022\r\n\005width\030\005 \002(\r\022\016\n\006height\030\006 \002(\r\022\022\n\ntop_" + "left_x\030\007 \001(\r\022\022\n\ntop_left_y\030\010 \001(\r\022\013\n\003img\030" + "\t \003(\014\"\313\002\n\tImageType\022\014\n\010MBFT_SDP\020\001\022\r\n\tMBF" + "T_FMTP\020\002\022\016\n\nMBFT_INDEX\020\003\022\024\n\020MBFT_PTR_AVF" + "RAME\020\004\022\022\n\016MBFT_H264_NALU\020\005\022\026\n\022MBFT_H264_" + "NALU_AUX\020\006\022\r\n\tMBFT_JPEG\020\007\022\014\n\010MBFT_YUV\020\010\022" + "\013\n\007MBFT_Y8\020\t\022\017\n\013MBFT_YUV420\020\n\022\r\n\tMBFT_NV" + "12\020\013\022\014\n\010MBFT_RGB\020\014\022\017\n\013MBFT_RGB888\020\r\022\017\n\013M" + "BFT_RGB565\020\016\022\r\n\tMBFT_RGBA\020\017\022\r\n\tMBFT_BGRA" + "\020\020\022\021\n\rMBFT_BGRA8888\020\021\022\021\n\rMBFT_ABGR8888\020\022" + "\022\021\n\rMBFT_ARGB8888\020\023" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - descriptor, 678); + descriptor, 699); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "PbFaceList", &protobuf_RegisterTypes); ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); @@ -221,6 +224,7 @@ #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int PbFaceList_FaceListImage::kIdxFieldNumber; +const int PbFaceList_FaceListImage::kStTrackIdFieldNumber; const int PbFaceList_FaceListImage::kSizeFieldNumber; const int PbFaceList_FaceListImage::kTypeFieldNumber; const int PbFaceList_FaceListImage::kWidthFieldNumber; @@ -292,7 +296,7 @@ void PbFaceList_FaceListImage::Clear() { // @@protoc_insertion_point(message_clear_start:PbFaceList.FaceListImage) img_.Clear(); - if (_has_bits_[0 / 32] & 127u) { + if (_has_bits_[0 / 32] & 255u) { ::memset(&idx_, 0, reinterpret_cast<char*>(&top_left_y_) - reinterpret_cast<char*>(&idx_) + sizeof(top_left_y_)); type_ = 9; @@ -325,10 +329,24 @@ break; } - // required uint32 size = 2; + // required uint32 st_track_id = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(16u)) { + set_has_st_track_id(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &st_track_id_))); + } else { + goto handle_unusual; + } + break; + } + + // required uint32 size = 3; + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { set_has_size(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -339,10 +357,10 @@ break; } - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; - case 3: { + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; + case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(24u)) { + static_cast< ::google::protobuf::uint8>(32u)) { int value; DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( @@ -350,7 +368,7 @@ if (::PbFaceList_FaceListImage_ImageType_IsValid(value)) { set_type(static_cast< ::PbFaceList_FaceListImage_ImageType >(value)); } else { - mutable_unknown_fields()->AddVarint(3, value); + mutable_unknown_fields()->AddVarint(4, value); } } else { goto handle_unusual; @@ -358,10 +376,10 @@ break; } - // required uint32 width = 4; - case 4: { + // required uint32 width = 5; + case 5: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(32u)) { + static_cast< ::google::protobuf::uint8>(40u)) { set_has_width(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -372,10 +390,10 @@ break; } - // required uint32 height = 5; - case 5: { + // required uint32 height = 6; + case 6: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(40u)) { + static_cast< ::google::protobuf::uint8>(48u)) { set_has_height(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -386,10 +404,10 @@ break; } - // optional uint32 top_left_x = 6; - case 6: { + // optional uint32 top_left_x = 7; + case 7: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(48u)) { + static_cast< ::google::protobuf::uint8>(56u)) { set_has_top_left_x(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -400,10 +418,10 @@ break; } - // optional uint32 top_left_y = 7; - case 7: { + // optional uint32 top_left_y = 8; + case 8: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(56u)) { + static_cast< ::google::protobuf::uint8>(64u)) { set_has_top_left_y(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( @@ -414,10 +432,10 @@ break; } - // repeated bytes img = 8; - case 8: { + // repeated bytes img = 9; + case 9: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(66u)) { + static_cast< ::google::protobuf::uint8>(74u)) { DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( input, this->add_img())); } else { @@ -456,41 +474,46 @@ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->idx(), output); } - // required uint32 size = 2; - if (has_size()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->size(), output); + // required uint32 st_track_id = 2; + if (has_st_track_id()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->st_track_id(), output); } - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + // required uint32 size = 3; + if (has_size()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->size(), output); + } + + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; if (has_type()) { ::google::protobuf::internal::WireFormatLite::WriteEnum( - 3, this->type(), output); + 4, this->type(), output); } - // required uint32 width = 4; + // required uint32 width = 5; if (has_width()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->width(), output); + ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->width(), output); } - // required uint32 height = 5; + // required uint32 height = 6; if (has_height()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->height(), output); + ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->height(), output); } - // optional uint32 top_left_x = 6; + // optional uint32 top_left_x = 7; if (has_top_left_x()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->top_left_x(), output); + ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->top_left_x(), output); } - // optional uint32 top_left_y = 7; + // optional uint32 top_left_y = 8; if (has_top_left_y()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->top_left_y(), output); + ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->top_left_y(), output); } - // repeated bytes img = 8; + // repeated bytes img = 9; for (int i = 0, n = this->img_size(); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteBytes( - 8, this->img(i), output); + 9, this->img(i), output); } if (_internal_metadata_.have_unknown_fields()) { @@ -509,41 +532,46 @@ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->idx(), target); } - // required uint32 size = 2; - if (has_size()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->size(), target); + // required uint32 st_track_id = 2; + if (has_st_track_id()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->st_track_id(), target); } - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + // required uint32 size = 3; + if (has_size()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->size(), target); + } + + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; if (has_type()) { target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 3, this->type(), target); + 4, this->type(), target); } - // required uint32 width = 4; + // required uint32 width = 5; if (has_width()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->width(), target); + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->width(), target); } - // required uint32 height = 5; + // required uint32 height = 6; if (has_height()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->height(), target); + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->height(), target); } - // optional uint32 top_left_x = 6; + // optional uint32 top_left_x = 7; if (has_top_left_x()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->top_left_x(), target); + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->top_left_x(), target); } - // optional uint32 top_left_y = 7; + // optional uint32 top_left_y = 8; if (has_top_left_y()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->top_left_y(), target); + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->top_left_y(), target); } - // repeated bytes img = 8; + // repeated bytes img = 9; for (int i = 0, n = this->img_size(); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: - WriteBytesToArray(8, this->img(i), target); + WriteBytesToArray(9, this->img(i), target); } if (_internal_metadata_.have_unknown_fields()) { @@ -565,29 +593,36 @@ this->idx()); } + if (has_st_track_id()) { + // required uint32 st_track_id = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->st_track_id()); + } + if (has_size()) { - // required uint32 size = 2; + // required uint32 size = 3; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->size()); } if (has_width()) { - // required uint32 width = 4; + // required uint32 width = 5; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->width()); } if (has_height()) { - // required uint32 height = 5; + // required uint32 height = 6; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->height()); } if (has_type()) { - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); } @@ -603,35 +638,40 @@ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } - if (((_has_bits_[0] & 0x0000004f) ^ 0x0000004f) == 0) { // All required fields are present. + if (((_has_bits_[0] & 0x0000009f) ^ 0x0000009f) == 0) { // All required fields are present. // required uint32 idx = 1; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->idx()); - // required uint32 size = 2; + // required uint32 st_track_id = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->st_track_id()); + + // required uint32 size = 3; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->size()); - // required uint32 width = 4; + // required uint32 width = 5; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->width()); - // required uint32 height = 5; + // required uint32 height = 6; total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->height()); - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; total_size += 1 + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); } else { total_size += RequiredFieldsByteSizeFallback(); } - // repeated bytes img = 8; + // repeated bytes img = 9; total_size += 1 * ::google::protobuf::internal::FromIntSize(this->img_size()); for (int i = 0, n = this->img_size(); i < n; i++) { @@ -639,15 +679,15 @@ this->img(i)); } - if (_has_bits_[0 / 32] & 48u) { - // optional uint32 top_left_x = 6; + if (_has_bits_[0 / 32] & 96u) { + // optional uint32 top_left_x = 7; if (has_top_left_x()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( this->top_left_x()); } - // optional uint32 top_left_y = 7; + // optional uint32 top_left_y = 8; if (has_top_left_y()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt32Size( @@ -682,9 +722,12 @@ GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); img_.MergeFrom(from.img_); - if (from._has_bits_[0 / 32] & 127u) { + if (from._has_bits_[0 / 32] & 255u) { if (from.has_idx()) { set_idx(from.idx()); + } + if (from.has_st_track_id()) { + set_st_track_id(from.st_track_id()); } if (from.has_size()) { set_size(from.size()); @@ -722,7 +765,7 @@ } bool PbFaceList_FaceListImage::IsInitialized() const { - if ((_has_bits_[0] & 0x0000004f) != 0x0000004f) return false; + if ((_has_bits_[0] & 0x0000009f) != 0x0000009f) return false; return true; } @@ -733,6 +776,7 @@ void PbFaceList_FaceListImage::InternalSwap(PbFaceList_FaceListImage* other) { img_.UnsafeArenaSwap(&other->img_); std::swap(idx_, other->idx_); + std::swap(st_track_id_, other->st_track_id_); std::swap(size_, other->size_); std::swap(width_, other->width_); std::swap(height_, other->height_); @@ -776,15 +820,39 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.idx) } -// required uint32 size = 2; -bool PbFaceList_FaceListImage::has_size() const { +// required uint32 st_track_id = 2; +bool PbFaceList_FaceListImage::has_st_track_id() const { return (_has_bits_[0] & 0x00000002u) != 0; } -void PbFaceList_FaceListImage::set_has_size() { +void PbFaceList_FaceListImage::set_has_st_track_id() { _has_bits_[0] |= 0x00000002u; } -void PbFaceList_FaceListImage::clear_has_size() { +void PbFaceList_FaceListImage::clear_has_st_track_id() { _has_bits_[0] &= ~0x00000002u; +} +void PbFaceList_FaceListImage::clear_st_track_id() { + st_track_id_ = 0u; + clear_has_st_track_id(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::st_track_id() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.st_track_id) + return st_track_id_; +} +void PbFaceList_FaceListImage::set_st_track_id(::google::protobuf::uint32 value) { + set_has_st_track_id(); + st_track_id_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.st_track_id) +} + +// required uint32 size = 3; +bool PbFaceList_FaceListImage::has_size() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void PbFaceList_FaceListImage::set_has_size() { + _has_bits_[0] |= 0x00000004u; +} +void PbFaceList_FaceListImage::clear_has_size() { + _has_bits_[0] &= ~0x00000004u; } void PbFaceList_FaceListImage::clear_size() { size_ = 0u; @@ -800,15 +868,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.size) } -// required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; +// required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; bool PbFaceList_FaceListImage::has_type() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } void PbFaceList_FaceListImage::set_has_type() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000080u; } void PbFaceList_FaceListImage::clear_has_type() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000080u; } void PbFaceList_FaceListImage::clear_type() { type_ = 9; @@ -825,15 +893,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.type) } -// required uint32 width = 4; +// required uint32 width = 5; bool PbFaceList_FaceListImage::has_width() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } void PbFaceList_FaceListImage::set_has_width() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } void PbFaceList_FaceListImage::clear_has_width() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } void PbFaceList_FaceListImage::clear_width() { width_ = 0u; @@ -849,15 +917,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.width) } -// required uint32 height = 5; +// required uint32 height = 6; bool PbFaceList_FaceListImage::has_height() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } void PbFaceList_FaceListImage::set_has_height() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } void PbFaceList_FaceListImage::clear_has_height() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } void PbFaceList_FaceListImage::clear_height() { height_ = 0u; @@ -873,15 +941,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.height) } -// optional uint32 top_left_x = 6; +// optional uint32 top_left_x = 7; bool PbFaceList_FaceListImage::has_top_left_x() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } void PbFaceList_FaceListImage::set_has_top_left_x() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } void PbFaceList_FaceListImage::clear_has_top_left_x() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } void PbFaceList_FaceListImage::clear_top_left_x() { top_left_x_ = 0u; @@ -897,15 +965,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_x) } -// optional uint32 top_left_y = 7; +// optional uint32 top_left_y = 8; bool PbFaceList_FaceListImage::has_top_left_y() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } void PbFaceList_FaceListImage::set_has_top_left_y() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000040u; } void PbFaceList_FaceListImage::clear_has_top_left_y() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000040u; } void PbFaceList_FaceListImage::clear_top_left_y() { top_left_y_ = 0u; @@ -921,7 +989,7 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_y) } -// repeated bytes img = 8; +// repeated bytes img = 9; int PbFaceList_FaceListImage::img_size() const { return img_.size(); } diff --git a/FaceServer/PbFaceList.pb.h b/FaceServer/PbFaceList.pb.h index 8085a09..9a00cfc 100644 --- a/FaceServer/PbFaceList.pb.h +++ b/FaceServer/PbFaceList.pb.h @@ -221,10 +221,10 @@ // accessors ------------------------------------------------------- - // repeated bytes img = 8; + // repeated bytes img = 9; int img_size() const; void clear_img(); - static const int kImgFieldNumber = 8; + static const int kImgFieldNumber = 9; const ::std::string& img(int index) const; ::std::string* mutable_img(int index); void set_img(int index, const ::std::string& value); @@ -250,45 +250,52 @@ ::google::protobuf::uint32 idx() const; void set_idx(::google::protobuf::uint32 value); - // required uint32 size = 2; + // required uint32 st_track_id = 2; + bool has_st_track_id() const; + void clear_st_track_id(); + static const int kStTrackIdFieldNumber = 2; + ::google::protobuf::uint32 st_track_id() const; + void set_st_track_id(::google::protobuf::uint32 value); + + // required uint32 size = 3; bool has_size() const; void clear_size(); - static const int kSizeFieldNumber = 2; + static const int kSizeFieldNumber = 3; ::google::protobuf::uint32 size() const; void set_size(::google::protobuf::uint32 value); - // required uint32 width = 4; + // required uint32 width = 5; bool has_width() const; void clear_width(); - static const int kWidthFieldNumber = 4; + static const int kWidthFieldNumber = 5; ::google::protobuf::uint32 width() const; void set_width(::google::protobuf::uint32 value); - // required uint32 height = 5; + // required uint32 height = 6; bool has_height() const; void clear_height(); - static const int kHeightFieldNumber = 5; + static const int kHeightFieldNumber = 6; ::google::protobuf::uint32 height() const; void set_height(::google::protobuf::uint32 value); - // optional uint32 top_left_x = 6; + // optional uint32 top_left_x = 7; bool has_top_left_x() const; void clear_top_left_x(); - static const int kTopLeftXFieldNumber = 6; + static const int kTopLeftXFieldNumber = 7; ::google::protobuf::uint32 top_left_x() const; void set_top_left_x(::google::protobuf::uint32 value); - // optional uint32 top_left_y = 7; + // optional uint32 top_left_y = 8; bool has_top_left_y() const; void clear_top_left_y(); - static const int kTopLeftYFieldNumber = 7; + static const int kTopLeftYFieldNumber = 8; ::google::protobuf::uint32 top_left_y() const; void set_top_left_y(::google::protobuf::uint32 value); - // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + // required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; bool has_type() const; void clear_type(); - static const int kTypeFieldNumber = 3; + static const int kTypeFieldNumber = 4; ::PbFaceList_FaceListImage_ImageType type() const; void set_type(::PbFaceList_FaceListImage_ImageType value); @@ -296,6 +303,8 @@ private: void set_has_idx(); void clear_has_idx(); + void set_has_st_track_id(); + void clear_has_st_track_id(); void set_has_size(); void clear_has_size(); void set_has_type(); @@ -317,6 +326,7 @@ mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::std::string> img_; ::google::protobuf::uint32 idx_; + ::google::protobuf::uint32 st_track_id_; ::google::protobuf::uint32 size_; ::google::protobuf::uint32 width_; ::google::protobuf::uint32 height_; @@ -500,15 +510,39 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.idx) } -// required uint32 size = 2; -inline bool PbFaceList_FaceListImage::has_size() const { +// required uint32 st_track_id = 2; +inline bool PbFaceList_FaceListImage::has_st_track_id() const { return (_has_bits_[0] & 0x00000002u) != 0; } -inline void PbFaceList_FaceListImage::set_has_size() { +inline void PbFaceList_FaceListImage::set_has_st_track_id() { _has_bits_[0] |= 0x00000002u; } -inline void PbFaceList_FaceListImage::clear_has_size() { +inline void PbFaceList_FaceListImage::clear_has_st_track_id() { _has_bits_[0] &= ~0x00000002u; +} +inline void PbFaceList_FaceListImage::clear_st_track_id() { + st_track_id_ = 0u; + clear_has_st_track_id(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::st_track_id() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.st_track_id) + return st_track_id_; +} +inline void PbFaceList_FaceListImage::set_st_track_id(::google::protobuf::uint32 value) { + set_has_st_track_id(); + st_track_id_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.st_track_id) +} + +// required uint32 size = 3; +inline bool PbFaceList_FaceListImage::has_size() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_size() { + _has_bits_[0] |= 0x00000004u; +} +inline void PbFaceList_FaceListImage::clear_has_size() { + _has_bits_[0] &= ~0x00000004u; } inline void PbFaceList_FaceListImage::clear_size() { size_ = 0u; @@ -524,15 +558,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.size) } -// required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; +// required .PbFaceList.FaceListImage.ImageType type = 4 [default = MBFT_Y8]; inline bool PbFaceList_FaceListImage::has_type() const { - return (_has_bits_[0] & 0x00000040u) != 0; + return (_has_bits_[0] & 0x00000080u) != 0; } inline void PbFaceList_FaceListImage::set_has_type() { - _has_bits_[0] |= 0x00000040u; + _has_bits_[0] |= 0x00000080u; } inline void PbFaceList_FaceListImage::clear_has_type() { - _has_bits_[0] &= ~0x00000040u; + _has_bits_[0] &= ~0x00000080u; } inline void PbFaceList_FaceListImage::clear_type() { type_ = 9; @@ -549,15 +583,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.type) } -// required uint32 width = 4; +// required uint32 width = 5; inline bool PbFaceList_FaceListImage::has_width() const { - return (_has_bits_[0] & 0x00000004u) != 0; + return (_has_bits_[0] & 0x00000008u) != 0; } inline void PbFaceList_FaceListImage::set_has_width() { - _has_bits_[0] |= 0x00000004u; + _has_bits_[0] |= 0x00000008u; } inline void PbFaceList_FaceListImage::clear_has_width() { - _has_bits_[0] &= ~0x00000004u; + _has_bits_[0] &= ~0x00000008u; } inline void PbFaceList_FaceListImage::clear_width() { width_ = 0u; @@ -573,15 +607,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.width) } -// required uint32 height = 5; +// required uint32 height = 6; inline bool PbFaceList_FaceListImage::has_height() const { - return (_has_bits_[0] & 0x00000008u) != 0; + return (_has_bits_[0] & 0x00000010u) != 0; } inline void PbFaceList_FaceListImage::set_has_height() { - _has_bits_[0] |= 0x00000008u; + _has_bits_[0] |= 0x00000010u; } inline void PbFaceList_FaceListImage::clear_has_height() { - _has_bits_[0] &= ~0x00000008u; + _has_bits_[0] &= ~0x00000010u; } inline void PbFaceList_FaceListImage::clear_height() { height_ = 0u; @@ -597,15 +631,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.height) } -// optional uint32 top_left_x = 6; +// optional uint32 top_left_x = 7; inline bool PbFaceList_FaceListImage::has_top_left_x() const { - return (_has_bits_[0] & 0x00000010u) != 0; + return (_has_bits_[0] & 0x00000020u) != 0; } inline void PbFaceList_FaceListImage::set_has_top_left_x() { - _has_bits_[0] |= 0x00000010u; + _has_bits_[0] |= 0x00000020u; } inline void PbFaceList_FaceListImage::clear_has_top_left_x() { - _has_bits_[0] &= ~0x00000010u; + _has_bits_[0] &= ~0x00000020u; } inline void PbFaceList_FaceListImage::clear_top_left_x() { top_left_x_ = 0u; @@ -621,15 +655,15 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_x) } -// optional uint32 top_left_y = 7; +// optional uint32 top_left_y = 8; inline bool PbFaceList_FaceListImage::has_top_left_y() const { - return (_has_bits_[0] & 0x00000020u) != 0; + return (_has_bits_[0] & 0x00000040u) != 0; } inline void PbFaceList_FaceListImage::set_has_top_left_y() { - _has_bits_[0] |= 0x00000020u; + _has_bits_[0] |= 0x00000040u; } inline void PbFaceList_FaceListImage::clear_has_top_left_y() { - _has_bits_[0] &= ~0x00000020u; + _has_bits_[0] &= ~0x00000040u; } inline void PbFaceList_FaceListImage::clear_top_left_y() { top_left_y_ = 0u; @@ -645,7 +679,7 @@ // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_y) } -// repeated bytes img = 8; +// repeated bytes img = 9; inline int PbFaceList_FaceListImage::img_size() const { return img_.size(); } diff --git a/FaceServer/STFaceCache.cpp b/FaceServer/STFaceCache.cpp index 52e3c69..6d5026d 100644 --- a/FaceServer/STFaceCache.cpp +++ b/FaceServer/STFaceCache.cpp @@ -9,12 +9,6 @@ #include "sample_face_search.h" #include <cv_face.h> -#define FDP_FDR_INVALID FDP_FaceDetectResult(0, 0, 0) -#define ENABLE_AUTO_CREATE_STFACEDB -#define ENABLE_SEARCH_IN_NEGATIVE_DBID -#define ENABLE_SEARCH_IN_NEGATIVE_DBID -#define RESULT_CONFIDENCE 0.70 - struct STFaceCacheContext { cv_handle_t handle_verify; @@ -72,7 +66,7 @@ handles.handle_db = nullptr; dbLoadOK = false; } - + std::string db_full_path() const { if (dbfpath.empty() || dbfname.empty()) @@ -89,7 +83,8 @@ STFaceCache::STFaceCache(const std::string& _stfacedbPath) : stfacedbPath(_stfacedbPath), stfaceModels(STFACESDK_BASE "/models"), - _dbContext(new stface_ctx_map_t), _cacheContext(new STFaceCacheContext) + _dbContext(new stface_ctx_map_t), _cacheContext(new STFaceCacheContext), + tempdbFaceCount(0) { LOG_INFO << "st face db: " << stfacedbPath << LOG_ENDL; LOG_INFO << "st face sdk models: " << stfaceModels << LOG_ENDL; @@ -207,13 +202,22 @@ return FDP_FDR_INVALID; } -#ifdef ENABLE_SEARCH_IN_NEGATIVE_DBID - STFaceImage imgNeg(img); - imgNeg.db_id = -1; - return detect(imgNeg); -#else - return FDP_FDR_INVALID; +#ifdef ENABLE_DETECT_IN_NEGATIVE_DBID + STFaceImage imgNeg(img); + FDP_FaceDetectResult res(FDP_FDR_INVALID); + + imgNeg.db_id = STFS_DBID_VISITOR_1; + res = detect(imgNeg); // #todo optimize extract feature once + if (res.db_id != STFS_DBID_INVALID) + return res; + + imgNeg.db_id = STFS_DBID_TEMPDB_1; + res = detect(imgNeg); + if (res.db_id != STFS_DBID_INVALID) + return res; #endif + + return FDP_FDR_INVALID; } FDP_FaceDetectResult STFaceCache::detect(const STFaceImage& img) @@ -323,6 +327,10 @@ return FDP_FDR_INVALID; } +#ifdef ENABLE_ADD_TO_TEMPDB_WHEN_NOT_DETECT + tempdbFaceCount++; +#endif + int idx = stface_db_add(ctx.handles, img); LOG_INFO << "stface_db_add dbid=" << img.db_id << ", idx=" << idx << LOG_ENDL; if (idx <= 1) @@ -347,7 +355,6 @@ stface_ctx_map_t& dbContext(*(stface_ctx_map_t*)_dbContext); STFaceCacheContext& cacheContext(*(STFaceCacheContext*)_cacheContext); - for(stface_ctx_map_t::iterator iterCtx = dbContext.begin(); iterCtx != dbContext.end(); ++iterCtx) { STFaceDBContext& ctx(iterCtx->second); @@ -416,4 +423,26 @@ topResult.push_back(FDP_FaceDetectResult(-1, 2, 4)); topResult.push_back(FDP_FaceDetectResult(1, 6, 5)); */ -} \ No newline at end of file +} + +void STFaceCache::delete_db(int dbid) +{ + stface_ctx_map_t& dbContext(*(stface_ctx_map_t*)_dbContext); + STFaceCacheContext& cacheContext(*(STFaceCacheContext*)_cacheContext); + + stface_ctx_map_t::iterator iterCtx = dbContext.find(dbid); + if (iterCtx == dbContext.end()) + { + LOG_WARN << "no dbid=%d" << dbid << LOG_ENDL; + return; + } + + STFaceDBContext& ctx(iterCtx->second); + ctx.close_db(); + + char mvDBtoBak[1000]; + sprintf(mvDBtoBak, "cd %s; mv %s %d.bak;", stfacedbPath.c_str(), ctx.db_full_path().c_str(), dbid); + system(mvDBtoBak); + + dbContext.erase(iterCtx); +} diff --git a/FaceServer/STFaceCache.h b/FaceServer/STFaceCache.h index ff50309..44fb677 100644 --- a/FaceServer/STFaceCache.h +++ b/FaceServer/STFaceCache.h @@ -4,6 +4,20 @@ #include <string> #include "face_daemon_proto.h" +#define FDP_FDR_INVALID FDP_FaceDetectResult(STFS_DBID_INVALID, 0, 0) +#define ENABLE_AUTO_CREATE_STFACEDB +#define ENABLE_DETECT_IN_NEGATIVE_DBID +//#define ENABLE_ADD_TO_TEMPDB_WHEN_NOT_DETECT +#define RESULT_CONFIDENCE 0.70 +#define TEMPDB_FACE_COUNT_MAX 10 + +enum STFSpecialDBID +{ + STFS_DBID_INVALID = 0, + STFS_DBID_VISITOR_1 = -1, + STFS_DBID_TEMPDB_1 = -1000 +}; + struct STFaceImage; class STFaceCache @@ -21,6 +35,7 @@ FDP_FaceDetectResult add(const STFaceImage& img); void search(const STFaceImage& img, fdr_vec_t& topResult); FDP_FaceDetectResult compare(const STFaceImage& img1, const STFaceImage& img2); + void delete_db(int dbid); //#todo need a delete img, if business not linked faceid and its personid // they can delete it and save/find again! @@ -33,6 +48,8 @@ const std::string stfaceModels; void* _dbContext; void* _cacheContext; + + int tempdbFaceCount; }; #endif diff --git a/FaceServer/face_daemon_proto.h b/FaceServer/face_daemon_proto.h index ed82594..cf642a9 100644 --- a/FaceServer/face_daemon_proto.h +++ b/FaceServer/face_daemon_proto.h @@ -42,8 +42,9 @@ struct FDP_FaceDetectPB { int32_t db_id; + int16_t camera_id; - FDP_FaceDetectPB(int32_t _db_id) : db_id(_db_id) + FDP_FaceDetectPB(int32_t _db_id, int16_t _camera_id) : db_id(_db_id), camera_id(_camera_id) {} void hton(); @@ -56,7 +57,11 @@ int32_t st_id; // sensetime id int16_t confidence; // 1000 times of float confidence, less than zero means error - FDP_FaceDetectResult(int32_t _db_id, int32_t _st_id, int _confidence) : db_id(_db_id), st_id(_st_id), confidence(_confidence) + int16_t camera_id; + int32_t st_track_id; + + FDP_FaceDetectResult(int32_t _db_id, int32_t _st_id, int _confidence) : + db_id(_db_id), st_id(_st_id), confidence(_confidence), camera_id(0), st_track_id(0) {} void hton(); diff --git a/FaceServer/main_face_daemon.cpp b/FaceServer/main_face_daemon.cpp index bd12356..baff933 100644 --- a/FaceServer/main_face_daemon.cpp +++ b/FaceServer/main_face_daemon.cpp @@ -34,7 +34,11 @@ ss << "\"result\":["; for(fdr_vec_t::const_iterator iter = result.begin(); iter != result.end(); ++iter) { - ss << "[" << WRAPPER_TEXT(iter->db_id) << "," << WRAPPER_TEXT(iter->st_id) << "," << WRAPPER_TEXT(iter->confidence) << "]"; + ss << "[" << WRAPPER_TEXT(iter->db_id) << "," + << WRAPPER_TEXT(iter->st_id) << "," + << WRAPPER_TEXT(iter->confidence) << "," + << WRAPPER_TEXT(iter->camera_id) << "," + << WRAPPER_TEXT(iter->st_track_id) << "]"; if (iter != std::prev(result.end())) ss << ","; } @@ -93,7 +97,21 @@ stimg.height = pbFaceListImage.height(); stimg.size = img->size(); stimg.buff = (const uint8_t*)img->data(); - result.push_back(g_STFaceCache.detect(stimg)); + + FDP_FaceDetectResult res(g_STFaceCache.detect(stimg)); + +#ifdef ENABLE_ADD_TO_TEMPDB_WHEN_NOT_DETECT + if (res.db_id == STFS_DBID_INVALID) + { + // #todo optimize extract feature once + stimg.db_id = STFS_DBID_TEMPDB_1; + res = g_STFaceCache.add(stimg); + } +#endif + + res.camera_id = fdpFaceDetectPB->camera_id; + res.st_track_id = pbFaceListImage.st_track_id(); + result.push_back(res); } //#test diff --git a/FaceServer/proto_hton_ntoh.cpp b/FaceServer/proto_hton_ntoh.cpp index ccc2da9..1aaa892 100644 --- a/FaceServer/proto_hton_ntoh.cpp +++ b/FaceServer/proto_hton_ntoh.cpp @@ -55,11 +55,13 @@ void FDP_FaceDetectPB::hton() { db_id = htonl(db_id); + camera_id = htons(camera_id); } void FDP_FaceDetectPB::ntoh() { db_id = ntohl(db_id); + camera_id = ntohs(camera_id); } void FDP_FaceDetectResult::hton() @@ -67,6 +69,8 @@ db_id = htonl(db_id); st_id = htonl(st_id); confidence = htons(confidence); + camera_id = htons(camera_id); + st_track_id = htonl(st_track_id); } void FDP_FaceDetectResult::ntoh() @@ -74,4 +78,6 @@ db_id = ntohl(db_id); st_id = ntohl(st_id); confidence = ntohs(confidence); + camera_id = ntohs(camera_id); + st_track_id = ntohl(st_track_id); } -- Gitblit v1.8.0