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

Create Image<Bgr, Byte> in Xamarin #368

Closed
firedeepan opened this issue Sep 15, 2020 · 2 comments
Closed

Create Image<Bgr, Byte> in Xamarin #368

firedeepan opened this issue Sep 15, 2020 · 2 comments

Comments

@firedeepan
Copy link

I am trying to construct an Image<Bgr, Byte> instance from byte[].

var img = new Image<Bgr, Byte>(width, height);
img.Bytes = imageBytes;

But it doesn't create the correct EmguCV image representation. I tried the same using a stream as well as SKBit, but couldn't get it to work. However, it works perfectly when creating it from a file path as shown below.

var img = new Image<Bgr, Byte>(imgPath);

Appreciate your help with this.

@emgucv
Copy link
Owner

emgucv commented Sep 17, 2020

For the Bytes property, you need to pass the raw pixel data. In the above case, it need to be a byte array of 3 x width x height arranged in RGB format. Passing the Jpeg stream will not work.

If the imageBytes is JPEG stream instead of raw pixel data, you need to decode the jpeg data by calling:

Mat img= new Mat();
CvInvoke.Imdecode(jpegBytes, Emgu.CV.CvEnum.ImreadModes.Color, img)

@emgucv
Copy link
Owner

emgucv commented May 26, 2021

Closing ticket now.

@emgucv emgucv closed this as completed May 26, 2021
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