From 52bd84663ef5bff417588dccd324937d506b9d95 Mon Sep 17 00:00:00 2001 From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674> Date: 星期四, 27 四月 2017 18:38:13 +0800 Subject: [PATCH] optimize --- FaceServer/bias.jpg | 0 FaceServer/STFaceCache.cpp | 86 + FaceServer/make.sh | 23 FaceServer/PbFaceList.pb.h | 820 +++++++++++++++++ FaceServer/PbFaceList | 33 FaceServer/main_face_daemon.cpp | 21 FaceServer/license.lic | 36 FaceServer/sample_face_search.h | 2 FaceServer/sample_face_search.cpp | 223 +++- FaceServer/PbFaceList.pb.cc | 1498 ++++++++++++++++++++++++++++++++ FaceServer/STFaceCache.h | 3 11 files changed, 2,638 insertions(+), 107 deletions(-) diff --git a/FaceServer/PbFaceList b/FaceServer/PbFaceList new file mode 100644 index 0000000..c2fb55d --- /dev/null +++ b/FaceServer/PbFaceList @@ -0,0 +1,33 @@ +// /opt/protobuf/src/protoc PbFaceList --cpp_out=./ + +syntax = "proto2"; + +message PbFaceList +{ + required uint32 magic = 1 [default = 0xB2A105]; + required uint32 image_count = 2; + optional uint32 src_width = 3; + optional uint32 src_height = 4; + + message FaceListImage + { + enum ImageType + { + MBFT_YUV = 8; + MBFT_Y8 = 9; + MBFT_RGB = 11; + } + + 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; + } + + repeated FaceListImage images = 5; +} diff --git a/FaceServer/PbFaceList.pb.cc b/FaceServer/PbFaceList.pb.cc new file mode 100644 index 0000000..589c7f8 --- /dev/null +++ b/FaceServer/PbFaceList.pb.cc @@ -0,0 +1,1498 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: PbFaceList + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "PbFaceList.pb.h" + +#include <algorithm> + +#include <google/protobuf/stubs/common.h> +#include <google/protobuf/stubs/port.h> +#include <google/protobuf/stubs/once.h> +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/wire_format_lite_inl.h> +#include <google/protobuf/descriptor.h> +#include <google/protobuf/generated_message_reflection.h> +#include <google/protobuf/reflection_ops.h> +#include <google/protobuf/wire_format.h> +// @@protoc_insertion_point(includes) +class PbFaceList_FaceListImageDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<PbFaceList_FaceListImage> { +} _PbFaceList_FaceListImage_default_instance_; +class PbFaceListDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<PbFaceList> { +} _PbFaceList_default_instance_; + +namespace protobuf_PbFaceList { + + +namespace { + +::google::protobuf::Metadata file_level_metadata[2]; +const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1]; + +} // namespace + +const ::google::protobuf::uint32 TableStruct::offsets[] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, idx_), + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, height_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, top_left_x_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, top_left_y_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList_FaceListImage, img_), + 0, + 1, + 6, + 2, + 3, + 4, + 5, + ~0u, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, magic_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, image_count_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, src_width_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, src_height_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PbFaceList, images_), + 3, + 0, + 1, + 2, + ~0u, +}; + +static const ::google::protobuf::internal::MigrationSchema schemas[] = { + { 0, 12, sizeof(PbFaceList_FaceListImage)}, + { 20, 29, sizeof(PbFaceList)}, +}; + +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_PbFaceList_FaceListImage_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_PbFaceList_default_instance_), +}; + +namespace { + +void protobuf_AssignDescriptors() { + AddDescriptors(); + ::google::protobuf::MessageFactory* factory = NULL; + AssignDescriptors( + "PbFaceList", schemas, file_default_instances, TableStruct::offsets, factory, + file_level_metadata, file_level_enum_descriptors, NULL); +} + +void protobuf_AssignDescriptorsOnce() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); +} + +void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2); +} + +} // namespace + +void TableStruct::Shutdown() { + _PbFaceList_FaceListImage_default_instance_.Shutdown(); + delete file_level_metadata[0].reflection; + _PbFaceList_default_instance_.Shutdown(); + delete file_level_metadata[1].reflection; +} + +void TableStruct::InitDefaultsImpl() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::internal::InitProtobufDefaults(); + _PbFaceList_FaceListImage_default_instance_.DefaultConstruct(); + _PbFaceList_default_instance_.DefaultConstruct(); +} + +void InitDefaults() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); +} +void AddDescriptorsImpl() { + InitDefaults(); + static const char descriptor[] = { + "\n\nPbFaceList\"\377\002\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\360\001\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\"4\n\tImageType\022\014\n" + "\010MBFT_YUV\020\010\022\013\n\007MBFT_Y8\020\t\022\014\n\010MBFT_RGB\020\013" + }; + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + descriptor, 398); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "PbFaceList", &protobuf_RegisterTypes); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); +} + +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); +} +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); + } +} static_descriptor_initializer; + +} // namespace protobuf_PbFaceList + +const ::google::protobuf::EnumDescriptor* PbFaceList_FaceListImage_ImageType_descriptor() { + protobuf_PbFaceList::protobuf_AssignDescriptorsOnce(); + return protobuf_PbFaceList::file_level_enum_descriptors[0]; +} +bool PbFaceList_FaceListImage_ImageType_IsValid(int value) { + switch (value) { + case 8: + case 9: + case 11: + return true; + default: + return false; + } +} + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::MBFT_YUV; +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::MBFT_Y8; +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::MBFT_RGB; +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::ImageType_MIN; +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::ImageType_MAX; +const int PbFaceList_FaceListImage::ImageType_ARRAYSIZE; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int PbFaceList_FaceListImage::kIdxFieldNumber; +const int PbFaceList_FaceListImage::kSizeFieldNumber; +const int PbFaceList_FaceListImage::kTypeFieldNumber; +const int PbFaceList_FaceListImage::kWidthFieldNumber; +const int PbFaceList_FaceListImage::kHeightFieldNumber; +const int PbFaceList_FaceListImage::kTopLeftXFieldNumber; +const int PbFaceList_FaceListImage::kTopLeftYFieldNumber; +const int PbFaceList_FaceListImage::kImgFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +PbFaceList_FaceListImage::PbFaceList_FaceListImage() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_PbFaceList::InitDefaults(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:PbFaceList.FaceListImage) +} +PbFaceList_FaceListImage::PbFaceList_FaceListImage(const PbFaceList_FaceListImage& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + img_(from.img_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&idx_, &from.idx_, + reinterpret_cast<char*>(&type_) - + reinterpret_cast<char*>(&idx_) + sizeof(type_)); + // @@protoc_insertion_point(copy_constructor:PbFaceList.FaceListImage) +} + +void PbFaceList_FaceListImage::SharedCtor() { + _cached_size_ = 0; + ::memset(&idx_, 0, reinterpret_cast<char*>(&top_left_y_) - + reinterpret_cast<char*>(&idx_) + sizeof(top_left_y_)); + type_ = 9; +} + +PbFaceList_FaceListImage::~PbFaceList_FaceListImage() { + // @@protoc_insertion_point(destructor:PbFaceList.FaceListImage) + SharedDtor(); +} + +void PbFaceList_FaceListImage::SharedDtor() { +} + +void PbFaceList_FaceListImage::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* PbFaceList_FaceListImage::descriptor() { + protobuf_PbFaceList::protobuf_AssignDescriptorsOnce(); + return protobuf_PbFaceList::file_level_metadata[0].descriptor; +} + +const PbFaceList_FaceListImage& PbFaceList_FaceListImage::default_instance() { + protobuf_PbFaceList::InitDefaults(); + return *internal_default_instance(); +} + +PbFaceList_FaceListImage* PbFaceList_FaceListImage::New(::google::protobuf::Arena* arena) const { + PbFaceList_FaceListImage* n = new PbFaceList_FaceListImage; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void PbFaceList_FaceListImage::Clear() { +// @@protoc_insertion_point(message_clear_start:PbFaceList.FaceListImage) + img_.Clear(); + if (_has_bits_[0 / 32] & 127u) { + ::memset(&idx_, 0, reinterpret_cast<char*>(&top_left_y_) - + reinterpret_cast<char*>(&idx_) + sizeof(top_left_y_)); + type_ = 9; + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool PbFaceList_FaceListImage::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:PbFaceList.FaceListImage) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required uint32 idx = 1; + case 1: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { + set_has_idx(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &idx_))); + } else { + goto handle_unusual; + } + break; + } + + // required uint32 size = 2; + case 2: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { + set_has_size(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &size_))); + } else { + goto handle_unusual; + } + break; + } + + // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { + int value; + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( + input, &value))); + if (::PbFaceList_FaceListImage_ImageType_IsValid(value)) { + set_type(static_cast< ::PbFaceList_FaceListImage_ImageType >(value)); + } else { + mutable_unknown_fields()->AddVarint(3, value); + } + } else { + goto handle_unusual; + } + break; + } + + // required uint32 width = 4; + case 4: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { + set_has_width(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &width_))); + } else { + goto handle_unusual; + } + break; + } + + // required uint32 height = 5; + case 5: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(40u)) { + set_has_height(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &height_))); + } else { + goto handle_unusual; + } + break; + } + + // optional uint32 top_left_x = 6; + case 6: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(48u)) { + set_has_top_left_x(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &top_left_x_))); + } else { + goto handle_unusual; + } + break; + } + + // optional uint32 top_left_y = 7; + case 7: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(56u)) { + set_has_top_left_y(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &top_left_y_))); + } else { + goto handle_unusual; + } + break; + } + + // repeated bytes img = 8; + case 8: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(66u)) { + DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( + input, this->add_img())); + } else { + goto handle_unusual; + } + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:PbFaceList.FaceListImage) + return true; +failure: + // @@protoc_insertion_point(parse_failure:PbFaceList.FaceListImage) + return false; +#undef DO_ +} + +void PbFaceList_FaceListImage::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:PbFaceList.FaceListImage) + // required uint32 idx = 1; + if (has_idx()) { + ::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 .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + if (has_type()) { + ::google::protobuf::internal::WireFormatLite::WriteEnum( + 3, this->type(), output); + } + + // required uint32 width = 4; + if (has_width()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->width(), output); + } + + // required uint32 height = 5; + if (has_height()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->height(), output); + } + + // optional uint32 top_left_x = 6; + if (has_top_left_x()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->top_left_x(), output); + } + + // optional uint32 top_left_y = 7; + if (has_top_left_y()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->top_left_y(), output); + } + + // repeated bytes img = 8; + for (int i = 0, n = this->img_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteBytes( + 8, this->img(i), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:PbFaceList.FaceListImage) +} + +::google::protobuf::uint8* PbFaceList_FaceListImage::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:PbFaceList.FaceListImage) + // required uint32 idx = 1; + if (has_idx()) { + 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 .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + if (has_type()) { + target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( + 3, this->type(), target); + } + + // required uint32 width = 4; + if (has_width()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->width(), target); + } + + // required uint32 height = 5; + if (has_height()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->height(), target); + } + + // optional uint32 top_left_x = 6; + if (has_top_left_x()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->top_left_x(), target); + } + + // optional uint32 top_left_y = 7; + if (has_top_left_y()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->top_left_y(), target); + } + + // repeated bytes img = 8; + for (int i = 0, n = this->img_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteBytesToArray(8, this->img(i), target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:PbFaceList.FaceListImage) + return target; +} + +size_t PbFaceList_FaceListImage::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:PbFaceList.FaceListImage) + size_t total_size = 0; + + if (has_idx()) { + // required uint32 idx = 1; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->idx()); + } + + if (has_size()) { + // required uint32 size = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->size()); + } + + if (has_width()) { + // required uint32 width = 4; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->width()); + } + + if (has_height()) { + // required uint32 height = 5; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->height()); + } + + if (has_type()) { + // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + } + + return total_size; +} +size_t PbFaceList_FaceListImage::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:PbFaceList.FaceListImage) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + if (((_has_bits_[0] & 0x0000004f) ^ 0x0000004f) == 0) { // All required fields are present. + // required uint32 idx = 1; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->idx()); + + // required uint32 size = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->size()); + + // required uint32 width = 4; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->width()); + + // required uint32 height = 5; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->height()); + + // required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + // repeated bytes img = 8; + total_size += 1 * + ::google::protobuf::internal::FromIntSize(this->img_size()); + for (int i = 0, n = this->img_size(); i < n; i++) { + total_size += ::google::protobuf::internal::WireFormatLite::BytesSize( + this->img(i)); + } + + if (_has_bits_[0 / 32] & 48u) { + // optional uint32 top_left_x = 6; + if (has_top_left_x()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->top_left_x()); + } + + // optional uint32 top_left_y = 7; + if (has_top_left_y()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->top_left_y()); + } + + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void PbFaceList_FaceListImage::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:PbFaceList.FaceListImage) + GOOGLE_DCHECK_NE(&from, this); + const PbFaceList_FaceListImage* source = + ::google::protobuf::internal::DynamicCastToGenerated<const PbFaceList_FaceListImage>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:PbFaceList.FaceListImage) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:PbFaceList.FaceListImage) + MergeFrom(*source); + } +} + +void PbFaceList_FaceListImage::MergeFrom(const PbFaceList_FaceListImage& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:PbFaceList.FaceListImage) + 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_idx()) { + set_idx(from.idx()); + } + if (from.has_size()) { + set_size(from.size()); + } + if (from.has_width()) { + set_width(from.width()); + } + if (from.has_height()) { + set_height(from.height()); + } + if (from.has_top_left_x()) { + set_top_left_x(from.top_left_x()); + } + if (from.has_top_left_y()) { + set_top_left_y(from.top_left_y()); + } + if (from.has_type()) { + set_type(from.type()); + } + } +} + +void PbFaceList_FaceListImage::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:PbFaceList.FaceListImage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void PbFaceList_FaceListImage::CopyFrom(const PbFaceList_FaceListImage& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:PbFaceList.FaceListImage) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool PbFaceList_FaceListImage::IsInitialized() const { + if ((_has_bits_[0] & 0x0000004f) != 0x0000004f) return false; + return true; +} + +void PbFaceList_FaceListImage::Swap(PbFaceList_FaceListImage* other) { + if (other == this) return; + InternalSwap(other); +} +void PbFaceList_FaceListImage::InternalSwap(PbFaceList_FaceListImage* other) { + img_.UnsafeArenaSwap(&other->img_); + std::swap(idx_, other->idx_); + std::swap(size_, other->size_); + std::swap(width_, other->width_); + std::swap(height_, other->height_); + std::swap(top_left_x_, other->top_left_x_); + std::swap(top_left_y_, other->top_left_y_); + std::swap(type_, other->type_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata PbFaceList_FaceListImage::GetMetadata() const { + protobuf_PbFaceList::protobuf_AssignDescriptorsOnce(); + return protobuf_PbFaceList::file_level_metadata[0]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PbFaceList_FaceListImage + +// required uint32 idx = 1; +bool PbFaceList_FaceListImage::has_idx() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PbFaceList_FaceListImage::set_has_idx() { + _has_bits_[0] |= 0x00000001u; +} +void PbFaceList_FaceListImage::clear_has_idx() { + _has_bits_[0] &= ~0x00000001u; +} +void PbFaceList_FaceListImage::clear_idx() { + idx_ = 0u; + clear_has_idx(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::idx() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.idx) + return idx_; +} +void PbFaceList_FaceListImage::set_idx(::google::protobuf::uint32 value) { + set_has_idx(); + idx_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.idx) +} + +// required uint32 size = 2; +bool PbFaceList_FaceListImage::has_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PbFaceList_FaceListImage::set_has_size() { + _has_bits_[0] |= 0x00000002u; +} +void PbFaceList_FaceListImage::clear_has_size() { + _has_bits_[0] &= ~0x00000002u; +} +void PbFaceList_FaceListImage::clear_size() { + size_ = 0u; + clear_has_size(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::size() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.size) + return size_; +} +void PbFaceList_FaceListImage::set_size(::google::protobuf::uint32 value) { + set_has_size(); + size_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.size) +} + +// required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; +bool PbFaceList_FaceListImage::has_type() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +void PbFaceList_FaceListImage::set_has_type() { + _has_bits_[0] |= 0x00000040u; +} +void PbFaceList_FaceListImage::clear_has_type() { + _has_bits_[0] &= ~0x00000040u; +} +void PbFaceList_FaceListImage::clear_type() { + type_ = 9; + clear_has_type(); +} +::PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::type() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.type) + return static_cast< ::PbFaceList_FaceListImage_ImageType >(type_); +} +void PbFaceList_FaceListImage::set_type(::PbFaceList_FaceListImage_ImageType value) { + assert(::PbFaceList_FaceListImage_ImageType_IsValid(value)); + set_has_type(); + type_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.type) +} + +// required uint32 width = 4; +bool PbFaceList_FaceListImage::has_width() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void PbFaceList_FaceListImage::set_has_width() { + _has_bits_[0] |= 0x00000004u; +} +void PbFaceList_FaceListImage::clear_has_width() { + _has_bits_[0] &= ~0x00000004u; +} +void PbFaceList_FaceListImage::clear_width() { + width_ = 0u; + clear_has_width(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::width() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.width) + return width_; +} +void PbFaceList_FaceListImage::set_width(::google::protobuf::uint32 value) { + set_has_width(); + width_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.width) +} + +// required uint32 height = 5; +bool PbFaceList_FaceListImage::has_height() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void PbFaceList_FaceListImage::set_has_height() { + _has_bits_[0] |= 0x00000008u; +} +void PbFaceList_FaceListImage::clear_has_height() { + _has_bits_[0] &= ~0x00000008u; +} +void PbFaceList_FaceListImage::clear_height() { + height_ = 0u; + clear_has_height(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::height() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.height) + return height_; +} +void PbFaceList_FaceListImage::set_height(::google::protobuf::uint32 value) { + set_has_height(); + height_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.height) +} + +// optional uint32 top_left_x = 6; +bool PbFaceList_FaceListImage::has_top_left_x() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +void PbFaceList_FaceListImage::set_has_top_left_x() { + _has_bits_[0] |= 0x00000010u; +} +void PbFaceList_FaceListImage::clear_has_top_left_x() { + _has_bits_[0] &= ~0x00000010u; +} +void PbFaceList_FaceListImage::clear_top_left_x() { + top_left_x_ = 0u; + clear_has_top_left_x(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::top_left_x() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.top_left_x) + return top_left_x_; +} +void PbFaceList_FaceListImage::set_top_left_x(::google::protobuf::uint32 value) { + set_has_top_left_x(); + top_left_x_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_x) +} + +// optional uint32 top_left_y = 7; +bool PbFaceList_FaceListImage::has_top_left_y() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +void PbFaceList_FaceListImage::set_has_top_left_y() { + _has_bits_[0] |= 0x00000020u; +} +void PbFaceList_FaceListImage::clear_has_top_left_y() { + _has_bits_[0] &= ~0x00000020u; +} +void PbFaceList_FaceListImage::clear_top_left_y() { + top_left_y_ = 0u; + clear_has_top_left_y(); +} +::google::protobuf::uint32 PbFaceList_FaceListImage::top_left_y() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.top_left_y) + return top_left_y_; +} +void PbFaceList_FaceListImage::set_top_left_y(::google::protobuf::uint32 value) { + set_has_top_left_y(); + top_left_y_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_y) +} + +// repeated bytes img = 8; +int PbFaceList_FaceListImage::img_size() const { + return img_.size(); +} +void PbFaceList_FaceListImage::clear_img() { + img_.Clear(); +} +const ::std::string& PbFaceList_FaceListImage::img(int index) const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.img) + return img_.Get(index); +} +::std::string* PbFaceList_FaceListImage::mutable_img(int index) { + // @@protoc_insertion_point(field_mutable:PbFaceList.FaceListImage.img) + return img_.Mutable(index); +} +void PbFaceList_FaceListImage::set_img(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.img) + img_.Mutable(index)->assign(value); +} +#if LANG_CXX11 +void PbFaceList_FaceListImage::set_img(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.img) + img_.Mutable(index)->assign(std::move(value)); +} +#endif +void PbFaceList_FaceListImage::set_img(int index, const char* value) { + img_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:PbFaceList.FaceListImage.img) +} +void PbFaceList_FaceListImage::set_img(int index, const void* value, size_t size) { + img_.Mutable(index)->assign( + reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_set_pointer:PbFaceList.FaceListImage.img) +} +::std::string* PbFaceList_FaceListImage::add_img() { + // @@protoc_insertion_point(field_add_mutable:PbFaceList.FaceListImage.img) + return img_.Add(); +} +void PbFaceList_FaceListImage::add_img(const ::std::string& value) { + img_.Add()->assign(value); + // @@protoc_insertion_point(field_add:PbFaceList.FaceListImage.img) +} +#if LANG_CXX11 +void PbFaceList_FaceListImage::add_img(::std::string&& value) { + img_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:PbFaceList.FaceListImage.img) +} +#endif +void PbFaceList_FaceListImage::add_img(const char* value) { + img_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:PbFaceList.FaceListImage.img) +} +void PbFaceList_FaceListImage::add_img(const void* value, size_t size) { + img_.Add()->assign(reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_add_pointer:PbFaceList.FaceListImage.img) +} +const ::google::protobuf::RepeatedPtrField< ::std::string>& +PbFaceList_FaceListImage::img() const { + // @@protoc_insertion_point(field_list:PbFaceList.FaceListImage.img) + return img_; +} +::google::protobuf::RepeatedPtrField< ::std::string>* +PbFaceList_FaceListImage::mutable_img() { + // @@protoc_insertion_point(field_mutable_list:PbFaceList.FaceListImage.img) + return &img_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// =================================================================== + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +const int PbFaceList::kMagicFieldNumber; +const int PbFaceList::kImageCountFieldNumber; +const int PbFaceList::kSrcWidthFieldNumber; +const int PbFaceList::kSrcHeightFieldNumber; +const int PbFaceList::kImagesFieldNumber; +#endif // !defined(_MSC_VER) || _MSC_VER >= 1900 + +PbFaceList::PbFaceList() + : ::google::protobuf::Message(), _internal_metadata_(NULL) { + if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { + protobuf_PbFaceList::InitDefaults(); + } + SharedCtor(); + // @@protoc_insertion_point(constructor:PbFaceList) +} +PbFaceList::PbFaceList(const PbFaceList& from) + : ::google::protobuf::Message(), + _internal_metadata_(NULL), + _has_bits_(from._has_bits_), + _cached_size_(0), + images_(from.images_) { + _internal_metadata_.MergeFrom(from._internal_metadata_); + ::memcpy(&image_count_, &from.image_count_, + reinterpret_cast<char*>(&magic_) - + reinterpret_cast<char*>(&image_count_) + sizeof(magic_)); + // @@protoc_insertion_point(copy_constructor:PbFaceList) +} + +void PbFaceList::SharedCtor() { + _cached_size_ = 0; + ::memset(&image_count_, 0, reinterpret_cast<char*>(&src_height_) - + reinterpret_cast<char*>(&image_count_) + sizeof(src_height_)); + magic_ = 11706629u; +} + +PbFaceList::~PbFaceList() { + // @@protoc_insertion_point(destructor:PbFaceList) + SharedDtor(); +} + +void PbFaceList::SharedDtor() { +} + +void PbFaceList::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* PbFaceList::descriptor() { + protobuf_PbFaceList::protobuf_AssignDescriptorsOnce(); + return protobuf_PbFaceList::file_level_metadata[1].descriptor; +} + +const PbFaceList& PbFaceList::default_instance() { + protobuf_PbFaceList::InitDefaults(); + return *internal_default_instance(); +} + +PbFaceList* PbFaceList::New(::google::protobuf::Arena* arena) const { + PbFaceList* n = new PbFaceList; + if (arena != NULL) { + arena->Own(n); + } + return n; +} + +void PbFaceList::Clear() { +// @@protoc_insertion_point(message_clear_start:PbFaceList) + images_.Clear(); + if (_has_bits_[0 / 32] & 15u) { + ::memset(&image_count_, 0, reinterpret_cast<char*>(&src_height_) - + reinterpret_cast<char*>(&image_count_) + sizeof(src_height_)); + magic_ = 11706629u; + } + _has_bits_.Clear(); + _internal_metadata_.Clear(); +} + +bool PbFaceList::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure + ::google::protobuf::uint32 tag; + // @@protoc_insertion_point(parse_start:PbFaceList) + for (;;) { + ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); + tag = p.first; + if (!p.second) goto handle_unusual; + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required uint32 magic = 1 [default = 11706629]; + case 1: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(8u)) { + set_has_magic(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &magic_))); + } else { + goto handle_unusual; + } + break; + } + + // required uint32 image_count = 2; + case 2: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(16u)) { + set_has_image_count(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &image_count_))); + } else { + goto handle_unusual; + } + break; + } + + // optional uint32 src_width = 3; + case 3: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(24u)) { + set_has_src_width(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &src_width_))); + } else { + goto handle_unusual; + } + break; + } + + // optional uint32 src_height = 4; + case 4: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(32u)) { + set_has_src_height(); + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &src_height_))); + } else { + goto handle_unusual; + } + break; + } + + // repeated .PbFaceList.FaceListImage images = 5; + case 5: { + if (static_cast< ::google::protobuf::uint8>(tag) == + static_cast< ::google::protobuf::uint8>(42u)) { + DO_(input->IncrementRecursionDepth()); + DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth( + input, add_images())); + } else { + goto handle_unusual; + } + input->UnsafeDecrementRecursionDepth(); + break; + } + + default: { + handle_unusual: + if (tag == 0 || + ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + goto success; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } +success: + // @@protoc_insertion_point(parse_success:PbFaceList) + return true; +failure: + // @@protoc_insertion_point(parse_failure:PbFaceList) + return false; +#undef DO_ +} + +void PbFaceList::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // @@protoc_insertion_point(serialize_start:PbFaceList) + // required uint32 magic = 1 [default = 11706629]; + if (has_magic()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->magic(), output); + } + + // required uint32 image_count = 2; + if (has_image_count()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->image_count(), output); + } + + // optional uint32 src_width = 3; + if (has_src_width()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->src_width(), output); + } + + // optional uint32 src_height = 4; + if (has_src_height()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->src_height(), output); + } + + // repeated .PbFaceList.FaceListImage images = 5; + for (unsigned int i = 0, n = this->images_size(); i < n; i++) { + ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( + 5, this->images(i), output); + } + + if (_internal_metadata_.have_unknown_fields()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } + // @@protoc_insertion_point(serialize_end:PbFaceList) +} + +::google::protobuf::uint8* PbFaceList::InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const { + (void)deterministic; // Unused + // @@protoc_insertion_point(serialize_to_array_start:PbFaceList) + // required uint32 magic = 1 [default = 11706629]; + if (has_magic()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->magic(), target); + } + + // required uint32 image_count = 2; + if (has_image_count()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->image_count(), target); + } + + // optional uint32 src_width = 3; + if (has_src_width()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->src_width(), target); + } + + // optional uint32 src_height = 4; + if (has_src_height()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->src_height(), target); + } + + // repeated .PbFaceList.FaceListImage images = 5; + for (unsigned int i = 0, n = this->images_size(); i < n; i++) { + target = ::google::protobuf::internal::WireFormatLite:: + InternalWriteMessageNoVirtualToArray( + 5, this->images(i), false, target); + } + + if (_internal_metadata_.have_unknown_fields()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + // @@protoc_insertion_point(serialize_to_array_end:PbFaceList) + return target; +} + +size_t PbFaceList::RequiredFieldsByteSizeFallback() const { +// @@protoc_insertion_point(required_fields_byte_size_fallback_start:PbFaceList) + size_t total_size = 0; + + if (has_image_count()) { + // required uint32 image_count = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->image_count()); + } + + if (has_magic()) { + // required uint32 magic = 1 [default = 11706629]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->magic()); + } + + return total_size; +} +size_t PbFaceList::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:PbFaceList) + size_t total_size = 0; + + if (_internal_metadata_.have_unknown_fields()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + if (((_has_bits_[0] & 0x00000009) ^ 0x00000009) == 0) { // All required fields are present. + // required uint32 image_count = 2; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->image_count()); + + // required uint32 magic = 1 [default = 11706629]; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->magic()); + + } else { + total_size += RequiredFieldsByteSizeFallback(); + } + // repeated .PbFaceList.FaceListImage images = 5; + { + unsigned int count = this->images_size(); + total_size += 1UL * count; + for (unsigned int i = 0; i < count; i++) { + total_size += + ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( + this->images(i)); + } + } + + if (_has_bits_[0 / 32] & 6u) { + // optional uint32 src_width = 3; + if (has_src_width()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->src_width()); + } + + // optional uint32 src_height = 4; + if (has_src_height()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->src_height()); + } + + } + int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = cached_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void PbFaceList::MergeFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:PbFaceList) + GOOGLE_DCHECK_NE(&from, this); + const PbFaceList* source = + ::google::protobuf::internal::DynamicCastToGenerated<const PbFaceList>( + &from); + if (source == NULL) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:PbFaceList) + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:PbFaceList) + MergeFrom(*source); + } +} + +void PbFaceList::MergeFrom(const PbFaceList& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:PbFaceList) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom(from._internal_metadata_); + images_.MergeFrom(from.images_); + if (from._has_bits_[0 / 32] & 15u) { + if (from.has_image_count()) { + set_image_count(from.image_count()); + } + if (from.has_src_width()) { + set_src_width(from.src_width()); + } + if (from.has_src_height()) { + set_src_height(from.src_height()); + } + if (from.has_magic()) { + set_magic(from.magic()); + } + } +} + +void PbFaceList::CopyFrom(const ::google::protobuf::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:PbFaceList) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void PbFaceList::CopyFrom(const PbFaceList& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:PbFaceList) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool PbFaceList::IsInitialized() const { + if ((_has_bits_[0] & 0x00000009) != 0x00000009) return false; + if (!::google::protobuf::internal::AllAreInitialized(this->images())) return false; + return true; +} + +void PbFaceList::Swap(PbFaceList* other) { + if (other == this) return; + InternalSwap(other); +} +void PbFaceList::InternalSwap(PbFaceList* other) { + images_.UnsafeArenaSwap(&other->images_); + std::swap(image_count_, other->image_count_); + std::swap(src_width_, other->src_width_); + std::swap(src_height_, other->src_height_); + std::swap(magic_, other->magic_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _internal_metadata_.Swap(&other->_internal_metadata_); + std::swap(_cached_size_, other->_cached_size_); +} + +::google::protobuf::Metadata PbFaceList::GetMetadata() const { + protobuf_PbFaceList::protobuf_AssignDescriptorsOnce(); + return protobuf_PbFaceList::file_level_metadata[1]; +} + +#if PROTOBUF_INLINE_NOT_IN_HEADERS +// PbFaceList + +// required uint32 magic = 1 [default = 11706629]; +bool PbFaceList::has_magic() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +void PbFaceList::set_has_magic() { + _has_bits_[0] |= 0x00000008u; +} +void PbFaceList::clear_has_magic() { + _has_bits_[0] &= ~0x00000008u; +} +void PbFaceList::clear_magic() { + magic_ = 11706629u; + clear_has_magic(); +} +::google::protobuf::uint32 PbFaceList::magic() const { + // @@protoc_insertion_point(field_get:PbFaceList.magic) + return magic_; +} +void PbFaceList::set_magic(::google::protobuf::uint32 value) { + set_has_magic(); + magic_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.magic) +} + +// required uint32 image_count = 2; +bool PbFaceList::has_image_count() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +void PbFaceList::set_has_image_count() { + _has_bits_[0] |= 0x00000001u; +} +void PbFaceList::clear_has_image_count() { + _has_bits_[0] &= ~0x00000001u; +} +void PbFaceList::clear_image_count() { + image_count_ = 0u; + clear_has_image_count(); +} +::google::protobuf::uint32 PbFaceList::image_count() const { + // @@protoc_insertion_point(field_get:PbFaceList.image_count) + return image_count_; +} +void PbFaceList::set_image_count(::google::protobuf::uint32 value) { + set_has_image_count(); + image_count_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.image_count) +} + +// optional uint32 src_width = 3; +bool PbFaceList::has_src_width() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +void PbFaceList::set_has_src_width() { + _has_bits_[0] |= 0x00000002u; +} +void PbFaceList::clear_has_src_width() { + _has_bits_[0] &= ~0x00000002u; +} +void PbFaceList::clear_src_width() { + src_width_ = 0u; + clear_has_src_width(); +} +::google::protobuf::uint32 PbFaceList::src_width() const { + // @@protoc_insertion_point(field_get:PbFaceList.src_width) + return src_width_; +} +void PbFaceList::set_src_width(::google::protobuf::uint32 value) { + set_has_src_width(); + src_width_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.src_width) +} + +// optional uint32 src_height = 4; +bool PbFaceList::has_src_height() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +void PbFaceList::set_has_src_height() { + _has_bits_[0] |= 0x00000004u; +} +void PbFaceList::clear_has_src_height() { + _has_bits_[0] &= ~0x00000004u; +} +void PbFaceList::clear_src_height() { + src_height_ = 0u; + clear_has_src_height(); +} +::google::protobuf::uint32 PbFaceList::src_height() const { + // @@protoc_insertion_point(field_get:PbFaceList.src_height) + return src_height_; +} +void PbFaceList::set_src_height(::google::protobuf::uint32 value) { + set_has_src_height(); + src_height_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.src_height) +} + +// repeated .PbFaceList.FaceListImage images = 5; +int PbFaceList::images_size() const { + return images_.size(); +} +void PbFaceList::clear_images() { + images_.Clear(); +} +const ::PbFaceList_FaceListImage& PbFaceList::images(int index) const { + // @@protoc_insertion_point(field_get:PbFaceList.images) + return images_.Get(index); +} +::PbFaceList_FaceListImage* PbFaceList::mutable_images(int index) { + // @@protoc_insertion_point(field_mutable:PbFaceList.images) + return images_.Mutable(index); +} +::PbFaceList_FaceListImage* PbFaceList::add_images() { + // @@protoc_insertion_point(field_add:PbFaceList.images) + return images_.Add(); +} +::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >* +PbFaceList::mutable_images() { + // @@protoc_insertion_point(field_mutable_list:PbFaceList.images) + return &images_; +} +const ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >& +PbFaceList::images() const { + // @@protoc_insertion_point(field_list:PbFaceList.images) + return images_; +} + +#endif // PROTOBUF_INLINE_NOT_IN_HEADERS + +// @@protoc_insertion_point(namespace_scope) + +// @@protoc_insertion_point(global_scope) diff --git a/FaceServer/PbFaceList.pb.h b/FaceServer/PbFaceList.pb.h new file mode 100644 index 0000000..b1d5c42 --- /dev/null +++ b/FaceServer/PbFaceList.pb.h @@ -0,0 +1,820 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: PbFaceList + +#ifndef PROTOBUF_PbFaceList__INCLUDED +#define PROTOBUF_PbFaceList__INCLUDED + +#include <string> + +#include <google/protobuf/stubs/common.h> + +#if GOOGLE_PROTOBUF_VERSION < 3002000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include <google/protobuf/io/coded_stream.h> +#include <google/protobuf/arena.h> +#include <google/protobuf/arenastring.h> +#include <google/protobuf/generated_message_util.h> +#include <google/protobuf/metadata.h> +#include <google/protobuf/message.h> +#include <google/protobuf/repeated_field.h> // IWYU pragma: export +#include <google/protobuf/extension_set.h> // IWYU pragma: export +#include <google/protobuf/generated_enum_reflection.h> +#include <google/protobuf/unknown_field_set.h> +// @@protoc_insertion_point(includes) +class PbFaceList; +class PbFaceListDefaultTypeInternal; +extern PbFaceListDefaultTypeInternal _PbFaceList_default_instance_; +class PbFaceList_FaceListImage; +class PbFaceList_FaceListImageDefaultTypeInternal; +extern PbFaceList_FaceListImageDefaultTypeInternal _PbFaceList_FaceListImage_default_instance_; + +namespace protobuf_PbFaceList { +// Internal implementation detail -- do not call these. +struct TableStruct { + static const ::google::protobuf::uint32 offsets[]; + static void InitDefaultsImpl(); + static void Shutdown(); +}; +void AddDescriptors(); +void InitDefaults(); +} // namespace protobuf_PbFaceList + +enum PbFaceList_FaceListImage_ImageType { + PbFaceList_FaceListImage_ImageType_MBFT_YUV = 8, + PbFaceList_FaceListImage_ImageType_MBFT_Y8 = 9, + PbFaceList_FaceListImage_ImageType_MBFT_RGB = 11 +}; +bool PbFaceList_FaceListImage_ImageType_IsValid(int value); +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage_ImageType_ImageType_MIN = PbFaceList_FaceListImage_ImageType_MBFT_YUV; +const PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage_ImageType_ImageType_MAX = PbFaceList_FaceListImage_ImageType_MBFT_RGB; +const int PbFaceList_FaceListImage_ImageType_ImageType_ARRAYSIZE = PbFaceList_FaceListImage_ImageType_ImageType_MAX + 1; + +const ::google::protobuf::EnumDescriptor* PbFaceList_FaceListImage_ImageType_descriptor(); +inline const ::std::string& PbFaceList_FaceListImage_ImageType_Name(PbFaceList_FaceListImage_ImageType value) { + return ::google::protobuf::internal::NameOfEnum( + PbFaceList_FaceListImage_ImageType_descriptor(), value); +} +inline bool PbFaceList_FaceListImage_ImageType_Parse( + const ::std::string& name, PbFaceList_FaceListImage_ImageType* value) { + return ::google::protobuf::internal::ParseNamedEnum<PbFaceList_FaceListImage_ImageType>( + PbFaceList_FaceListImage_ImageType_descriptor(), name, value); +} +// =================================================================== + +class PbFaceList_FaceListImage : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:PbFaceList.FaceListImage) */ { + public: + PbFaceList_FaceListImage(); + virtual ~PbFaceList_FaceListImage(); + + PbFaceList_FaceListImage(const PbFaceList_FaceListImage& from); + + inline PbFaceList_FaceListImage& operator=(const PbFaceList_FaceListImage& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const PbFaceList_FaceListImage& default_instance(); + + static inline const PbFaceList_FaceListImage* internal_default_instance() { + return reinterpret_cast<const PbFaceList_FaceListImage*>( + &_PbFaceList_FaceListImage_default_instance_); + } + + void Swap(PbFaceList_FaceListImage* other); + + // implements Message ---------------------------------------------- + + inline PbFaceList_FaceListImage* New() const PROTOBUF_FINAL { return New(NULL); } + + PbFaceList_FaceListImage* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const PbFaceList_FaceListImage& from); + void MergeFrom(const PbFaceList_FaceListImage& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); + } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(PbFaceList_FaceListImage* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + typedef PbFaceList_FaceListImage_ImageType ImageType; + static const ImageType MBFT_YUV = + PbFaceList_FaceListImage_ImageType_MBFT_YUV; + static const ImageType MBFT_Y8 = + PbFaceList_FaceListImage_ImageType_MBFT_Y8; + static const ImageType MBFT_RGB = + PbFaceList_FaceListImage_ImageType_MBFT_RGB; + static inline bool ImageType_IsValid(int value) { + return PbFaceList_FaceListImage_ImageType_IsValid(value); + } + static const ImageType ImageType_MIN = + PbFaceList_FaceListImage_ImageType_ImageType_MIN; + static const ImageType ImageType_MAX = + PbFaceList_FaceListImage_ImageType_ImageType_MAX; + static const int ImageType_ARRAYSIZE = + PbFaceList_FaceListImage_ImageType_ImageType_ARRAYSIZE; + static inline const ::google::protobuf::EnumDescriptor* + ImageType_descriptor() { + return PbFaceList_FaceListImage_ImageType_descriptor(); + } + static inline const ::std::string& ImageType_Name(ImageType value) { + return PbFaceList_FaceListImage_ImageType_Name(value); + } + static inline bool ImageType_Parse(const ::std::string& name, + ImageType* value) { + return PbFaceList_FaceListImage_ImageType_Parse(name, value); + } + + // accessors ------------------------------------------------------- + + // repeated bytes img = 8; + int img_size() const; + void clear_img(); + static const int kImgFieldNumber = 8; + const ::std::string& img(int index) const; + ::std::string* mutable_img(int index); + void set_img(int index, const ::std::string& value); + #if LANG_CXX11 + void set_img(int index, ::std::string&& value); + #endif + void set_img(int index, const char* value); + void set_img(int index, const void* value, size_t size); + ::std::string* add_img(); + void add_img(const ::std::string& value); + #if LANG_CXX11 + void add_img(::std::string&& value); + #endif + void add_img(const char* value); + void add_img(const void* value, size_t size); + const ::google::protobuf::RepeatedPtrField< ::std::string>& img() const; + ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_img(); + + // required uint32 idx = 1; + bool has_idx() const; + void clear_idx(); + static const int kIdxFieldNumber = 1; + ::google::protobuf::uint32 idx() const; + void set_idx(::google::protobuf::uint32 value); + + // required uint32 size = 2; + bool has_size() const; + void clear_size(); + static const int kSizeFieldNumber = 2; + ::google::protobuf::uint32 size() const; + void set_size(::google::protobuf::uint32 value); + + // required uint32 width = 4; + bool has_width() const; + void clear_width(); + static const int kWidthFieldNumber = 4; + ::google::protobuf::uint32 width() const; + void set_width(::google::protobuf::uint32 value); + + // required uint32 height = 5; + bool has_height() const; + void clear_height(); + static const int kHeightFieldNumber = 5; + ::google::protobuf::uint32 height() const; + void set_height(::google::protobuf::uint32 value); + + // optional uint32 top_left_x = 6; + bool has_top_left_x() const; + void clear_top_left_x(); + static const int kTopLeftXFieldNumber = 6; + ::google::protobuf::uint32 top_left_x() const; + void set_top_left_x(::google::protobuf::uint32 value); + + // optional uint32 top_left_y = 7; + bool has_top_left_y() const; + void clear_top_left_y(); + static const int kTopLeftYFieldNumber = 7; + ::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]; + bool has_type() const; + void clear_type(); + static const int kTypeFieldNumber = 3; + ::PbFaceList_FaceListImage_ImageType type() const; + void set_type(::PbFaceList_FaceListImage_ImageType value); + + // @@protoc_insertion_point(class_scope:PbFaceList.FaceListImage) + private: + void set_has_idx(); + void clear_has_idx(); + void set_has_size(); + void clear_has_size(); + void set_has_type(); + void clear_has_type(); + void set_has_width(); + void clear_has_width(); + void set_has_height(); + void clear_has_height(); + void set_has_top_left_x(); + void clear_has_top_left_x(); + void set_has_top_left_y(); + void clear_has_top_left_y(); + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::std::string> img_; + ::google::protobuf::uint32 idx_; + ::google::protobuf::uint32 size_; + ::google::protobuf::uint32 width_; + ::google::protobuf::uint32 height_; + ::google::protobuf::uint32 top_left_x_; + ::google::protobuf::uint32 top_left_y_; + int type_; + friend struct protobuf_PbFaceList::TableStruct; +}; +// ------------------------------------------------------------------- + +class PbFaceList : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:PbFaceList) */ { + public: + PbFaceList(); + virtual ~PbFaceList(); + + PbFaceList(const PbFaceList& from); + + inline PbFaceList& operator=(const PbFaceList& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _internal_metadata_.unknown_fields(); + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return _internal_metadata_.mutable_unknown_fields(); + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const PbFaceList& default_instance(); + + static inline const PbFaceList* internal_default_instance() { + return reinterpret_cast<const PbFaceList*>( + &_PbFaceList_default_instance_); + } + + void Swap(PbFaceList* other); + + // implements Message ---------------------------------------------- + + inline PbFaceList* New() const PROTOBUF_FINAL { return New(NULL); } + + PbFaceList* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; + void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; + void CopyFrom(const PbFaceList& from); + void MergeFrom(const PbFaceList& from); + void Clear() PROTOBUF_FINAL; + bool IsInitialized() const PROTOBUF_FINAL; + + size_t ByteSizeLong() const PROTOBUF_FINAL; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; + ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( + bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) + const PROTOBUF_FINAL { + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); + } + int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const PROTOBUF_FINAL; + void InternalSwap(PbFaceList* other); + private: + inline ::google::protobuf::Arena* GetArenaNoVirtual() const { + return NULL; + } + inline void* MaybeArenaPtr() const { + return NULL; + } + public: + + ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; + + // nested types ---------------------------------------------------- + + typedef PbFaceList_FaceListImage FaceListImage; + + // accessors ------------------------------------------------------- + + // repeated .PbFaceList.FaceListImage images = 5; + int images_size() const; + void clear_images(); + static const int kImagesFieldNumber = 5; + const ::PbFaceList_FaceListImage& images(int index) const; + ::PbFaceList_FaceListImage* mutable_images(int index); + ::PbFaceList_FaceListImage* add_images(); + ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >* + mutable_images(); + const ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >& + images() const; + + // required uint32 image_count = 2; + bool has_image_count() const; + void clear_image_count(); + static const int kImageCountFieldNumber = 2; + ::google::protobuf::uint32 image_count() const; + void set_image_count(::google::protobuf::uint32 value); + + // optional uint32 src_width = 3; + bool has_src_width() const; + void clear_src_width(); + static const int kSrcWidthFieldNumber = 3; + ::google::protobuf::uint32 src_width() const; + void set_src_width(::google::protobuf::uint32 value); + + // optional uint32 src_height = 4; + bool has_src_height() const; + void clear_src_height(); + static const int kSrcHeightFieldNumber = 4; + ::google::protobuf::uint32 src_height() const; + void set_src_height(::google::protobuf::uint32 value); + + // required uint32 magic = 1 [default = 11706629]; + bool has_magic() const; + void clear_magic(); + static const int kMagicFieldNumber = 1; + ::google::protobuf::uint32 magic() const; + void set_magic(::google::protobuf::uint32 value); + + // @@protoc_insertion_point(class_scope:PbFaceList) + private: + void set_has_magic(); + void clear_has_magic(); + void set_has_image_count(); + void clear_has_image_count(); + void set_has_src_width(); + void clear_has_src_width(); + void set_has_src_height(); + void clear_has_src_height(); + + // helper for ByteSizeLong() + size_t RequiredFieldsByteSizeFallback() const; + + ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; + ::google::protobuf::internal::HasBits<1> _has_bits_; + mutable int _cached_size_; + ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage > images_; + ::google::protobuf::uint32 image_count_; + ::google::protobuf::uint32 src_width_; + ::google::protobuf::uint32 src_height_; + ::google::protobuf::uint32 magic_; + friend struct protobuf_PbFaceList::TableStruct; +}; +// =================================================================== + + +// =================================================================== + +#if !PROTOBUF_INLINE_NOT_IN_HEADERS +// PbFaceList_FaceListImage + +// required uint32 idx = 1; +inline bool PbFaceList_FaceListImage::has_idx() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_idx() { + _has_bits_[0] |= 0x00000001u; +} +inline void PbFaceList_FaceListImage::clear_has_idx() { + _has_bits_[0] &= ~0x00000001u; +} +inline void PbFaceList_FaceListImage::clear_idx() { + idx_ = 0u; + clear_has_idx(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::idx() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.idx) + return idx_; +} +inline void PbFaceList_FaceListImage::set_idx(::google::protobuf::uint32 value) { + set_has_idx(); + idx_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.idx) +} + +// required uint32 size = 2; +inline bool PbFaceList_FaceListImage::has_size() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_size() { + _has_bits_[0] |= 0x00000002u; +} +inline void PbFaceList_FaceListImage::clear_has_size() { + _has_bits_[0] &= ~0x00000002u; +} +inline void PbFaceList_FaceListImage::clear_size() { + size_ = 0u; + clear_has_size(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::size() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.size) + return size_; +} +inline void PbFaceList_FaceListImage::set_size(::google::protobuf::uint32 value) { + set_has_size(); + size_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.size) +} + +// required .PbFaceList.FaceListImage.ImageType type = 3 [default = MBFT_Y8]; +inline bool PbFaceList_FaceListImage::has_type() const { + return (_has_bits_[0] & 0x00000040u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_type() { + _has_bits_[0] |= 0x00000040u; +} +inline void PbFaceList_FaceListImage::clear_has_type() { + _has_bits_[0] &= ~0x00000040u; +} +inline void PbFaceList_FaceListImage::clear_type() { + type_ = 9; + clear_has_type(); +} +inline ::PbFaceList_FaceListImage_ImageType PbFaceList_FaceListImage::type() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.type) + return static_cast< ::PbFaceList_FaceListImage_ImageType >(type_); +} +inline void PbFaceList_FaceListImage::set_type(::PbFaceList_FaceListImage_ImageType value) { + assert(::PbFaceList_FaceListImage_ImageType_IsValid(value)); + set_has_type(); + type_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.type) +} + +// required uint32 width = 4; +inline bool PbFaceList_FaceListImage::has_width() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_width() { + _has_bits_[0] |= 0x00000004u; +} +inline void PbFaceList_FaceListImage::clear_has_width() { + _has_bits_[0] &= ~0x00000004u; +} +inline void PbFaceList_FaceListImage::clear_width() { + width_ = 0u; + clear_has_width(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::width() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.width) + return width_; +} +inline void PbFaceList_FaceListImage::set_width(::google::protobuf::uint32 value) { + set_has_width(); + width_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.width) +} + +// required uint32 height = 5; +inline bool PbFaceList_FaceListImage::has_height() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_height() { + _has_bits_[0] |= 0x00000008u; +} +inline void PbFaceList_FaceListImage::clear_has_height() { + _has_bits_[0] &= ~0x00000008u; +} +inline void PbFaceList_FaceListImage::clear_height() { + height_ = 0u; + clear_has_height(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::height() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.height) + return height_; +} +inline void PbFaceList_FaceListImage::set_height(::google::protobuf::uint32 value) { + set_has_height(); + height_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.height) +} + +// optional uint32 top_left_x = 6; +inline bool PbFaceList_FaceListImage::has_top_left_x() const { + return (_has_bits_[0] & 0x00000010u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_top_left_x() { + _has_bits_[0] |= 0x00000010u; +} +inline void PbFaceList_FaceListImage::clear_has_top_left_x() { + _has_bits_[0] &= ~0x00000010u; +} +inline void PbFaceList_FaceListImage::clear_top_left_x() { + top_left_x_ = 0u; + clear_has_top_left_x(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::top_left_x() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.top_left_x) + return top_left_x_; +} +inline void PbFaceList_FaceListImage::set_top_left_x(::google::protobuf::uint32 value) { + set_has_top_left_x(); + top_left_x_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_x) +} + +// optional uint32 top_left_y = 7; +inline bool PbFaceList_FaceListImage::has_top_left_y() const { + return (_has_bits_[0] & 0x00000020u) != 0; +} +inline void PbFaceList_FaceListImage::set_has_top_left_y() { + _has_bits_[0] |= 0x00000020u; +} +inline void PbFaceList_FaceListImage::clear_has_top_left_y() { + _has_bits_[0] &= ~0x00000020u; +} +inline void PbFaceList_FaceListImage::clear_top_left_y() { + top_left_y_ = 0u; + clear_has_top_left_y(); +} +inline ::google::protobuf::uint32 PbFaceList_FaceListImage::top_left_y() const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.top_left_y) + return top_left_y_; +} +inline void PbFaceList_FaceListImage::set_top_left_y(::google::protobuf::uint32 value) { + set_has_top_left_y(); + top_left_y_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.top_left_y) +} + +// repeated bytes img = 8; +inline int PbFaceList_FaceListImage::img_size() const { + return img_.size(); +} +inline void PbFaceList_FaceListImage::clear_img() { + img_.Clear(); +} +inline const ::std::string& PbFaceList_FaceListImage::img(int index) const { + // @@protoc_insertion_point(field_get:PbFaceList.FaceListImage.img) + return img_.Get(index); +} +inline ::std::string* PbFaceList_FaceListImage::mutable_img(int index) { + // @@protoc_insertion_point(field_mutable:PbFaceList.FaceListImage.img) + return img_.Mutable(index); +} +inline void PbFaceList_FaceListImage::set_img(int index, const ::std::string& value) { + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.img) + img_.Mutable(index)->assign(value); +} +#if LANG_CXX11 +inline void PbFaceList_FaceListImage::set_img(int index, ::std::string&& value) { + // @@protoc_insertion_point(field_set:PbFaceList.FaceListImage.img) + img_.Mutable(index)->assign(std::move(value)); +} +#endif +inline void PbFaceList_FaceListImage::set_img(int index, const char* value) { + img_.Mutable(index)->assign(value); + // @@protoc_insertion_point(field_set_char:PbFaceList.FaceListImage.img) +} +inline void PbFaceList_FaceListImage::set_img(int index, const void* value, size_t size) { + img_.Mutable(index)->assign( + reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_set_pointer:PbFaceList.FaceListImage.img) +} +inline ::std::string* PbFaceList_FaceListImage::add_img() { + // @@protoc_insertion_point(field_add_mutable:PbFaceList.FaceListImage.img) + return img_.Add(); +} +inline void PbFaceList_FaceListImage::add_img(const ::std::string& value) { + img_.Add()->assign(value); + // @@protoc_insertion_point(field_add:PbFaceList.FaceListImage.img) +} +#if LANG_CXX11 +inline void PbFaceList_FaceListImage::add_img(::std::string&& value) { + img_.Add()->assign(std::move(value)); + // @@protoc_insertion_point(field_add:PbFaceList.FaceListImage.img) +} +#endif +inline void PbFaceList_FaceListImage::add_img(const char* value) { + img_.Add()->assign(value); + // @@protoc_insertion_point(field_add_char:PbFaceList.FaceListImage.img) +} +inline void PbFaceList_FaceListImage::add_img(const void* value, size_t size) { + img_.Add()->assign(reinterpret_cast<const char*>(value), size); + // @@protoc_insertion_point(field_add_pointer:PbFaceList.FaceListImage.img) +} +inline const ::google::protobuf::RepeatedPtrField< ::std::string>& +PbFaceList_FaceListImage::img() const { + // @@protoc_insertion_point(field_list:PbFaceList.FaceListImage.img) + return img_; +} +inline ::google::protobuf::RepeatedPtrField< ::std::string>* +PbFaceList_FaceListImage::mutable_img() { + // @@protoc_insertion_point(field_mutable_list:PbFaceList.FaceListImage.img) + return &img_; +} + +// ------------------------------------------------------------------- + +// PbFaceList + +// required uint32 magic = 1 [default = 11706629]; +inline bool PbFaceList::has_magic() const { + return (_has_bits_[0] & 0x00000008u) != 0; +} +inline void PbFaceList::set_has_magic() { + _has_bits_[0] |= 0x00000008u; +} +inline void PbFaceList::clear_has_magic() { + _has_bits_[0] &= ~0x00000008u; +} +inline void PbFaceList::clear_magic() { + magic_ = 11706629u; + clear_has_magic(); +} +inline ::google::protobuf::uint32 PbFaceList::magic() const { + // @@protoc_insertion_point(field_get:PbFaceList.magic) + return magic_; +} +inline void PbFaceList::set_magic(::google::protobuf::uint32 value) { + set_has_magic(); + magic_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.magic) +} + +// required uint32 image_count = 2; +inline bool PbFaceList::has_image_count() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void PbFaceList::set_has_image_count() { + _has_bits_[0] |= 0x00000001u; +} +inline void PbFaceList::clear_has_image_count() { + _has_bits_[0] &= ~0x00000001u; +} +inline void PbFaceList::clear_image_count() { + image_count_ = 0u; + clear_has_image_count(); +} +inline ::google::protobuf::uint32 PbFaceList::image_count() const { + // @@protoc_insertion_point(field_get:PbFaceList.image_count) + return image_count_; +} +inline void PbFaceList::set_image_count(::google::protobuf::uint32 value) { + set_has_image_count(); + image_count_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.image_count) +} + +// optional uint32 src_width = 3; +inline bool PbFaceList::has_src_width() const { + return (_has_bits_[0] & 0x00000002u) != 0; +} +inline void PbFaceList::set_has_src_width() { + _has_bits_[0] |= 0x00000002u; +} +inline void PbFaceList::clear_has_src_width() { + _has_bits_[0] &= ~0x00000002u; +} +inline void PbFaceList::clear_src_width() { + src_width_ = 0u; + clear_has_src_width(); +} +inline ::google::protobuf::uint32 PbFaceList::src_width() const { + // @@protoc_insertion_point(field_get:PbFaceList.src_width) + return src_width_; +} +inline void PbFaceList::set_src_width(::google::protobuf::uint32 value) { + set_has_src_width(); + src_width_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.src_width) +} + +// optional uint32 src_height = 4; +inline bool PbFaceList::has_src_height() const { + return (_has_bits_[0] & 0x00000004u) != 0; +} +inline void PbFaceList::set_has_src_height() { + _has_bits_[0] |= 0x00000004u; +} +inline void PbFaceList::clear_has_src_height() { + _has_bits_[0] &= ~0x00000004u; +} +inline void PbFaceList::clear_src_height() { + src_height_ = 0u; + clear_has_src_height(); +} +inline ::google::protobuf::uint32 PbFaceList::src_height() const { + // @@protoc_insertion_point(field_get:PbFaceList.src_height) + return src_height_; +} +inline void PbFaceList::set_src_height(::google::protobuf::uint32 value) { + set_has_src_height(); + src_height_ = value; + // @@protoc_insertion_point(field_set:PbFaceList.src_height) +} + +// repeated .PbFaceList.FaceListImage images = 5; +inline int PbFaceList::images_size() const { + return images_.size(); +} +inline void PbFaceList::clear_images() { + images_.Clear(); +} +inline const ::PbFaceList_FaceListImage& PbFaceList::images(int index) const { + // @@protoc_insertion_point(field_get:PbFaceList.images) + return images_.Get(index); +} +inline ::PbFaceList_FaceListImage* PbFaceList::mutable_images(int index) { + // @@protoc_insertion_point(field_mutable:PbFaceList.images) + return images_.Mutable(index); +} +inline ::PbFaceList_FaceListImage* PbFaceList::add_images() { + // @@protoc_insertion_point(field_add:PbFaceList.images) + return images_.Add(); +} +inline ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >* +PbFaceList::mutable_images() { + // @@protoc_insertion_point(field_mutable_list:PbFaceList.images) + return &images_; +} +inline const ::google::protobuf::RepeatedPtrField< ::PbFaceList_FaceListImage >& +PbFaceList::images() const { + // @@protoc_insertion_point(field_list:PbFaceList.images) + return images_; +} + +#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + + +#ifndef SWIG +namespace google { +namespace protobuf { + +template <> struct is_proto_enum< ::PbFaceList_FaceListImage_ImageType> : ::google::protobuf::internal::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::PbFaceList_FaceListImage_ImageType>() { + return ::PbFaceList_FaceListImage_ImageType_descriptor(); +} + +} // namespace protobuf +} // namespace google +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_PbFaceList__INCLUDED diff --git a/FaceServer/STFaceCache.cpp b/FaceServer/STFaceCache.cpp index 6190f82..405fd71 100644 --- a/FaceServer/STFaceCache.cpp +++ b/FaceServer/STFaceCache.cpp @@ -9,7 +9,11 @@ #include "sample_face_search.h" #include <cv_face.h> +#define FDP_FDR_INVALID FDP_FaceDetectResult(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 { @@ -36,13 +40,22 @@ { handles.handle_verify = ctx.handle_verify; handles.handle_detect = ctx.handle_detect; - dbLoadOK = stface_db_load(handles, db_full_path().c_str()); - dbLoadOK &= (handles.handle_db != nullptr); + if (handles.handle_db == nullptr) + { + dbLoadOK = stface_db_load(handles, db_full_path().c_str()); + dbLoadOK &= (handles.handle_db != nullptr); + } + else + { + dbLoadOK = true; + } return dbLoadOK; } void close_db() { + stface_db_save(handles, db_full_path().c_str()); + handles.handle_verify = nullptr; handles.handle_detect = nullptr; cv_verify_destroy_db(handles.handle_db); @@ -85,10 +98,18 @@ { STFaceCacheContext& cacheContext(*(STFaceCacheContext*)_cacheContext); + if (stface_init_license("./license.lic") != 0) + { + LOG_ERROR << "stface_init_license failed" << LOG_ENDL; + return false; + } + + cv_face_algorithm_info(); + cv_result_t cv_result = cv_face_create_detector(&cacheContext.handle_detect, nullptr, CV_DETECT_ENABLE_ALIGN_21); if (cv_result != CV_OK) { - LOGP(ERROR, "create detect handle failed, error code %d\n", cv_result); + LOGP(ERROR, "create detect handle failed, error code %d", cv_result); return false; } @@ -169,9 +190,27 @@ } } +FDP_FaceDetectResult STFaceCache::detect_neg(const STFaceImage& img) +{ + if (img.db_id <= 0) + { + 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; +#endif +} + FDP_FaceDetectResult STFaceCache::detect(const STFaceImage& img) { stface_ctx_map_t& dbContext(*(stface_ctx_map_t*)_dbContext); + + LOG_WARN << "detect in dbid=" << img.db_id << LOG_ENDL; if (img.db_id == 0) { @@ -184,34 +223,41 @@ if (iterCtx == dbContext.end()) { LOG_WARN << "no db find dbid=" << img.db_id << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return detect_neg(img); } STFaceDBContext& ctx(iterCtx->second); if (!ctx.dbLoadOK) { LOG_WARN << "dbLoadOK return false" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return detect_neg(img); } top_idx_score_vect_t result; if (!stface_search_db(ctx.handles, img, result)) { LOG_WARN << "stface_search_db return false" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return detect_neg(img); } if (result.empty()) { LOG_INFO << "stface_search_db return empty" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return detect_neg(img); } LOGP(INFO, "stface_search_db return dbid=%d, idx=%d, score=%f", img.db_id, result[0].idx, result[0].score); + + if (result[0].score < RESULT_CONFIDENCE) + { + LOGP(INFO, "low score not accepted"); + return detect_neg(img); + } + return FDP_FaceDetectResult(img.db_id, result[0].idx); } - return FDP_FaceDetectResult(0, 0); + return FDP_FDR_INVALID; } FDP_FaceDetectResult STFaceCache::add(const STFaceImage& img) @@ -219,10 +265,12 @@ stface_ctx_map_t& dbContext(*(stface_ctx_map_t*)_dbContext); STFaceCacheContext& cacheContext(*(STFaceCacheContext*)_cacheContext); + LOG_WARN << "add in dbid=" << img.db_id << LOG_ENDL; + if (img.db_id == 0) { LOG_WARN << "db_id=0 not ok" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return FDP_FDR_INVALID; } stface_ctx_map_t::iterator iterCtx = dbContext.find(img.db_id); @@ -237,19 +285,16 @@ ctx.dbfname = dbfname; ctx.dbfpath = stfacedbPath; ctx.dbid = img.db_id; + ctx.init_db(cacheContext); // copy handlers if (!stface_db_create(ctx.handles, ctx.db_full_path().c_str())) { LOG_WARN << "stface_db_create return false" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return FDP_FDR_INVALID; } - if (!ctx.init_db(cacheContext)) - { - LOG_WARN << "ctx.init_db return false" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); - } - + ctx.dbLoadOK = true; + dbContext.insert(std::make_pair(ctx.dbid, ctx)); iterCtx = dbContext.find(img.db_id); } @@ -258,17 +303,20 @@ if (iterCtx == dbContext.end()) { LOG_ERROR << "no stfacedb found" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return FDP_FDR_INVALID; } STFaceDBContext& ctx(iterCtx->second); if (!ctx.dbLoadOK) { LOG_WARN << "dbLoadOK return false" << LOG_ENDL; - return FDP_FaceDetectResult(0, 0); + return FDP_FDR_INVALID; } int idx = stface_db_add(ctx.handles, img); LOG_INFO << "stface_db_add dbid=" << img.db_id << ", idx=" << idx << LOG_ENDL; - return FDP_FaceDetectResult(img.db_id, idx); + if (idx <= 1) + return FDP_FDR_INVALID; + else + return FDP_FaceDetectResult(img.db_id, idx); } diff --git a/FaceServer/STFaceCache.h b/FaceServer/STFaceCache.h index 3f234ac..e8e0680 100644 --- a/FaceServer/STFaceCache.h +++ b/FaceServer/STFaceCache.h @@ -24,6 +24,9 @@ // they can delete it and save/find again! private: + FDP_FaceDetectResult detect_neg(const STFaceImage& img); + +private: const std::string stfacedbPath; const std::string stfaceModels; void* _dbContext; diff --git a/FaceServer/bias.jpg b/FaceServer/bias.jpg new file mode 100644 index 0000000..da0ad0f --- /dev/null +++ b/FaceServer/bias.jpg Binary files differ diff --git a/FaceServer/license.lic b/FaceServer/license.lic new file mode 100644 index 0000000..f190bf7 --- /dev/null +++ b/FaceServer/license.lic @@ -0,0 +1,36 @@ +############################################################ +# SenseTime License +# License Product: FaceSdk +# Expiration: 20000101~20170525 +# License SN: 5e4b4993-6c25-4942-a5e5-3e4c818b807a +############################################################ +sGfdd5sxA8NCweDGA+vU2qzOgOjTn64wtsOftvbVw+MzmQXlL9gGE+JsM0nU +lOHN/Ai/mjyyPqGW4W5FxJgLnqgzp2g09JkRdjXGle8IEY8ag4wXH8LUT+XY +OXBBvilrGRazpr4ni1SVkpgxTHoX3GdBY09aLCaJ9uCj1p7uErIgjhC2AQAA +AAEAAAABJioS4yQz2pTIieigSTrt4ANVz5LRRa52XLWQvB2azvNdASaqkN2B +qMLx/Hy1Bq6TLqWxL0paF9Xj5t/xptpwmax0BxY+Dn4rsdJj4PnChey1B2Hx +OLlVDQUj+oZ3lgpzi1wdFp8RLKEDJVa5WRuiV8Po3o+JrDz5DvX+FJIKyrgF +5piZ69rc/zi0ohoz3VqCCr1OEUv4XSpDkK/g+1NkBHvco/EZe8wLoh0R7nQR +7yHAzGQRZMEBTaduWIATW1PeBQJxUjKGCv57aCB5jeGk0wg/60/4702f2Dth +RpZOeMvfbYedzag4SKaHN5rQ9jE+L0dCqREJvkfUVMYJ8wyvAQABAAAAAAAD +AAAAAAAAAAAAAAAdFrdcj38Pba/zw3OZ/zBgEZR1PVWeUBie2oiKNyH5oui3 +TgKfJH5wsLTGRPVm9S7pvOYfkLzS36uvuwvzZDyuWR2Z4LhnnZuPmaVqjKCs +8vqKNKoYMjqRuKlLc/y+lAk4U/2HGWDkWruVyV2pwqQhUEreQjDI3kFfwPtR +Ku7yaU4WpTKlQnuqI0Obs6/RqzM+XXs3TfxMOQAiBu+kWzaZTC19BtXMPFrN +fAjbMnQde9bo7miN0Suho+Y+NJZgyHmTyQ== +------------------------------------------------------------ +sGfdd6lFJ6Tqu92vBLdmba43DDEo8urBsQZgtiw9f+FdDXiYmMiLivrnakFi +LYVW+wr/LB8OKhHC5LHMAwb5IwcPlxzccHHRhz9MKOBoj089cX8HQnXxa954 +rjT+aIQTbB9iXnWI7/YKAQ3hJP5npQOfOC8r42a16kJEHAbyzUWDARM+AQAA +AAEAAAAkearNEl4QZVrQXPX7VQzz5BkSzBTxt+aIE4aXNPXRD3nUgQBUzPFk +3nmQxDRg9OuKmnKQ7jZHjEfDg/JaBeyrX/mzQWqntxnKN0vQhSglI2YpBXHt +paXkknm1UxA3kvOQWkCohszZZaDwwvPqjw8vXbqshKDF7ABD2zqp+pb1nOh3 +6gpIO6VQdDm/XPDb4uCwqiiupY0tAR/2wgMvKEzDl+3GDI/bTgnc6AixLDqr +B9s4zScgWD1uRxEVdouTvOsjmKpphZLOFjrqDBjoC0wipnVYdxs2n3XBINyb +nWHfQazOhTrxyDS5b4nKZ/ArFgU+IQMSSvfScUYNp+d4NXxBAQABAAAAAAAD +AAAAAAAAAAAAAACI3FN6Tjqab7g46ixAJmcB4wXakeYo02ApwEuuClavJUBc +y5k9pj0BlerX2nVWBvgJFarsp4Ch+IaJVx1B1xmbQ7W0UHm1Uc1RhdEkFlqu +pgCJNyJCcu68f5+tC474kw5T7KPCS2hmBh6u7Q7bICrsZ1NXXIJJCb4/UGWk +DLhEsPXKQTl40lBGUY7kFt24dRYSRrPg2g3D2O8Q+kv2PnC7LuyeHYqNgS24 +tAgNqfTB/zfLogIBdwXBsAZAh/k/8pFmwA== +############################################################ \ No newline at end of file diff --git a/FaceServer/main_face_daemon.cpp b/FaceServer/main_face_daemon.cpp index 6cfc437..e4783ab 100644 --- a/FaceServer/main_face_daemon.cpp +++ b/FaceServer/main_face_daemon.cpp @@ -6,7 +6,7 @@ #include "face_daemon_proto.h" #include "sample_face_search.h" #include "STFaceCache.h" -#include <PbFaceList.pb.h> +#include "PbFaceList.pb.h" #include <signal.h> @@ -42,8 +42,8 @@ ss << "}"; std::string output(ss.str());//#todo avoid copy - client.sendBuffSize = output.size() + 1; - client.sendBuff = new uint8_t[client.sendBuffSize]; + client.sendBuffSize = output.size(); + client.sendBuff = new uint8_t[output.size() + 1]; strcpy((char*)client.sendBuff, output.c_str()); client.deleteSendBuff = true; @@ -61,6 +61,7 @@ EVPHeader* evpHeader = (EVPHeader*)client.recvBuff; FDP_FaceDetectPB* fdpFaceDetectPB = (FDP_FaceDetectPB*)(client.recvBuff + sizeof(EVPHeader)); + fdpFaceDetectPB->ntoh(); PbFaceList pbFaceList; pbFaceList.ParseFromArray(client.recvBuff + sizeof(EVPHeader) + sizeof(FDP_FaceDetectPB), evpHeader->size - sizeof(EVPHeader) - sizeof(FDP_FaceDetectPB)); @@ -120,13 +121,13 @@ 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; + //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); diff --git a/FaceServer/make.sh b/FaceServer/make.sh index b0d607e..670e598 100644 --- a/FaceServer/make.sh +++ b/FaceServer/make.sh @@ -2,24 +2,26 @@ PIPELINE_BASE=/opt/RtspFace -VISITFACE_BASE=/opt/VisitFace/RtspNativeCodec/app/src/main/cpp - PROTOBUF_BASE=/opt/protobuf/inst PROTOBUF_INC="-I$PROTOBUF_BASE/include" PROTOBUF_LIB="-L$PROTOBUF_BASE/lib -lprotobuf" -STFACESDK_BASE=/opt/st_face-6.3.1-verify_p1-linux-524d0c3 +STFACESDK_BASE=/opt/st_face STFACESDK_INC="-I$STFACESDK_BASE/include" -STFACESDK_LIB="-L$STFACESDK_BASE/libs/linux-x86_64" +STFACESDK_LIB="-L$STFACESDK_BASE/libs/linux-x86_64/lib_dummy -lcvface_api" LIBYUV_BASE=/opt/libyuv/inst LIBYUV_INC="-I$LIBYUV_BASE/include" LIBYUV_LIB="-L$LIBYUV_BASE/lib -lyuv" -OPENCV_LIB=`pkg-config --libs-only-l opencv` +OPENCV_BASE=/opt/opencv/inst +OPENCV_INC="-I$OPENCV_BASE/include" +OPENCV_LIB="$OPENCV_BASE/lib" +OPENCV_LIB=`PKG_CONFIG_PATH=$OPENCV_LIB/pkgconfig pkg-config --libs-only-l opencv` +OPENCV_LIB="-L$OPENCV_BASE/lib $OPENCV_LIB" -CPPFLAGS+="-g -c -std=c++11 -pthread -DSERVER_PORT=15432 -DSTFACESDK_BASE=\"$STFACESDK_BASE\" -I$PIPELINE_BASE -I$VISITFACE_BASE $PROTOBUF_INC $STFACESDK_INC $LIBYUV_INC " -LDFLAGS+="-pthread -levent $PROTOBUF_LIB $STFACESDK_LIB $OPENCV_LIB $LIBYUV_LIB " # -lcvface_api +CPPFLAGS+="-g -c -std=c++11 -pthread -DSERVER_PORT=15432 -DSTFACESDK_BASE=\"$STFACESDK_BASE\" -I$PIPELINE_BASE $PROTOBUF_INC $STFACESDK_INC $OPENCV_INC $LIBYUV_INC " +LDFLAGS+="-pthread -levent $PROTOBUF_LIB $STFACESDK_LIB $OPENCV_LIB $LIBYUV_LIB " rm *.o rm face_server test_client_detect test_client_add @@ -27,10 +29,10 @@ 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++ PbFaceList.pb.cc $CFLAGS $CPPFLAGS g++ main_face_daemon.cpp $CFLAGS $CPPFLAGS g++ sample_face_search.cpp $CFLAGS $CPPFLAGS -g++ pseudo_stfacesdk.cpp $CFLAGS $CPPFLAGS +#g++ pseudo_stfacesdk.cpp $CFLAGS $CPPFLAGS g++ STFaceCache.cpp $CFLAGS $CPPFLAGS g++ test_client_detect.cpp $CFLAGS $CPPFLAGS @@ -43,7 +45,6 @@ PbFaceList.pb.o \ main_face_daemon.o \ sample_face_search.o \ - pseudo_stfacesdk.o \ STFaceCache.o \ $LDFLAGS -o face_server # @@ -58,4 +59,4 @@ $LDFLAGS -o test_client_add # -#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/protobuf/inst/lib:/opt/st_face-6.3.1-verify_p1-linux-524d0c3/libs/linux-x86_64 +#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/protobuf/inst/lib:/opt/opencv/inst/lib:/opt/st_face/libs/linux-x86_64 diff --git a/FaceServer/sample_face_search.cpp b/FaceServer/sample_face_search.cpp index 8889cac..69f2c54 100644 --- a/FaceServer/sample_face_search.cpp +++ b/FaceServer/sample_face_search.cpp @@ -1,14 +1,15 @@ #include "sample_face_search.h" +#include <cv_face.h> #include <MaterialBuffer.h> #include "STFaceCache.h" #include <logger.h> #include <vector> #include <stdio.h> -#include <cv_face.h> #include <opencv2/opencv.hpp> #include <libyuv/convert.h> +#include <libyuv/convert_from_argb.h> #define SUBSAMPLE(v, a) ((((v) + (a) - 1)) / (a)) #define MAX_FACE_IMAGE_WIDTH 640 @@ -42,7 +43,7 @@ bgr_image.cols, bgr_image.rows, bgr_image.step, p_face, &p_feature, nullptr); if (st_result != CV_OK) { - LOGP(DEBUG, "cv_verify_get_feature failed, error code %d\n", st_result); + LOGP(DEBUG, "cv_verify_get_feature failed, error code %d", st_result); } } else { LOGP(DEBUG, "can't find face in %s", image_path); @@ -55,6 +56,7 @@ cv_feature_t *stface_extract_feature(stface_handles& handles, const STFaceImage& image) { cv_pixel_format stimgfmt = CV_PIX_FMT_GRAY8; + int matType = 0; if (image.width > MAX_FACE_IMAGE_WIDTH || image.height > MAX_FACE_IMAGE_HEIGHT) { @@ -64,28 +66,83 @@ uint8_t imgbuf[MAX_FACE_IMAGE_WIDTH * MAX_FACE_IMAGE_HEIGHT * 4]; size_t imgbufSize = 0; - if (image.mb_type == MB_Frame::MBFT_RGB565) + + if (image.mb_type == MB_Frame::MBFT_Y8) { + memcpy(imgbuf, image.buff, image.size);//#todo avoid mem cpy + + imgbufSize = image.height * image.width; + stimgfmt = CV_PIX_FMT_GRAY8; + matType = CV_8UC1; + } + else if (image.mb_type == MB_Frame::MBFT_RGB565) + { + //#todo libyuv can not deal no-normal-size image uint8* dst_y = (uint8*)(imgbuf); uint8* dst_u = (uint8*)(dst_y + (image.height * image.width)); uint8* dst_v = (uint8*)(dst_u + (image.height * image.width / 4)); int ret = libyuv::RGB565ToI420( - image.buff, image.width, + image.buff, image.width * 2,//#todo test dst_y, image.width, dst_u, SUBSAMPLE(image.width, 2), dst_v, SUBSAMPLE(image.width, 2), image.width, image.height - ); - imgbufSize = image.height * image.width * 1.5; + ); + + imgbufSize = image.height * image.width; + stimgfmt = CV_PIX_FMT_GRAY8; + matType = CV_8UC1; + } + else if (image.mb_type == MB_Frame::MBFT_ARGB8888) + { + //int ret = libyuv::ARGBToBGRA( + // image.buff, image.width * 4, + // imgbuf, image.width * 4, + // image.width, image.height + // ); + // + ////memcpy(imgbuf, image.buff, image.size); + // + //imgbufSize = image.height * image.width * 4; + //stimgfmt = CV_PIX_FMT_BGRA8888; + //matType = CV_8UC4; + + int ret = libyuv::ARGBToI400( + image.buff, image.width * 4, + imgbuf, image.width, + image.width, image.height + ); + + //memcpy(imgbuf, image.buff, image.size); + + imgbufSize = image.height * image.width; + stimgfmt = CV_PIX_FMT_GRAY8; + matType = CV_8UC1; } else { LOG_WARN << "mb frame type not support" << LOG_ENDL; return nullptr; } + + //{ + // static int f = 0; + // ++f; + // + // char fname[50]; + // sprintf(fname, "st-%d.rgb", f); + // FILE *pFile = fopen(fname, "wb"); + // fwrite(image.buff, 1, image.size, pFile); + // fclose(pFile); + // + // sprintf(fname, "st-%d.yuv", f); + // pFile = fopen(fname, "wb"); + // fwrite(imgbuf, 1, imgbufSize, pFile); + // fclose(pFile); + //} - Mat matImg(cv::Size(image.width, image.height), CV_8UC1, imgbuf); + Mat matImg(cv::Size(image.width, image.height), matType, imgbuf); if (!matImg.data) { return nullptr; @@ -101,13 +158,14 @@ st_result = cv_verify_get_feature(handles.handle_verify, (unsigned char *)matImg.data, stimgfmt, matImg.cols, matImg.rows, matImg.step, p_face, &p_feature, nullptr); if (st_result != CV_OK) { - LOGP(DEBUG, "cv_verify_get_feature failed, error code %d\n", st_result); + LOGP(DEBUG, "cv_verify_get_feature failed, error code %d", st_result); } } else { - LOGP(DEBUG, "can't find face in"); + LOGP(DEBUG, "can't find face in STFaceImage"); } + // release the memory of face cv_face_release_detector_result(p_face, face_count); return p_feature; @@ -121,7 +179,7 @@ int idx; cv_result_t cv_result = cv_verify_add_face(handles.handle_db, p_feature, &idx); if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_add_face failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_add_face failed, error code %d", cv_result); } cv_verify_release_feature(p_feature); return idx; @@ -138,7 +196,7 @@ cv_result_t cv_result = cv_verify_add_face(handles.handle_db, p_feature, &idx); if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_add_face failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_add_face failed, error code %d", cv_result); } cv_verify_release_feature(p_feature); return idx; @@ -146,16 +204,16 @@ bool stface_db_del(stface_handles& handles, int idx) { if (idx < 0) { - LOGP(DEBUG, "invalid idx!\n"); + LOGP(DEBUG, "invalid idx!"); return false; } cv_result_t cv_result = CV_OK; cv_result = cv_verify_delete_face(handles.handle_db, idx); if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_delete_face failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_delete_face failed, error code %d", cv_result); } else { - LOGP(DEBUG, "delete succeed\n"); + LOGP(DEBUG, "delete succeed"); } } @@ -163,11 +221,11 @@ cv_result_t cv_result = CV_OK; cv_result = cv_verify_save_db(handles.handle_db, db_path); if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_save_db failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_save_db failed, error code %d", cv_result); return false; } else { - LOGP(DEBUG, "save done!\n"); + LOGP(DEBUG, "save done!"); } return true; @@ -175,13 +233,26 @@ bool stface_db_load(stface_handles& handles, const char *db_path) { cv_result_t cv_result = CV_OK; + + if (handles.handle_db == nullptr) + { + cv_result = cv_verify_create_db(&handles.handle_db); + if (cv_result != CV_OK) + { + LOGP(DEBUG, "cv_verify_create_db failed, error code %d", cv_result); + return false; + } + } + cv_result = cv_verify_load_db(handles.handle_db, db_path); - if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_load_db failed, error code %d\n", cv_result); + if (cv_result != CV_OK) + { + LOGP(DEBUG, "cv_verify_load_db failed, error code %d", cv_result); return false; } - else { - LOGP(DEBUG, "load done!\n"); + else + { + LOGP(DEBUG, "load done!"); } return true; @@ -189,13 +260,22 @@ bool stface_db_create(stface_handles& handles, const char *db_path) { - cv_result_t cv_result = cv_verify_create_db(&handles.handle_db); - if (cv_result != CV_OK) + cv_result_t cv_result = CV_OK; + + if (handles.handle_db == nullptr) { - LOG_WARN << "cv_verify_create_db return false" << LOG_ENDL; - return false; + cv_result = cv_verify_create_db(&handles.handle_db); + if (cv_result != CV_OK) + { + LOGP(DEBUG, "cv_verify_create_db failed, error code %d", cv_result); + return false; + } } - + + // add a bias image so that stfacesdk can save db + int idx = stface_db_add(handles, "./bias.jpg"); + cout << "idx = " << idx << endl; + cv_result = cv_verify_save_db(handles.handle_db, db_path); if (cv_result != CV_OK) { @@ -210,7 +290,7 @@ bool bresult = true; FILE *fp_path = fopen(image_list, "r"); if(!fp_path) { - LOGP(DEBUG, "failed to load %s\n", image_list); + LOGP(DEBUG, "failed to load %s", image_list); return false; } std::vector<cv_feature_t *> list_feature; @@ -222,12 +302,12 @@ bresult = false; break; } - LOGP(DEBUG, "extracting %s\n", image_path); + LOGP(DEBUG, "extracting %s", image_path); // get the face feature cv_feature_t *p_feature = stface_extract_feature(handles, image_path); if (!p_feature) { - LOGP(DEBUG, "failed to extract image: %s\n", image_path); + LOGP(DEBUG, "failed to extract image: %s", image_path); continue; } list_feature.push_back(p_feature); @@ -238,7 +318,7 @@ cv_verify_create_db(&handles.handle_db); cv_result = cv_verify_build_db(handles.handle_db, &list_feature[0], list_feature.size()); if (cv_result != CV_OK) { - LOGP(DEBUG, "cv_verify_build_db failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_build_db failed, error code %d", cv_result); bresult = false; } cv_verify_save_db(handles.handle_db, output_db_path); @@ -253,14 +333,14 @@ bool stface_search_db(stface_handles& handles, char *image_path) { FILE *fp_path = fopen(image_path, "r"); if (fp_path == nullptr) { - LOGP(DEBUG, "invalid path !\n"); + LOGP(DEBUG, "invalid path !"); return false; } fclose(fp_path); cv_feature_t *p_feature = stface_extract_feature(handles, image_path); if (p_feature == nullptr) { - LOGP(DEBUG, "extract failed !\n"); + LOGP(DEBUG, "extract failed !"); return false; } @@ -274,12 +354,11 @@ if (cv_result == CV_OK) { for (unsigned int t = 0; t < result_length; t++) { // const cv_feature_t item = result[t].item; - LOGP(DEBUG, "%d\t", top_idxs[t]); - LOGP(DEBUG, "%0.2f\n", top_scores[t]); + LOGP(DEBUG, "%d\t%0.2f", top_idxs[t], top_scores[t]); } } else { - LOGP(DEBUG, "cv_verify_search_face failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_search_face failed, error code %d", cv_result); } if (top_idxs) { delete[]top_idxs; @@ -297,7 +376,7 @@ cv_feature_t *p_feature = stface_extract_feature(handles, image); if (p_feature == nullptr) { - LOGP(DEBUG, "extract failed !\n"); + LOGP(DEBUG, "extract failed !"); return false; } @@ -311,15 +390,14 @@ for (unsigned int t = 0; t < result_length; t++) { // const cv_feature_t item = result[t].item; - LOGP(DEBUG, "%d\t", top_idxs[t]); - LOGP(DEBUG, "%0.2f\n", top_scores[t]); + LOGP(DEBUG, "%d\t%0.2f", top_idxs[t], top_scores[t]); result.push_back(TopIdxScore(top_idxs[t], top_scores[t])); } } else { - LOGP(DEBUG, "cv_verify_search_face failed, error code %d\n", cv_result); + LOGP(DEBUG, "cv_verify_search_face failed, error code %d", cv_result); } if (top_idxs) { @@ -337,13 +415,13 @@ bool stface_search_list(stface_handles& handles, char *image_path, char *list_path) { cv_feature_t *p_feature = stface_extract_feature(handles, image_path); if (p_feature == nullptr) { - LOGP(DEBUG, "failed to extract image: %s\n", image_path); + LOGP(DEBUG, "failed to extract image: %s", image_path); return false; } FILE *fp_path = fopen(list_path, "r"); if(!fp_path) { - LOGP(DEBUG, "failed to load %s\n", list_path); + LOGP(DEBUG, "failed to load %s", list_path); return false; } std::vector<cv_feature_t *> list_feature; @@ -354,12 +432,12 @@ if (num != 1) { break; } - LOGP(DEBUG, "extracting %s\n", image_path); + LOGP(DEBUG, "extracting %s", image_path); // get the face feature cv_feature_t *p_feature = stface_extract_feature(handles, image_path); if (!p_feature) { - LOGP(DEBUG, "failed to extract image: %s\n", image_path); + LOGP(DEBUG, "failed to extract image: %s", image_path); continue; } list_feature.push_back(p_feature); @@ -378,8 +456,7 @@ if (cv_result == CV_OK) { for (unsigned int t = 0; t < result_length; t++) { - LOGP(DEBUG, "%d\t", top_idxs[t]); - LOGP(DEBUG, "%0.2f\n", top_scores[t]); + LOGP(DEBUG, "%d\t%0.2f", top_idxs[t], top_scores[t]); } } else { LOGP(DEBUG, "search face failed"); @@ -389,40 +466,40 @@ for (int i = 0; i < list_feature.size(); i++) { cv_verify_release_feature(list_feature[i]); } - LOGP(DEBUG, "list search done!\n"); + LOGP(DEBUG, "list search done!"); return true; } void stface_get_help() { - LOGP(DEBUG, "Usage: help | Get cmd list\n"); - LOGP(DEBUG, "Usage: search p_image_colorpath | Search image in db\n"); - LOGP(DEBUG, "Usage: add p_image_colorpath | Add image in db, return idx in db, if idx < 0 means failed\n"); - LOGP(DEBUG, "Usage: del idx | Delete image in db\n"); - LOGP(DEBUG, "Usage: save db_file | Save current db in db_file\n"); - LOGP(DEBUG, "Usage: load db_file | Load db in db_file\n"); - LOGP(DEBUG, "Usage: gen p_image_colorlist db_file | Gen images in p_image_colorlist and save in db_file\n"); - LOGP(DEBUG, "Usage: exit | Exit the program\n"); + LOGP(DEBUG, "Usage: help | Get cmd list"); + LOGP(DEBUG, "Usage: search p_image_colorpath | Search image in db"); + LOGP(DEBUG, "Usage: add p_image_colorpath | Add image in db, return idx in db, if idx < 0 means failed"); + LOGP(DEBUG, "Usage: del idx | Delete image in db"); + LOGP(DEBUG, "Usage: save db_file | Save current db in db_file"); + LOGP(DEBUG, "Usage: load db_file | Load db in db_file"); + LOGP(DEBUG, "Usage: gen p_image_colorlist db_file | Gen images in p_image_colorlist and save in db_file"); + LOGP(DEBUG, "Usage: exit | Exit the program"); } int stface_main(stface_handles& handles, int argc, char *argv[]) { cv_result_t cv_result = cv_face_create_detector(&handles.handle_detect, nullptr, CV_DETECT_ENABLE_ALIGN_21); if (cv_result != CV_OK){ - LOGP(DEBUG, "create detect handle failed, error code %d\n", cv_result); + LOGP(DEBUG, "create detect handle failed, error code %d", cv_result); } cv_result = cv_verify_create_handle(&handles.handle_verify, "../../../models/verify.model"); if (cv_result != CV_OK){ - LOGP(DEBUG, "create verify handle failed, error code %d\n", cv_result); + LOGP(DEBUG, "create verify handle failed, error code %d", cv_result); } cv_result = cv_verify_create_db(&handles.handle_db); if (cv_result != CV_OK){ - LOGP(DEBUG, "create db handle failed, error code %d\n", cv_result); + LOGP(DEBUG, "create db handle failed, error code %d", cv_result); } if (handles.handle_detect != nullptr && handles.handle_verify != nullptr && handles.handle_db != nullptr) { // stface_db_gen("list.txt","out.db"); - LOGP(DEBUG, "Database is empty at the beginning\n"); - LOGP(DEBUG, "Please input 'help' to get the cmd list\n"); + LOGP(DEBUG, "Database is empty at the beginning"); + LOGP(DEBUG, "Please input 'help' to get the cmd list"); char input_code[256]; char image_path[_MAX_PATH]; char db_path[_MAX_PATH]; @@ -431,7 +508,7 @@ while (1) { LOGP(DEBUG, ">>"); if (!fgets(input_code, 256, stdin)) { - LOGP(DEBUG, "read nothing\n"); + LOGP(DEBUG, "read nothing"); continue; } int input_length = strlen(input_code); @@ -448,7 +525,7 @@ else if (strcmp(str_input_code.substr(0, 3).c_str(), "add") == 0) { int input_number = sscanf(input_code, "%s%s", command, image_path); if (input_number != 2) { - LOGP(DEBUG, "invalid! Usage: add p_image_colorpath\n"); + LOGP(DEBUG, "invalid! Usage: add p_image_colorpath"); continue; } int idx = stface_db_add(handles, image_path); @@ -458,7 +535,7 @@ int idx = -1; int input_number = sscanf(input_code, "%s%d", image_path, &idx); if (input_number != 2) { - LOGP(DEBUG, "invalid! Usage: del idx(unsigned int\n"); + LOGP(DEBUG, "invalid! Usage: del idx(unsigned int"); continue; } stface_db_del(handles, idx); @@ -466,7 +543,7 @@ else if (strcmp(str_input_code.substr(0, 4).c_str(), "save") == 0) { int input_number = sscanf(input_code, "%s%s", command, image_path); if (input_number != 2) { - LOGP(DEBUG, "invalid! Usage: save db_file\n"); + LOGP(DEBUG, "invalid! Usage: save db_file"); continue; } stface_db_save(handles, image_path); @@ -474,7 +551,7 @@ else if (strcmp(str_input_code.substr(0, 4).c_str(), "load") == 0) { int input_number = sscanf(input_code, "%s%s", command, image_path); if (input_number != 2) { - LOGP(DEBUG, "invalid! Usage: load db_file\n"); + LOGP(DEBUG, "invalid! Usage: load db_file"); continue; } stface_db_load(handles, image_path); @@ -485,7 +562,7 @@ else if (strcmp(str_input_code.substr(0, 3).c_str(), "gen") == 0) { int input_number = sscanf(input_code, "%s%s%s", command, image_path, db_path); if (input_number != 3) { - LOGP(DEBUG, "invalid! Usage: gen p_image_colorlist_file db_file\n"); + LOGP(DEBUG, "invalid! Usage: gen p_image_colorlist_file db_file"); continue; } stface_db_gen(handles, image_path, db_path); @@ -493,7 +570,7 @@ else if (strcmp(str_input_code.substr(0, 6).c_str(), "search") == 0) { int input_number = sscanf(input_code, "%s%s", command, image_path); if (input_number != 2) { - LOGP(DEBUG, "invalid! Usage: search p_image_colorpath\n"); + LOGP(DEBUG, "invalid! Usage: search p_image_colorpath"); continue; } stface_search_db(handles, image_path); @@ -503,13 +580,13 @@ int input_number = sscanf(input_code, "%s%s%s", command, search_path, image_path); if (input_number != 3) { - LOGP(DEBUG, "invalid! Usage: listsearch p_image_colorsrcpath p_image_colorlistpath\n"); + LOGP(DEBUG, "invalid! Usage: listsearch p_image_colorsrcpath p_image_colorlistpath"); continue; } stface_search_list(handles, search_path, image_path); } else { - LOGP(DEBUG, "invalid cmd, please input 'help' to get the cmd list\n"); + LOGP(DEBUG, "invalid cmd, please input 'help' to get the cmd list"); } } } @@ -520,3 +597,15 @@ return 0; } +int stface_init_license(const char* lic_path) +{ + //鍔犺浇鎺堟潈璇佷功 + cv_result_t cv_result = cv_face_public_init_license(lic_path, "license"); + if(cv_result != CV_OK) + { + LOGP(ERROR, "cv_face_public_init_license error %d", cv_result); + return -1; + } + + return 0; +} diff --git a/FaceServer/sample_face_search.h b/FaceServer/sample_face_search.h index 89a9853..8d6075a 100644 --- a/FaceServer/sample_face_search.h +++ b/FaceServer/sample_face_search.h @@ -63,4 +63,6 @@ int stface_main(int argc, char *argv[]); +int stface_init_license(const char* lic_path); + #endif -- Gitblit v1.8.0