Software Archive
Read-only legacy content
17061 Discussions

3D scan problem in Unity

峰_張_
Beginner
325 Views

Hi everybody,

I did the 3D scanning in Unity and displayed the preview image in the plane.

But it is something wrong. Before started to scan, the preview image is normal like the image below.

And when I started to scan, the preview become weird.

Does anyone know how to fix it?

0 Kudos
2 Replies
Xusheng_L_Intel
Employee
325 Views

Could you provide the relate codes so we can help you to figure out the issue? Thanks!

0 Kudos
峰_張_
Beginner
325 Views

I called the AcquirePreviewImage function and got the preview image.
            Then I transfer the preview image into Texture2D and use it as the mainTexture of the plane in Unity.
            Relate code is :
            
          

 //Preview the scanning result
            PXCMImage scanimage = scan.AcquirePreviewImage ();
        
            /*Retrieve and render the individual color and depth images */           
            if (scanimage != null) {                        
                if (scanTexture2D == null) {                     
                    /* If not allocated, allocate a Texture2D */                     
                    scanTexture2D = new Texture2D (scanimage.info.width, scanimage.info.height, TextureFormat.ARGB32, false);  
                    
                    /* Associate the Texture2D with a gameObject */                     
                    scanPlane.renderer.material.mainTexture = scanTexture2D;                     
                }  
                
                /* Retrieve the image data in Texture2D */                 
                PXCMImage.ImageData scanImageData;
                scanimage.AcquireAccess (PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out scanImageData);               
                scanImageData.ToTexture2D (0, scanTexture2D);               
                scanimage.ReleaseAccess (scanImageData);  
                
                /* Apply the texture to the GameObject to display on */                 
                scanTexture2D.Apply ();  

                scanimage.Dispose ();
            }


            
            I have another question now.
            I set the scan configure as below.
            
          

            scan_config = new PXCM3DScan.Configuration();
            scan_config.maxVertices = 30000;
            scan_config.mode = PXCM3DScan.ScanningMode.VARIABLE;
            scan_config.options = PXCM3DScan.ReconstructionOption.LANDMARKS;
            scan_config.options = scan_config.options | PXCM3DScan.ReconstructionOption.TEXTURE;
            scan_config.startScan = StartScanFlag;
            pxcmStatus ConfiguresState = scan.SetConfiguration (scan_config);
            Debug.Log ("Face Scan Module Configure setting state : " + ConfiguresState);


            
            The error message said "Face Scan Module Configure setting state : PXCM_STATUS_INIT_FAILED".
            
            But if I remove the configure setting of Texture, it is work!

0 Kudos
Reply