none
What is Windows.Media.IVideoFrameStatics? RRS feed

  • Question

  • Hello hello,

    I try to implement faceTacker into the hololens. For that I use Hololens Camera Stream, because MediaCapture use CaptureElement which from XAML. My problem is when I implement videoFrame for FaceTracker I have this error :

    System.InvalidCastException: Unable to cast object of type 'System.__ComObject' to type 'Windows.Media.IVideoFrameStatics'.
       at System.StubHelpers.StubHelpers.GetCOMIPFromRCW_WinRT(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget)
       at Windows.Media.VideoFrame.CreateWithSoftwareBitmap(SoftwareBitmap bitmap)
       at test02.OnFrameSampleAcquired(VideoCaptureSample sample)

    And when I write it on google, I have result about Windows Media Player, so I have no idea what is it and how to resolve it ...

    Here is my code :

     void OnFrameSampleAcquired(VideoCaptureSample sample)
        {
            if (frameSample == null || frameSample.Length < sample.dataLength)
            {
                frameSample = new byte[sample.dataLength];
            }
    
            sample.CopyRawImageDataIntoBuffer(frameSample);
    
            IBuffer ibuffer = null;
            if(frameSample != null)
                ibuffer = frameSample.AsBuffer();
            else
                Debug.Log("frameSample null");
    
            SoftwareBitmap softwareBitmapFrameSample = new SoftwareBitmap(BitmapPixelFormat.Nv12, this._resolution.width, this._resolution.height);
            softwareBitmapFrameSample.CopyFromBuffer(ibuffer);
    
            if(softwareBitmapFrameSample == null)
                Debug.Log("Failed to create SoftwareBitmap");
            else
                Debug.Log("SoftwareBitmap success");
            try
            {
                Debug.Log("BEFORE VIDEOfRAME");
                VideoFrame videoFrameSample = VideoFrame.CreateWithSoftwareBitmap(softwareBitmapFrameSample);
            }catch(Exception ex){
                Debug.Log(ex);
            }/*
            UnityEngine.WSA.Application.InvokeOnAppThread(() =>
            {
    //                faces = await this.faceTracker.ProcessNextFrameAsync();
            }, false);*/
    }

    Thanks for the help...


    • Edited by Keurkeur Sunday, April 14, 2019 11:02 PM
    Sunday, April 14, 2019 11:02 PM

All replies

  • Hi KeurKeur,

    Thank you for posting here.

    For your question is more related to HoloLens, you could post a new thread in HoloLens forum for suitable support.

    https://forums.hololens.com/

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 15, 2019 6:49 AM
    Moderator
  • Hello hello,

    thank you for your answer. But I think (even if I posted like you said in hololens forum) the problem is not really related to the hololens. The error I posted comes from the line :

    VideoFrame videoFrameSample = VideoFrame.CreateWithSoftwareBitmap(softwareBitmapFrameSample);

    So ... I don't know ... :/

    Thank you !

    Monday, April 15, 2019 10:30 PM