Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

R200 Enhanced photo not working in C#

Aaron_B_3
Beginner
559 Views

I'm trying to use the enhanced photo module inside of a C# project and am running into some trouble. Unfortunately I can't get any feedback from the SDK about what they error might be or what I am doing wrong. Has anyone got this module to work successfully in C#?

 

Here is how I load the module:

            PXCMSession session = PXCMSession.CreateInstance();
            short major = session.QueryVersion().major;
            short minor = session.QueryVersion().minor;
            Console.WriteLine("SDK Version {0}.{1}", major, minor);
            session.Dispose();
         
            PXCMSenseManager sm = PXCMSenseManager.CreateInstance();

          
        
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 628, 468, 30);
            PXCMEnhancedPhoto ep;
            PXCMPhoto photo = sm.QuerySession().CreatePhoto();
            pxcmStatus sts = sm.QuerySession().CreateImpl<PXCMEnhancedPhoto>(out ep);
            if(sts == pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("enhanced photo module created");
            }
            sm.Init();

This results in the console displaying "enhanced photo module created" - presumably all is well.

Here is the code where I attempt to use the enhanced photo module to resize the depth:

                        photo.ImportFromPreviewSample(sample);
                        PXCMImage.ImageInfo info = photo.QueryReferenceImage().QueryInfo();
                        PXCMSizeI32 targetSize = new PXCMSizeI32(info.width, info.height);

                        PXCMImage depthFromPhoto = photo.QueryRawDepthImage();
                        PXCMPhoto resized = ep.DepthResize(photo, targetSize);
                        if(resized==null)
                        {
                            Console.WriteLine("image did not resize properly");
                        }

Here is the entire main:

static void Main(string[] args)
        {
            PXCMSession session = PXCMSession.CreateInstance();
            short major = session.QueryVersion().major;
            short minor = session.QueryVersion().minor;
            Console.WriteLine("SDK Version {0}.{1}", major, minor);
            session.Dispose();
         
            PXCMSenseManager sm = PXCMSenseManager.CreateInstance();

           
        
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 628, 468, 30);
           // sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_RIGHT, 628, 468, 30);
           // sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_LEFT, 628, 468, 30);
            PXCMEnhancedPhoto ep;
            PXCMPhoto photo = sm.QuerySession().CreatePhoto();
            pxcmStatus sts = sm.QuerySession().CreateImpl<PXCMEnhancedPhoto>(out ep);
            if(sts == pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("enhanced photo module created");
            }
            sm.Init();


            

           


            int frames = 0;
            while (frames < 60)
            {
                // This function blocks until a color sample is ready
                sts = sm.AcquireFrame(true);
                if (!sts.IsError())
                {
                    // retrieve the sample
                    PXCMCapture.Sample sample;
                    sample = sm.QuerySample();
                    if (frames == 59)
                    {



                      


                        photo.ImportFromPreviewSample(sample);
                        PXCMImage.ImageInfo info = photo.QueryReferenceImage().QueryInfo();
                        PXCMSizeI32 targetSize = new PXCMSizeI32(info.width, info.height);

                        PXCMImage depthFromPhoto = photo.QueryRawDepthImage();
                        PXCMPhoto resized = ep.DepthResize(photo, targetSize);
                        if (resized == null)
                        {
                            Console.WriteLine("image did not resize properly");
                        }

                    }

                    sm.ReleaseFrame();
                    Console.WriteLine("frame acquired");
                }
                else
                {
                    Console.WriteLine("Error acquiring frame");
                }


                frames++;
            }
            sm.Close();
            Console.WriteLine("CTRL-C to close...");
            Console.ReadLine();
        }

 

0 Kudos
2 Replies
Aaron_B_3
Beginner
559 Views

Update on this: This actually does work in some cases but not all. In the case where it does work it outputs a message about CUDA. Is there anyway to force this process only on the CPU?

edit: As a bizarre addition to this update, resizing the depth with the enhanced photo module works on my desktop computer with an R200 dev kit and an Nvidia card. EnhancedDepth does not work on this computer.

On my recently purchased HP Spectre X2 with a built-in R200 EnhancedDepth works but resizing the depth does not. Any suggestions or additional guidance as to what this module is doing would be appreciated. Here the platform it outputs to the console is OpenCL.

Thanks!

0 Kudos
Xusheng_L_Intel
Employee
559 Views

Need OpenCL 1.2 support for EP MW. 

0 Kudos
Reply