Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for training code not working in Mac Os #11

Open
edgie-m opened this issue Nov 4, 2017 · 2 comments
Open

Solution for training code not working in Mac Os #11

edgie-m opened this issue Nov 4, 2017 · 2 comments

Comments

@edgie-m
Copy link

edgie-m commented Nov 4, 2017

Hi, I was able to run the code of alignment and training successfully on Mac Os.
The only issue regarding the training code (in my case at least) was in the MapShape function in utils_train.cpp file.
Just change the function MapShape to the following and the training will work (I had to cast the x and y values to int)

vectorcv::Point2d MapShape(cv::Rect original_face_rect,
const vectorcv::Point2d original_landmarks, cv::Rect new_face_rect)
{
vectorcv::Point2d result;
for (const cv::Point2d &landmark: original_landmarks)
{
result.push_back(landmark);
result.back() -= cv::Point2d(original_face_rect.x, original_face_rect.y);
result.back().x = result.back().x * (int)
((float)(new_face_rect.width) / original_face_rect.width);
result.back().y = result.back().y * (int)
((float)(new_face_rect.height) / original_face_rect.height);
result.back() += cv::Point2d(new_face_rect.x, new_face_rect.y);
}
return result;
}

@delphifirst
Copy link
Owner

Thanks for your information. Do you know why we need to add the cast here? Does the compiler give an error in the original code?

@edgie-m
Copy link
Author

edgie-m commented Nov 6, 2017

Hi, no the project as it is compile correctly on mac os (using my own CMakeLists.txt). However when I run it the code crushes in main_train.cpp -> TrainModel -> CreateTestInitShapes line -> in the CreateTestInitShapes function the line "cv::kmeans(all_landmarks ...." causes memory leak (malloc: *** error for object : pointer being freed was not allocated). I can't figure out why. I need maybe to dig more in the cv::kmeans source code. When casting to int the error disappears.
By the way I had the same issue when I run the training code on Android using JNI, it crushes at the same line with an error related to the memory. Do you have any ideas?
The model I trained after casting to int doesn't seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants