C# Color image and custom Handtracking input image ReadStreamAsync exception

C# Color image and custom Handtracking input image ReadStreamAsync exception

Hi,

i want to use analyze a color image and use the gathered information to manipulate the depth image wich is passed to the hand tracking module. Unfortunaly I get an AccessViolationException when I call ReadStreamAsync and have no idea what i'm doing wrong. I thinks its caused by some lack of understanding the library. 

here is my class (sry for the bad code formatting (copy&paste didn't realy work :<):

class ExtendedProcessing : Processing {
     protected override void Capture()     {
         PXCMSession session;
         var sts = PXCMSession.CreateInstance(out session);
         if (sts<pxcmStatus.PXCM_STATUS_NO_ERROR) {
             return;
         }
        /* Set Module */
         var desc=new PXCMSession.ImplDesc();
         desc.friendlyName.set("Hand/Finger Tracking and Gesture Recognition");
        PXCMGesture gesture;
         sts=session.CreateImpl(ref desc,PXCMGesture.CUID,out gesture);
         if (sts<pxcmStatus.PXCM_STATUS_NO_ERROR) {
             session.Dispose();
             return;
         }
        var capture=new UtilMCapture(session);
         capture.SetFilter(DeviceName);
        for (uint i = 0; ; i++)         {
             PXCMGesture.ProfileInfo pinfo;
             sts = gesture.QueryProfile(i, out pinfo);
             if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
             sts = capture.LocateStreams(ref pinfo.inputs);
             if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
             sts = gesture.SetProfile(ref pinfo);
             if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) break;
         }
         if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
         {
             capture.Dispose();
             gesture.Dispose();
             session.Dispose();
             return;
         }
        var sd1 = new PXCMCapture.VideoStream.DataDesc.StreamDesc();
         sd1.format = PXCMImage.ColorFormat.COLOR_FORMAT_RGB24;
         sd1.sizeMin.width = sd1.sizeMax.width = 640;
         sd1.sizeMin.height = sd1.sizeMax.height = 480;
         //var sd2 = new PXCMCapture.VideoStream.DataDesc.StreamDesc();
         //sd2.format = PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH;
         //sd2.sizeMin.width = sd2.sizeMax.width = 320;
         //sd2.sizeMin.height = sd2.sizeMax.height = 240;
         var req = new PXCMCapture.VideoStream.DataDesc();
         req.streams[0] = sd1;
         //req.streams[1] = sd2;
        sts = capture.LocateStreams(ref req);
                     while (_running)
         {
             var images = new PXCMImage[PXCMCapture.VideoStream.STREAM_LIMIT];
             var sps = new PXCMScheduler.SyncPoint[2];
            // 1. read from IO device
             sts = capture.ReadStreamAsync(images, out sps[0]); // <<< exception here
             if (sts == pxcmStatus.PXCM_STATUS_DEVICE_LOST) continue;
             if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
            // 2. sync to ensure that IO operation is completed
             sts = PXCMScheduler.SyncPoint.SynchronizeEx(sps);
             if (sts == pxcmStatus.PXCM_STATUS_DEVICE_LOST) continue;
             if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
            // 3. preprocess images
             if (DoPreProcessImages)
             {
                 PreProcessImages(capture, images, session);
             }
             // 4. hand images over to finger tracking module
             sts = gesture.ProcessImageAsync(images, out sps[1]);
             if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
            // 5. display images
                            UpdateImage(capture.QueryImage(images, PXCMImage.ImageType.IMAGE_TYPE_DEPTH), _depthImage);
             //UpdateImage(capture.QueryImage(images, PXCMImage.ImageType.IMAGE_TYPE_COLOR), _colorImage);
             UpdateNodes(gesture);
             PXCMImage image;
             if (gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out image) >=  pxcmStatus.PXCM_STATUS_NO_ERROR)
             {
                 UpdateImage(image, _labelImage);
                 image.Dispose();
             }
            PXCMImage.Dispose(images);
             PXCMScheduler.SyncPoint.Dispose(sps);
         }
        capture.Dispose();
         gesture.Dispose();
         session.Dispose();
        if (_running)
         {
             Stop();
         }
     } }

at UtilCapture.ReadStreamAsync(UtilCapture* , PXCImage** images, SyncPoint** sp)   
at UtilMCapture.ReadStreamAsync(PXCMImage[] images, SyncPoint& sp)   
at xxx.ExtendedProcessing.Capture() in c:ProjektexxxExtendedProcessing.cs:line 73   
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   
at System.Threading.ThreadHelper.ThreadStart()

Can somebody please explain me what i'm doing wrong?

rgds Sven

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I will verify it and will be back to you soon. Thanks!

Login to leave a comment.