Table of Contents

Class Image

名前空間
easyar

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]);
    // ここでbytesを使用
    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);
    // ここでbytesを使用
    b.dispose();
    i.dispose();
    inputFrame.dispose();
    outputFrame.dispose();
}
Image

コンストラクター

Image

void easyar_Image__ctor(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, easyar_Image * * Return)
Image(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height)
public Image(@Nonnull Buffer buffer, int format, int width, int height)
constructor(buffer: Buffer, format: Int, width: Int, height: Int)
+ (easyar_Image *) create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height
public convenience init(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32)
public Image(Buffer buffer, PixelFormat format, int width, int height)

パラメーター

名前 説明
buffer Buffer
format PixelFormat
width Int32
height Int32

メソッド

buffer

画像内のデータバッファを返します。内部データへのアクセスにはBuffer APIを使用します。取得したBufferの内容は他のスレッドで使用されている可能性があるため、変更しないでください。

void easyar_Image_buffer(const easyar_Image * This, easyar_Buffer * * Return)
std::shared_ptr<Buffer> buffer()
public @Nonnull Buffer buffer()
fun buffer(): Buffer
- (easyar_Buffer *)buffer
public func buffer() -> Buffer
public virtual Buffer buffer()

戻り値

説明
Buffer

format

画像フォーマットを返します。

easyar_PixelFormat easyar_Image_format(const easyar_Image * This)
PixelFormat format()
public int format()
fun format(): Int
- (easyar_PixelFormat)format
public func format() -> PixelFormat
public virtual PixelFormat format()

戻り値

説明
PixelFormat

width

画像の幅を返します。画像データの右側にはpixelWidth-widthピクセルのパディングが存在します。

int easyar_Image_width(const easyar_Image * This)
int width()
public int width()
fun width(): Int
- (int)width
public func width() -> Int32
public virtual int width()

戻り値

説明
Int32

height

画像の高さを返します。画像データの下方にはpixelHeight-heightピクセルのパディングが存在します。

int easyar_Image_height(const easyar_Image * This)
int height()
public int height()
fun height(): Int
- (int)height
public func height() -> Int32
public virtual int height()

戻り値

説明
Int32

pixelWidth

画像エンコード時に使用されるピクセル幅を返します。

int easyar_Image_pixelWidth(const easyar_Image * This)
int pixelWidth()
public int pixelWidth()
fun pixelWidth(): Int
- (int)pixelWidth
public func pixelWidth() -> Int32
public virtual int pixelWidth()

戻り値

説明
Int32

pixelHeight

画像エンコード時に使用されるピクセル高さを返します。

int easyar_Image_pixelHeight(const easyar_Image * This)
int pixelHeight()
public int pixelHeight()
fun pixelHeight(): Int
- (int)pixelHeight
public func pixelHeight() -> Int32
public virtual int pixelHeight()

戻り値

説明
Int32

create

void easyar_Image_create(easyar_Buffer * buffer, easyar_PixelFormat format, int width, int height, int pixelWidth, int pixelHeight, easyar_Image * * Return)
static std::shared_ptr<Image> create(std::shared_ptr<Buffer> buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)
public static @Nonnull Image create(@Nonnull Buffer buffer, int format, int width, int height, int pixelWidth, int pixelHeight)
companion object fun create(buffer: Buffer, format: Int, width: Int, height: Int, pixelWidth: Int, pixelHeight: Int): Image
+ (easyar_Image *)create:(easyar_Buffer *)buffer format:(easyar_PixelFormat)format width:(int)width height:(int)height pixelWidth:(int)pixelWidth pixelHeight:(int)pixelHeight
public static func create(_ buffer: Buffer, _ format: PixelFormat, _ width: Int32, _ height: Int32, _ pixelWidth: Int32, _ pixelHeight: Int32) -> Image
public static Image create(Buffer buffer, PixelFormat format, int width, int height, int pixelWidth, int pixelHeight)

パラメーター

名前 説明
buffer Buffer
format PixelFormat
width Int32
height Int32
pixelWidth Int32
pixelHeight Int32

戻り値

説明
Image