Latest SDK v2.0.7 - Help find any example or instructions of using c# wrapper

I’ve just updated AstraDotNetDemo:

  • Switched to version 2.0.9-beta3 of Astra SDK
  • Fixed bug in color visualization (R and B channels were swapped)
  • Added support for depth registration mode (as was requested by @shanigu3d)
  • Known issues (thanks to low quality of Astra SDK…) are described in Known issues section of readme.md

Thanks Andrew!
I am now also able to finally open 1280x1024 color and depth modes through C#!

Please advice regarding Astra video recording/replaying framework.
Openni not good for my problem, because I need to use .mp4 video format.
Opencv (EmguCV) also not good, because it doesn’t have a real timestamp. I need the real timestamp for synchronization with the recorded body data.
Trying to use Media Foundation, but have a lot of issues with MF .Net wrapper.

Is there a Ubuntu Linux/Persee version of this sample by any chance?

@andrew in your sample sometimes I am getting corrupted body frame, it happens during handling body frame in ViewModel

any suggestion how to fix it?

There is one addition to this checklist, you have to save the “Astra.StreamSet” after making the streams. Even though you don’t use it anymore, if it gets garbage collected it will close the connection with the camera and all it will tell you is that you have an invalid argument exception at “streamReader.TryOpenFrame()”

Hi andrew, i copied the code into the VS 2017 and it didnt work are you able to provide an guide on how to use the AstraDotNetDemo? I pressed F5 to debug and there is 98 errors.
Thank you.

hi how do you do this are you able to teach me thankyou

i got this error as well when trying to run the code still could not solve this yet. I hope someone have the solution to it.

@andrew and all : Demo AstraDotNetDemo on github its free trial version and required any license???

@victorsbd Can you please share your source code ??

Please refer readme.md file (“License” section).

Hi,
Thanks for this wrapper.
I got the depth frame.
How do I calculate distance from camera to pixel?
I have this:

    private void HandleDepthFrame(
        Astra.ReaderFrame frame )
    {
        var depthFrame = frame.GetFrame<Astra.DepthFrame>();
        if ( depthBuffer.Update( depthFrame ) )
        {
            BitmapSource image = depthBuffer.ImageSource;
            dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() => getBitmap(image)));

            if ( frameRateCalculator.RegisterFrame() )
                RaisePropertyChanged( nameof(FramesPerSecond) );
        }
    }

    private void getBitmap(BitmapSource source)
    {
        var bmp = new Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
        var data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
        source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
        bmp.UnlockBits(data);
        var imageCV = new Image<Gray, Int16>(bmp);
        //How di I read the distance?
    }

How can I get the depth measurement from a pixel on the DepthFame object?

Hello,
Since depth is a short indicating millimeters, i created these handy functions in the DepthBuffer class:

public unsafe short GetNativeDepthAt(int index)
        {
            fixed (void* innerBufferPtr = innerBuffer)
            {
                short* srcPtr = (short*)innerBufferPtr + index;
                return *srcPtr;
            }
        }

        public unsafe short GetNativeDepthAt(int x, int y)
        {
            fixed (void* innerBufferPtr = innerBuffer)
            {
                short* srcPtr = (short*)innerBufferPtr + (y * width) + x;
                return *srcPtr;
            }
        }

        // Returns depth in millimeters at coordinate
        public float GetMetricDepthAt(int x, int y)
        {
            short depth = GetNativeDepthAt(x, y);
            return ((float) depth) / 1000f;
        }

Thank you, very handy. Where did you get the Matrix class?

Thank you very much for this

1 Like

Are you asking me about this?

No it was for shanigu, but nevermind i just found it was from a Nuget math class.

All the best!

I followed the “how to use” instruction. However, the program run into break mode when executing Astra.Context.Initialize(); Could you please advice on how to solve the issue? Very appreciated!