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

Unable to manually manage Images #15

Closed
turowicz opened this issue Dec 13, 2018 · 5 comments
Closed

Unable to manually manage Images #15

turowicz opened this issue Dec 13, 2018 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@turowicz
Copy link

I get images from a webcam stream using OpenCV. I need to be able to load them up without using any disk files and use them in C#. So far I've been working with python and that feature is available there.

Unfortunately the constructor of Image is private in https://github.com/takuya-takeuchi/FaceRecognitionDotNet/blob/master/src/FaceRecognitionDotNet/Image.cs#L23

Ideally it would be nice to be able to create a Image from byte[]

@takuya-takeuchi
Copy link
Owner

You can use FaceRecognition.LoadImage.

@takuya-takeuchi takuya-takeuchi self-assigned this Dec 13, 2018
@takuya-takeuchi takuya-takeuchi added the question Further information is requested label Dec 13, 2018
@turowicz
Copy link
Author

@takuya-takeuchi I'm having trouble loading it from RGB

var frame = GetOpenCvMat();
var data = frame.ToBytes(".jpg",  new ImageEncodingParam(ImwriteFlags.JpegQuality, 90));
var image = FaceRecognition.LoadImage(data, frame.Height, frame.Width, 3);

The exception

Exception has occurred: CLR/System.ArgumentOutOfRangeException
Exception thrown: 'System.ArgumentOutOfRangeException' in DlibDotNet.dll: 'Specified argument was out of the range of valid values.'
   at DlibDotNet.Matrix`1..ctor(Byte[] array, Int32 row, Int32 column, Int32 elementSize)
   at FaceRecognitionDotNet.FaceRecognition.LoadImage(Byte[] array, Int32 row, Int32 column, Int32 elementSize) in /Users/wojtek/Workspace/facedotnet/src/FaceRecognitionDotNet/FaceRecognition.cs:line 374

@turowicz
Copy link
Author

also failing:

var image = FaceRecognition.LoadImage(frame.ToBytes(), frame.Rows, frame.Cols, 3);

@turowicz
Copy link
Author

also failing...

var data = frame.ToBytes(".bmp");
var image = FaceRecognition.LoadImage(data, frame.Rows, frame.Cols, 3);

Probably on this assertion

if (array.Length != row * column * elementSize)
    throw new ArgumentOutOfRangeException($"{nameof(array)}.Length should equalt to {nameof(column)}x{nameof(column)}*{nameof(elementSize)}.");

but the size is almost there:

data.Length
2239542

frame.Rows*frame.Cols*3
2239488

@turowicz
Copy link
Author

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

No branches or pull requests

2 participants