4 Replies Latest reply on May 19, 2017 3:23 AM by UCToby

    SDK R3 use ImageData.ToBitmap parameters?

    UCToby

      Hi guys,

       

      I'm fairly new to the game - I would like to analyse depth data to estimate the distance of the objects in front of the camera.

      I prefer writing in c# so I used the RawStreams.cs sample as my source. In the "StreamColorDepth"-while(!stop)-loop I call a new task with the image of that frame. The code of that thread is posted below:

      public void getImage(RS.Image img)
              {
                  Bitmap bitmap = new Bitmap(img.Info.width,img.Info.height);
                  RS.ImageData idata;
                  img.AcquireAccess(RS.ImageAccess.ACCESS_WRITE, out idata);
                  idata.ToBitmap(0, bitmap);
                  img.ReleaseAccess(idata);
              }
      

      Line 6 throws "System.ArgumentException" with the additional information being "Parameter is not valid.".

      The documentation lists .ToBitmap(Bitmap bitmap), so there's actually no int in the beginning. Visual Studio requests that int though..

       

      Any help is greatly appreciated!

       

      EDIT:

      it seems that the problem is already in Line 5!

      I added a RS.status before the img.AcquireAccess, and I get a "STATUS_PARAM_UNSUPPORTED".

      I also tried RS.ImageAccess.ACCESS_READ_WRITE -> same result.

       

      EDIT2:

      I also tried istatus = img.ExportData(idata,0); -> same result. I'm not sure about the ",0", there is no mention of this in the documentation. The parameter is an integer called "flags".

       

      Cheers,

      Toby

        • 1. Re: SDK R3 use ImageData.ToBitmap parameters?
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Toby,

          Thanks for reaching out!

          First of all, I would like to ask you which camera you are using in order to make sure we have the same environment.

          I would like to test this to see if I'm able to see the same behavior as you, for this I would like to request for the complete code. I am aware that your code is based in RawStreams.cs but in order to make sure that we are running the same application I would like you to share the full code.

          I'll be waiting for your response.
          Pedro M.

          • 2. Re: SDK R3 use ImageData.ToBitmap parameters?
            UCToby

            Hi Pedro,

             

            I am working on a Windows 10 Notebook, the camera I'm using is the new SR300.

             

            I uploaded the project to WeTransfer (I couldn't find an "attach file" function in the forum) and will also try some more things (and edit this post if something possibly meaningful comes up).

             

             

            Thanks for the reply and effort,

            Toby

            • 3. Re: SDK R3 use ImageData.ToBitmap parameters?
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Thank you for letting us know the camera that you are using. 

              I've been testing your code and I'm indeed able to see the same behavior as you. I've been trying to analyze why AcquireAccess throws a STATUS_PARAM_UNSUPPORTED but I'm not able to see why. I even, tried to use the full command like:

              istatus = image.AcquireAccess(Intel.RealSense.ImageAccess.ACCESS_READ_WRITE, Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_RAW, Intel.RealSense.ImageRotation.ROTATION_ANY, Intel.RealSense.ImageOption.OPTION_ANY, out idata);

              I noticed that that you set the pixel format of idata to depth, so I tried to change the pixel format in AcquireAccess to the different formats of depth available but the same thing happens every time even if I try with the option any.

              Let me see what I can find out about this. I'll get back to you as soon as I have any useful update.

              Pedro M. 

              • 4. Re: SDK R3 use ImageData.ToBitmap parameters?
                UCToby

                Hi Pedro,

                 

                I got some data from the "projection.QueryVertices" function. I don't know yet how to further use this data but it might be the way to go. I will first try to validate the data to see if it makes sense. I too will post any updates i find. If you're interested I can upload my project on monday once more.

                 

                EDIT:

                It works! I exported the data to a csv file which in turn I imported into a Unity scene an created a sphere on each point.

                3D_Data.png

                I don't really need the data I originally asked for anymore, this is much better for my usecase!

                If you find a solution I'd still be interested, but currently I am completely satisfied with what I have.

                 

                Cheers & thanks so far!

                Toby