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

How to implement Face Recognition on Xamarin.Android #8

Open
Takanashi-T opened this issue May 16, 2018 · 1 comment
Open

How to implement Face Recognition on Xamarin.Android #8

Takanashi-T opened this issue May 16, 2018 · 1 comment

Comments

@Takanashi-T
Copy link

An error will occur if the following processing.
How should I implement it?

C#
Stream input = Resources.OpenRawResource(Resource.Raw.haarcascade_frontalface_default))
Java.IO.File dir = GetDir("cascade", FileCreationMode.Private);
Java.IO.File file = new Java.IO.File(dir, "haarcascade_frontalface_default.xml");

var output = new FileOutputStream(file);
byte[] buf = new byte[2048];
Output(output, buf);

input.Dispose();
output.Dispose();
string resource = file.AbsolutePath;

var cascade = new CascadeClassifier(resource);


@matstumpf
Copy link

I added libOpenCvSharpExtern.so in /lib/armeabi-v7a and set the "Build Action = AndroidNativeLibrary".
Also added "haarcascade_frontalface_default.xml" to Assets and set "Build Action = AndroidAsset"

Then in MainActivity:

 Mat ImageOne = Mat.FromImageData(GetBytesFromBitmap(img1), ImreadModes.GrayScale);
 Mat ImageTwo = Mat.FromImageData(GetBytesFromBitmap(img2), ImreadModes.GrayScale);

string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
 string filename = System.IO.Path.Combine(path, "haarcascade_frontalface_default.xml");

File.WriteAllText(filename, GetTextFromAsset("haarcascade_frontalface_default.xml"));

using (var imageOne = ImageOne)
using (var imageTwo = ImageTwo)
using (var model = FaceRecognizer.CreateEigenFaceRecognizer())

Here in last line

FaceRecognizer.CreateEigenFaceRecognizer()

It throw a exception because cant find the cv::face, that's because my extern.so was compiled without the face class implementation.

I'm trying now to have the complete .so (building from source), but always throw the exception:

1> undefined reference to 'cv::face::createEigenFaceRecognizer(int, double)'

Any clue?

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