fix shape_predictor dlib::searialize and dlib::desearialize error (#156)

* fix shape_predictor dlib::searialize and dlib::desearialize error

* declare shape_predictor searialize and desearialize inline

* fix inline declare issue: declare inline before implement
This commit is contained in:
vsooda 2016-07-12 21:46:06 +08:00 committed by Davis E. King
parent e3281851b5
commit 2849ebd70e

View File

@ -398,26 +398,9 @@ namespace dlib
return full_object_detection(rect, parts);
}
friend void serialize (const shape_predictor& item, std::ostream& out)
{
int version = 1;
dlib::serialize(version, out);
dlib::serialize(item.initial_shape, out);
dlib::serialize(item.forests, out);
dlib::serialize(item.anchor_idx, out);
dlib::serialize(item.deltas, out);
}
friend void deserialize (shape_predictor& item, std::istream& in)
{
int version = 0;
dlib::deserialize(version, in);
if (version != 1)
throw serialization_error("Unexpected version found while deserializing dlib::shape_predictor.");
dlib::deserialize(item.initial_shape, in);
dlib::deserialize(item.forests, in);
dlib::deserialize(item.anchor_idx, in);
dlib::deserialize(item.deltas, in);
}
friend void serialize (const shape_predictor& item, std::ostream& out);
friend void deserialize (shape_predictor& item, std::istream& in);
private:
matrix<float,0,1> initial_shape;
@ -426,6 +409,27 @@ namespace dlib
std::vector<std::vector<dlib::vector<float,2> > > deltas;
};
inline void serialize (const shape_predictor& item, std::ostream& out)
{
int version = 1;
dlib::serialize(version, out);
dlib::serialize(item.initial_shape, out);
dlib::serialize(item.forests, out);
dlib::serialize(item.anchor_idx, out);
dlib::serialize(item.deltas, out);
}
inline void deserialize (shape_predictor& item, std::istream& in)
{
int version = 0;
dlib::deserialize(version, in);
if (version != 1)
throw serialization_error("Unexpected version found while deserializing dlib::shape_predictor.");
dlib::deserialize(item.initial_shape, in);
dlib::deserialize(item.forests, in);
dlib::deserialize(item.anchor_idx, in);
dlib::deserialize(item.deltas, in);
}
// ----------------------------------------------------------------------------------------
class shape_predictor_trainer