Image Class¶
This type is an EasyAR Sense API in C#: Image . Some descriptions may not apply to Unity environment on this page.
Some parts of the Sense API may have already been wrapped into Unity components, and directly usages may not be necessary.
Description¶
Image stores an image data and represents an image in memory.
Image raw data can be accessed as byte array. The width/height/etc information are also accessible.
You can always access image data since the first version of EasyAR Sense.
You can do this in iOS
#import <easyar/buffer.oc.h>
#import <easyar/image.oc.h>
easyar_OutputFrame * outputFrame = [outputFrameBuffer peek];
if (outputFrame != nil) {
easyar_Image * i = [[outputFrame inputFrame] image];
easyar_Buffer * b = [i buffer];
char * bytes = calloc([b size], 1);
memcpy(bytes, [b data], [b size]);
// use bytes here
free(bytes);
}
Or in Android
import cn.easyar.*;
OutputFrame outputFrame = outputFrameBuffer.peek();
if (outputFrame != null) {
InputFrame inputFrame = outputFrame.inputFrame();
Image i = inputFrame.image();
Buffer b = i.buffer();
byte[] bytes = new byte[b.size()];
b.copyToByteArray(0, bytes, 0, bytes.length);
// use bytes here
b.dispose();
i.dispose();
inputFrame.dispose();
outputFrame.dispose();
}
Methods¶
buffer¶
- C#
public virtual Buffer buffer()
Returns buffer inside image. It can be used to access internal data of image. The content of Buffer shall not be modified, as they may be accessed from other threads.
format¶
- C#
public virtual PixelFormat format()
Returns image format.
width¶
- C#
public virtual int width()
Returns image width. There is a padding of (pixelWidth - width) pixels at the right side of the image.
height¶
- C#
public virtual int height()
Returns image height. There is a padding of (pixelHeight - height) pixels at the bottom of the image.
pixelWidth¶
- C#
public virtual int pixelWidth()
Returns image pixel width for encoding.
pixelHeight¶
- C#
public virtual int pixelHeight()
Returns image pixel height for encoding.