diff --git a/impl/ocean/devices/arkit/Utilities.h b/impl/ocean/devices/arkit/Utilities.h index f1ebe75b0..91b6850be 100644 --- a/impl/ocean/devices/arkit/Utilities.h +++ b/impl/ocean/devices/arkit/Utilities.h @@ -65,8 +65,9 @@ class OCEAN_DEVICES_ARKIT_EXPORT Utilities * Extracts the color image from an ARKit frame. * @param arFrame The ARKit frame from which the color image will be extracted, must be valid * @param copyData True, to copy the data; False, to only use the memory of the ARKit frame + * @param preferredPixelFormat Optional preferred pixel format of the resulting frame, however the resulting frame can have any pixel format, FORMAT_UNDEFINED if not of interest */ - static Frame extractFrame(const ARFrame* arFrame, const bool copyData = true); + static Frame extractFrame(const ARFrame* arFrame, const bool copyData = true, const FrameType::PixelFormat preferredPixelFormat = FrameType::FORMAT_UNDEFINED); /** * Extracts the depth image from an ARKit frame, if existing. diff --git a/impl/ocean/devices/arkit/Utilities.mm b/impl/ocean/devices/arkit/Utilities.mm index 1f51c7810..67d577b27 100644 --- a/impl/ocean/devices/arkit/Utilities.mm +++ b/impl/ocean/devices/arkit/Utilities.mm @@ -18,13 +18,15 @@ namespace ARKit { -Frame Utilities::extractFrame(const ARFrame* arFrame, const bool copyData) +Frame Utilities::extractFrame(const ARFrame* arFrame, const bool copyData, const FrameType::PixelFormat preferredPixelFormat) { ocean_assert(arFrame != nullptr); const CVPixelBufferRef capturedImage = arFrame.capturedImage; - const Media::AVFoundation::PixelBufferAccessor pixelBufferAccessor(capturedImage, true /*readOnly*/); + const bool accessYPlaneOnly = preferredPixelFormat == FrameType::FORMAT_Y8; + + const Media::AVFoundation::PixelBufferAccessor pixelBufferAccessor(capturedImage, true /*readOnly*/, accessYPlaneOnly); if (!pixelBufferAccessor) {