Image Class

Description

Image存储了图像数据,用来表示内存中的图像。

Image以字节数组的方式提供了对原始数据的访问,同时也提供了访问width/height等信息的接口。

在EasyAR Sense的所有版本中,你都可以访问图像数据。

在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);
}

在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();
}

Constructor

C

void easyar_Image__ctor(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, easyar_Image * * Return)

C++

Image(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height)

Java

public Image(@Nonnull Buffer buffer, int format, int width, int height)

Kotlin

constructor(buffer: Buffer, format: Int, width: Int, height: Int)

Objective-C

+ (easyar_Image *) create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height

Swift

public convenience init(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32)

C#

public Image(Buffer buffer, PixelFormat format, int width, int height)

buffer

返回图像中的数据buffer。可以使用 Buffer API访问内部数据。不应对获得的数据 Buffer 的内容进行修改,因为这些内容可能在其他线程被使用。

C

void easyar_Image_buffer(const easyar_Image * This, easyar_Buffer * * Return)

C++

std::shared_ptr<Buffer> buffer()

Java

public @Nonnull Buffer buffer()

Kotlin

fun buffer(): Buffer

Objective-C

- (easyar_Buffer *)buffer

Swift

public func buffer() -> Buffer

C#

public virtual Buffer buffer()

format

返回图像格式。

C

easyar_PixelFormat easyar_Image_format(const easyar_Image * This)

C++

PixelFormat format()

Java

public int format()

Kotlin

fun format(): Int

Objective-C

- (easyar_PixelFormat)format

Swift

public func format() -> PixelFormat

C#

public virtual PixelFormat format()

width

返回图像宽度。图像数据的右方会有 pixelWidth - width 像素的padding。

C

int easyar_Image_width(const easyar_Image * This)

C++

int width()

Java

public int width()

Kotlin

fun width(): Int

Objective-C

- (int)width

Swift

public func width() -> Int32

C#

public virtual int width()

height

返回图像高度。图像数据的下方会有 pixelHeight - height 像素的padding。

C

int easyar_Image_height(const easyar_Image * This)

C++

int height()

Java

public int height()

Kotlin

fun height(): Int

Objective-C

- (int)height

Swift

public func height() -> Int32

C#

public virtual int height()

pixelWidth

返回图像编码时使用的像素宽度。

C

int easyar_Image_pixelWidth(const easyar_Image * This)

C++

int pixelWidth()

Java

public int pixelWidth()

Kotlin

fun pixelWidth(): Int

Objective-C

- (int)pixelWidth

Swift

public func pixelWidth() -> Int32

C#

public virtual int pixelWidth()

pixelHeight

返回图像编码时使用的像素高度。

C

int easyar_Image_pixelHeight(const easyar_Image * This)

C++

int pixelHeight()

Java

public int pixelHeight()

Kotlin

fun pixelHeight(): Int

Objective-C

- (int)pixelHeight

Swift

public func pixelHeight() -> Int32

C#

public virtual int pixelHeight()

create

C

void easyar_Image_create(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, int pixelWidth, int pixelHeight, easyar_Image * * Return)

C++

static std::shared_ptr<Image> create(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)

Java

public static @Nonnull Image create(@Nonnull Buffer buffer, int format, int width, int height, int pixelWidth, int pixelHeight)

Kotlin

companion object fun create(buffer: Buffer, format: Int, width: Int, height: Int, pixelWidth: Int, pixelHeight: Int): Image

Objective-C

+ (easyar_Image *)create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height pixelWidth:(int)pixelWidth pixelHeight:(int)pixelHeight

Swift

public static func create(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32, _ pixelWidth: Int32, _ pixelHeight: Int32) -> Image

C#

public static Image create(Buffer buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)