MLKitVision 框架参考
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
VisionImage
用于视觉检测的图片或图片缓冲区。
-
声明
Swift
var orientation: Int32 { get set }
-
使用给定图片初始化 VisionImage
对象。
参数
image
|
要在视觉检测中使用的图片。指定图片应旋转,因此其
imageOrientation 属性设置为 .up 。UIImage 必须具有非 NULL 值的 CGImage
属性。
|
返回值
具有指定映像的 VisionImage
实例。
-
使用给定的图片缓冲区初始化 VisionImage
对象。为了提升性能
在使用
一个 CMSampleBufferRef
。
声明
Swift
init(buffer sampleBuffer: CMSampleBuffer)
参数
sampleBuffer
|
要在视觉检测中使用的图片缓冲区。缓冲必须基于
像素缓冲区(非压缩数据),并且像素格式必须为以下之一:
- kCVPixelFormatType_32BGRA
- kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
- kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
实际上,这适用于手机摄像头的视频输出,但不适用于其他视频
任意来源的 CMSampleBufferRef 。
|
返回值
具有指定图像缓冲区的 VisionImage
实例。
-
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eVisionImage\u003c/code\u003e is an object used for vision detection tasks, accepting images or image buffers as input.\u003c/p\u003e\n"],["\u003cp\u003eIt's crucial to set the \u003ccode\u003eimageOrientation\u003c/code\u003e property of input \u003ccode\u003eUIImage\u003c/code\u003e to \u003ccode\u003e.up\u003c/code\u003e before initialization to ensure proper orientation.\u003c/p\u003e\n"],["\u003cp\u003eWhen using \u003ccode\u003eCMSampleBufferRef\u003c/code\u003e for initialization, ensure it's a pixel buffer with a supported pixel format like \u003ccode\u003ekCVPixelFormatType_32BGRA\u003c/code\u003e for optimal performance.\u003c/p\u003e\n"],["\u003cp\u003eFor \u003ccode\u003eCMSampleBufferRef\u003c/code\u003e inputs, compatibility is primarily with phone camera output, not arbitrary buffer sources.\u003c/p\u003e\n"],["\u003cp\u003eDirect initialization using \u003ccode\u003einit()\u003c/code\u003e is unavailable; utilize \u003ccode\u003einit(image:)\u003c/code\u003e or \u003ccode\u003einit(buffer:)\u003c/code\u003e instead.\u003c/p\u003e\n"]]],["`VisionImage` is a class for vision detection using images or image buffers. It has a settable `orientation` property, defaulting to `.up`. It initializes with either an `image`, requiring a rotated image with an `.up` orientation and a non-NULL `CGImage`, or a `CMSampleBuffer` image buffer with specified pixel formats. When using `CMSampleBufferRef`, minimize instance lifespan. Direct initialization using `init()` is unavailable.\n"],null,[]]