Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by thrmotta · Jul 02, 2014 at 03:21 PM · c#colormapkinectdepth

Kinect Map Depth into Color

Hello!

Im currently working on a project where I need to display a pointcloud using Kinect, which I already achieved. The result can be seen at the picture bellow. For this Im using Microsoft Kinect SDK v1.8.0 with a Kinect for XBOX hardware at Windows 7 and Unity Pro.

alt text

The problem is that the RGB camera and the Depth camera are not calibrated, so the pixels from each camera arent corresponding to each other at the moment.

After searching at the Kinect SDK documentation, I saw that there is this method called CoordinateMapper.MapDepthFrameToColorFrame, which does exactly what I need to match both streams.

But then again I cant seem to find this method within Unity Kinect Plugin. To be honest I even opened the kinect10.dll and search for it, but couldnt find it. So I decided to implement it myself. Here is my try:

At KinectInterop.cs, within NativeMethods class, I did this:

 [DllImportAttribute(@"C:\Windows\System32\Kinect10.dll", 
            EntryPoint = "MapDepthFrameToColorFrame")]
                            
     public static extern int MapDepthFrameToColorFrame(
            DepthImageFormat depthImageFormat,  
            ref DepthImagePixel[] depthPixels,  
            ColorImageFormat colorImageFormat,  
            ref ColorImagePoint[] colorPoints);

I also tried using the following instead with no success:

 [DllImportAttribute(@"C:\Windows\System32\Kinect10.dll", 
            EntryPoint = "CoordinateMapper.MapDepthFrameToColorFrame")]

The structs are defined before NativeMethods class and goes as follow:

 [StructLayout(LayoutKind.Sequential)]
     public struct ColorImagePoint
     {
         public int X;
         public int Y;
     }
  
     [StructLayout(LayoutKind.Sequential)]
     public struct DepthImagePixel
     {
         public Int16 Depth;
         public bool IsKnownDepth;
         public Int16 PlayerIndex;
  
     }
  
     public enum ColorImageFormat : int
     {
         RGB = 0,
         YUV = 1,
         Bayer = 2,
         Undefined = 3,
     }
  
     public enum DepthImageFormat : int
     {
         Resolution320x240Fps30 = 0,
         Resolution640x480Fps30 = 1,
         Resolution80x60Fps30 = 2,
         Undefined = 3
     }

Now at the main file:

     private Kinect.ColorImagePoint[] mappedDepthLocations;
         private Kinect.DepthImagePixel[] depthStreamPixel;
     
         void Start () {
         mappedDepthLocations = 
 new Kinect.ColorImagePoint[depthImageHeight*depthImageWidth];
         depthStreamPixel = 
 new Kinect.DepthImagePixel[depthImageHeight*depthImageWidth];
         }
     
         void Update () {
     
                 if (depthStream.pollDepth () && colorStream.pollColor()) {
     
     
                 for ( int i = 0; i < depthImageWidth; i++ )
                     {
                         for ( int j = 0; j < depthImageHeight; j++ )
                         {
                             int index = i+j*depthImageWidth;
                             depthStreamPixel[index].Depth = depthStream.depthImg[index];
                             depthStreamPixel[index].IsKnownDepth = true;
                             depthStreamPixel[index].PlayerIndex = 0;
                         }
                     }
     
                     Kinect.NativeMethods. MapDepthFrameToColorFrame ( 
                         Kinect.DepthImageFormat.Resolution320x240Fps30, 
                         ref depthStreamPixel,
                         Kinect.ColorImageFormat.RGB, 
                         ref mappedDepthLocations );
                 }
         }

This is giving me the following error: EntryPointNotFoundException.

After double checking the Kinect SDK reference ( http://msdn.microsoft.com/en-us/library/jj883690.aspx ), Ive seen that the class defined is within the CoordinateMapper class, which is not defined in my project, but should it really be?

If thats not the problem, what could it be? Im kinda lost here, is the first time Im working with these DllImportAttribute methods.

Besides trying the above, I can also calibrate it myself by multiplying Projection and Modelview Matrixes, but that would be a bummer.

Is there any other way to achieve the same result?

Thank you all for the help!!

kinectcaliberror.png (70.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

KinectWrapperPackage Depth Camera 2 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Use kinect depth map as input? 1 Answer

Transitioning colors based on variable. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges