ข้อมูลอ้างอิงเฟรมเวิร์ก MLKitVision
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
GMLImage
@interface GMLImage : NSObject
รูปภาพที่ใช้ในแมชชีนเลิร์นนิงในอุปกรณ์
-
ความกว้างของรูปภาพเป็นพิกเซล
คำประกาศ
Objective-C
@property (nonatomic, readonly) CGFloat width;
-
ความสูงของรูปภาพเป็นพิกเซล
คำประกาศ
Objective-C
@property (nonatomic, readonly) CGFloat height;
-
การวางแนวในการแสดงของรูปภาพ หาก imageSourceType
คือ .image
ค่าเริ่มต้นจะเป็น
image.imageOrientation
; ไม่เช่นนั้น ค่าเริ่มต้นจะเป็น .up
คำประกาศ
Objective-C
@property (nonatomic) int orientation;
-
ประเภทของแหล่งที่มาของรูปภาพ
-
คำประกาศ
Objective-C
@property (nonatomic, readonly, nullable) int *image;
-
คำประกาศ
Objective-C
@property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;
-
คำประกาศ
Objective-C
@property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;
-
เริ่มต้นออบเจ็กต์ MLImage
ด้วยรูปภาพที่ระบุ
คำประกาศ
Objective-C
- (nullable instancetype)initWithImage:(id)image;
พารามิเตอร์
image
|
รูปภาพที่จะใช้เป็นต้นฉบับ พร็อพเพอร์ตี้ CGImage ของ URL ต้องไม่ใช่ NULL
|
ผลลัพธ์
อินสแตนซ์ MLImage
ใหม่ที่มีรูปภาพที่ระบุเป็นแหล่งที่มา nil
หาก image
ที่ระบุ
nil
หรือไม่ถูกต้อง
-
เริ่มต้นออบเจ็กต์ MLImage
ด้วยบัฟเฟอร์พิกเซลที่กำหนด
คำประกาศ
Objective-C
- (nullable instancetype)initWithPixelBuffer:
(nonnull CVPixelBufferRef)pixelBuffer;
พารามิเตอร์
pixelBuffer
|
บัฟเฟอร์พิกเซลที่จะใช้เป็นแหล่งที่มา โปรไฟล์จะเก็บไว้โดย
MLImage อินสแตนซ์ตลอดอายุการใช้งาน
|
ผลลัพธ์
อินสแตนซ์ MLImage
ใหม่ที่มีบัฟเฟอร์พิกเซลที่ระบุเป็นแหล่งที่มา nil
หากระบุ
บัฟเฟอร์พิกเซล nil
หรือไม่ถูกต้อง
-
เริ่มต้นออบเจ็กต์ MLImage
ด้วยบัฟเฟอร์ตัวอย่างที่ระบุ
คำประกาศ
Objective-C
- (nullable instancetype)initWithSampleBuffer:
(nonnull CMSampleBufferRef)sampleBuffer;
พารามิเตอร์
sampleBuffer
|
บัฟเฟอร์ตัวอย่างที่จะใช้เป็นแหล่งที่มา โปรไฟล์จะเก็บไว้โดย
MLImage อินสแตนซ์ตลอดอายุการใช้งาน ตัวอย่างบัฟเฟอร์ต้องอิงตาม
บัฟเฟอร์พิกเซล (ไม่ใช่ข้อมูลที่บีบอัด) ในทางปฏิบัติแล้ว ก็ควรจะเป็นเอาต์พุตวิดีโอของกล้อง
ในอุปกรณ์ iOS ไม่ใช่ CMSampleBuffer ประเภทอื่นๆ
|
ผลลัพธ์
อินสแตนซ์ MLImage
ใหม่ที่มีบัฟเฟอร์ตัวอย่างที่ระบุเป็นแหล่งที่มา nil
หากระบุ
บัฟเฟอร์ตัวอย่าง nil
หรือไม่ถูกต้อง
-
คำประกาศ
Objective-C
- (nonnull instancetype)init;
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003e\u003ccode\u003eGMLImage\u003c/code\u003e is an object used for on-device machine learning representing an image.\u003c/p\u003e\n"],["\u003cp\u003eIt can be initialized with an image, a pixel buffer, or a sample buffer, defining the image source.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGMLImage\u003c/code\u003e provides read-only access to properties like width, height, orientation, and the image source type.\u003c/p\u003e\n"],["\u003cp\u003eIf initialized with an image, the \u003ccode\u003eimage\u003c/code\u003e property holds the source image; otherwise, it's \u003ccode\u003enil\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eSimilarly, \u003ccode\u003epixelBuffer\u003c/code\u003e and \u003ccode\u003esampleBuffer\u003c/code\u003e properties hold the respective source data depending on the initialization type, being \u003ccode\u003enil\u003c/code\u003e otherwise.\u003c/p\u003e\n"]]],["GMLImage manages images for on-device machine learning, defining properties like `width`, `height`, `orientation`, and `imageSourceType`. It can be initialized using `-initWithImage:`, `-initWithPixelBuffer:`, or `-initWithSampleBuffer:`, accepting an image, pixel buffer, or sample buffer respectively as the source. It also exposes the source data through read-only properties, such as `image`, `pixelBuffer`, and `sampleBuffer`, depending on `imageSourceType`. The `-init` method is unavailable.\n"],null,["# MLKitVision Framework Reference\n\nGMLImage\n========\n\n\n @interface GMLImage : NSObject\n\nAn image used in on-device machine learning.\n- `\n ``\n ``\n `\n\n ### [width](#/c:objc(cs)GMLImage(py)width)\n\n `\n ` \n Width of the image in pixels. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) CGFloat width;\n\n- `\n ``\n ``\n `\n\n ### [height](#/c:objc(cs)GMLImage(py)height)\n\n `\n ` \n Height of the image in pixels. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) CGFloat height;\n\n- `\n ``\n ``\n `\n\n ### [orientation](#/c:objc(cs)GMLImage(py)orientation)\n\n `\n ` \n The display orientation of the image. If [imageSourceType](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType) is [.image](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)image), the default value is\n `image.imageOrientation`; otherwise the default value is `.up`. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic) int orientation;\n\n- `\n ``\n ``\n `\n\n ### [imageSourceType](#/c:objc(cs)GMLImage(py)imageSourceType)\n\n `\n ` \n The type of the image source. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) ../Type-Definitions.html#/c:GMLImage.h@T@GMLImageSourceType imageSourceType;\n\n- `\n ``\n ``\n `\n\n ### [image](#/c:objc(cs)GMLImage(py)image)\n\n `\n ` \n The source image. `nil` if [imageSourceType](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType) is not `.image`. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) int *image;\n\n- `\n ``\n ``\n `\n\n ### [pixelBuffer](#/c:objc(cs)GMLImage(py)pixelBuffer)\n\n `\n ` \n The source pixel buffer. `nil` if [imageSourceType](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType) is not `.pixelBuffer`. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;\n\n- `\n ``\n ``\n `\n\n ### [sampleBuffer](#/c:objc(cs)GMLImage(py)sampleBuffer)\n\n `\n ` \n The source sample buffer. `nil` if [imageSourceType](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType) is not `.sampleBuffer`. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;\n\n- `\n ``\n ``\n `\n\n ### [-initWithImage:](#/c:objc(cs)GMLImage(im)initWithImage:)\n\n `\n ` \n Initializes an `MLImage` object with the given image. \n\n #### Declaration\n\n Objective-C \n\n - (nullable instancetype)initWithImage:(id)image;\n\n #### Parameters\n\n |---------------|----------------------------------------------------------------------------|\n | ` `*image*` ` | The image to use as the source. Its `CGImage` property must not be `NULL`. |\n\n #### Return Value\n\n A new `MLImage` instance with the given image as the source. `nil` if the given [image](../Classes/GMLImage.html#/c:objc(cs)GMLImage(py)image)\n is `nil` or invalid.\n- `\n ``\n ``\n `\n\n ### [-initWithPixelBuffer:](#/c:objc(cs)GMLImage(im)initWithPixelBuffer:)\n\n `\n ` \n Initializes an `MLImage` object with the given pixel buffer. \n\n #### Declaration\n\n Objective-C \n\n - (nullable instancetype)initWithPixelBuffer:\n (nonnull CVPixelBufferRef)pixelBuffer;\n\n #### Parameters\n\n |---------------------|-----------------------------------------------------------------------------------------------------------------------------|\n | ` `*pixelBuffer*` ` | The pixel buffer to use as the source. It will be retained by the new `MLImage` instance for the duration of its lifecycle. |\n\n #### Return Value\n\n A new `MLImage` instance with the given pixel buffer as the source. `nil` if the given\n pixel buffer is `nil` or invalid.\n- `\n ``\n ``\n `\n\n ### [-initWithSampleBuffer:](#/c:objc(cs)GMLImage(im)initWithSampleBuffer:)\n\n `\n ` \n Initializes an `MLImage` object with the given sample buffer. \n\n #### Declaration\n\n Objective-C \n\n - (nullable instancetype)initWithSampleBuffer:\n (nonnull CMSampleBufferRef)sampleBuffer;\n\n #### Parameters\n\n |----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*sampleBuffer*` ` | The sample buffer to use as the source. It will be retained by the new `MLImage` instance for the duration of its lifecycle. The sample buffer must be based on a pixel buffer (not compressed data). In practice, it should be the video output of the camera on an iOS device, not other arbitrary types of `CMSampleBuffer`s. |\n\n #### Return Value\n\n A new `MLImage` instance with the given sample buffer as the source. `nil` if the given\n sample buffer is `nil` or invalid.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)GMLImage(im)init)\n\n `\n ` \n Unavailable. \n\n #### Declaration\n\n Objective-C \n\n - (nonnull instancetype)init;"]]