Merge pull request #1753 from alalek:fix_face_32bit

pull/1755/head^2
Alexander Alekhin 6 years ago
commit 3094b94850
  1. 2
      modules/face/src/face_alignmentimpl.hpp
  2. 7
      modules/face/src/getlandmarks.cpp
  3. 10
      modules/face/src/trainFacemark.cpp

@ -103,7 +103,7 @@ protected:
// This function randomly generates test splits to get the best split.
splitr getTestSplits(std::vector<Point2f> pixel_coordinates,int seed);
// This function writes a split node to the XML file storing the trained model
void writeSplit(std::ofstream& os,const splitr split);
void writeSplit(std::ofstream& os, const splitr& split);
// This function writes a leaf node to the binary file storing the trained model
void writeLeaf(std::ofstream& os, const std::vector<Point2f> &leaf);
// This function writes a tree to the binary file containing the model

@ -26,7 +26,12 @@ bool FacemarkKazemiImpl :: findNearestLandmarks( vector< vector<int> >& nearest)
}
void FacemarkKazemiImpl :: readSplit(ifstream& is, splitr &vec)
{
is.read((char*)&vec, sizeof(splitr));
is.read((char*)&vec.index1, sizeof(vec.index1));
is.read((char*)&vec.index2, sizeof(vec.index2));
is.read((char*)&vec.thresh, sizeof(vec.thresh));
uint32_t dummy_ = 0;
is.read((char*)&dummy_, sizeof(dummy_)); // buggy writer structure alignment
CV_CheckEQ((int)(sizeof(vec.index1) + sizeof(vec.index2) + sizeof(vec.thresh) + sizeof(dummy_)), 24, "Invalid build configuration");
}
void FacemarkKazemiImpl :: readLeaf(ifstream& is, vector<Point2f> &leaf)
{

@ -219,9 +219,15 @@ void FacemarkKazemiImpl :: writeLeaf(ofstream& os, const vector<Point2f> &leaf)
os.write((char*)&size, sizeof(size));
os.write((char*)&leaf[0], leaf.size() * sizeof(Point2f));
}
void FacemarkKazemiImpl :: writeSplit(ofstream& os, splitr split)
void FacemarkKazemiImpl :: writeSplit(ofstream& os, const splitr& vec)
{
os.write((char*)&split, sizeof(split));
os.write((char*)&vec.index1, sizeof(vec.index1));
os.write((char*)&vec.index2, sizeof(vec.index2));
os.write((char*)&vec.thresh, sizeof(vec.thresh));
uint32_t dummy_ = 0;
os.write((char*)&dummy_, sizeof(dummy_)); // buggy original writer structure alignment
CV_CheckEQ((int)(sizeof(vec.index1) + sizeof(vec.index2) + sizeof(vec.thresh) + sizeof(dummy_)), 24, "Invalid build configuration");
}
void FacemarkKazemiImpl :: writeTree(ofstream &f,regtree tree)
{

Loading…
Cancel
Save