Software Archive
Read-only legacy content
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
17065 Discussions

Error in Mapping Depth to Color Coordinates using UV Mapping

himanshu_p_
Beginner
106 Views

Hi,

I have Intel RealSense F200 camera, trying to Map Depth to Color Coordinates using UV Mapping, through the following code.

CodeSnippet:--

                        PXCMCapture.Sample sampleCD = senseMgr.QuerySample();
                        PXCMImage depth= sampleCD.depth;
                        PXCMImage color= sampleCD.color;
                        
                        PXCMProjection projection=device.CreateProjection();// Create the PXCMProjection instance.
                        
                        
                        // color and depth image size.
                           PXCMImage.ImageInfo dinfo=depth.QueryInfo();
                        PXCMImage.ImageInfo cinfo=color.QueryInfo();
                         
                        // Calculate the UV map.
                        PXCMPointF32[] uvmap=new PXCMPointF32[dinfo.width*dinfo.height];
                        projection.QueryUVMap(depth, uvmap);
                         
                        // Translate depth points dBuffRaw[] to color depthToColor[]
                        float depthToColor[]=  new float[dBuffRaw.length];
                        for (int y=0; y <  dHeight-1; y++) 
                        {
                            for (int x=0; x <  dWidth - 1; x++)  
                            {
                                    for (int i=0;i<dBuffRaw.length;i++) {
                                        depthToColor.x=uvmap[(int)dBuffRaw.y*dinfo.width+(int)dBuffRaw.x].x*cinfo.width;
                                        depthToColor.y=uvmap[(int)dBuffRaw.y*dinfo.width+(int)dBuffRaw.x].y*cinfo.height;

                                 }
                            }
                        }

I am getting error "x cannot be resolved or is not a field"  "y cannot be resolved or is not a field"  on above bold lines.

 

regards,
Himanshu

0 Kudos
2 Replies
jb455
Valued Contributor II
106 Views

You've set up depthToColor[] as a float array. Presumably you want it to be a PXCMPointF32[] array instead? That's the only obvious problem I can see. If you fix that and it still doesn't work I'll take a closer look for you.

Let me know how you get on!
James

himanshu_p_
Beginner
106 Views

Thanks James for your prompt reply......I got the solution..... 

Reply