Skip to content

Commit

Permalink
Extended utility function Utilities::extractFrame()
Browse files Browse the repository at this point in the history
Summary: Just an option to access the y-plane of an ARKit frame.

Reviewed By: enpe

Differential Revision: D65562188

fbshipit-source-id: f2fb7868162c1d60b1a995b3d3aadc0f4f2805fb
  • Loading branch information
janherling authored and facebook-github-bot committed Nov 6, 2024
1 parent 43e95cf commit f59f9a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion impl/ocean/devices/arkit/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions impl/ocean/devices/arkit/Utilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit f59f9a9

Please sign in to comment.