Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use ARCamera as the input of HandLandmarkDetection in the new version? #1261

Open
price6856 opened this issue Sep 24, 2024 · 1 comment
Labels
type:feature New feature or request

Comments

@price6856
Copy link

Feature Description

I have looked at the solutions of previous MediaPipe versions, but some classes or methods have been deprecated compared to the latest MediaPipe for Unity. Can you provide a simple example? Thank you.

Current Behaviour/State

No response

Additional Context

No response

@price6856 price6856 added the type:feature New feature or request label Sep 24, 2024
@nemajor1
Copy link

nemajor1 commented Oct 8, 2024

Check this

void OnCameraFrameReceived(ARCameraFrameEventArgs args)
    {
        if (arCameraManager.TryAcquireLatestCpuImage(out XRCpuImage image))
        {
            var conversionParams = new XRCpuImage.ConversionParams
            {
                inputRect = new RectInt(0, 0, image.width, image.height),
                outputDimensions = new Vector2Int(image.width, image.height),
                outputFormat = TextureFormat.RGBA32,
                transformation = XRCpuImage.Transformation.None
            };

            var rawTextureData = new NativeArray<byte>(image.GetConvertedDataSize(conversionParams), Allocator.Temp);
            image.Convert(conversionParams, rawTextureData);

            if (cameraTexture == null || cameraTexture.width != image.width || cameraTexture.height != image.height)
            {
                cameraTexture = new Texture2D(image.width, image.height, TextureFormat.RGBA32, false);
            }

            cameraTexture.LoadRawTextureData(rawTextureData);
            cameraTexture.Apply();

            var textureFrame = new TextureFrame(cameraTexture.width, cameraTexture.height, TextureFormat.RGBA32);

            textureFrame.ReadTextureFromOnCPU(cameraTexture);

            graph.AddTextureFrameToInputStream(textureFrame);

            rawTextureData.Dispose();
            image.Dispose();
        }
    }
use XRCpuImage.ConversionParams and AddTextureFrameToInputStream, but there is a bug with coordinate inversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants