void ProcessImage(PXCMImage depth) { if (depth == null) { return; } /* Returns the image properties. */ info = depth.QueryInfo(); /* Set the pixel format*/ info.format = PXCMImage.PixelFormat.PIXEL_FORMAT_Y8; /* Perform blob extraction on the specified depth image.*/ m_blob.ProcessImage(depth); /* Create an instance of the PXC[M]Image interface to manage image buffer access. */ new_image = mask_utils.PipelineManager.session.CreateImage(info); results = m_blob.QueryBlobData(0, new_image, out blobData[0]); if (results == pxcmStatus.PXCM_STATUS_NO_ERROR) { /* Get all blob points */ blobPointsPos = new Vector2[6]; blobPointsPos[0] = new Vector2(blobData[0].centerPoint.x * -1, blobData[0].centerPoint.y * -1); blobPointsPos[1] = new Vector2(blobData[0].topPoint.x * -1, blobData[0].topPoint.y * -1); blobPointsPos[2] = new Vector2(blobData[0].bottomPoint.x * -1, blobData[0].bottomPoint.y * -1); blobPointsPos[3] = new Vector2(blobData[0].leftPoint.x * -1, blobData[0].leftPoint.y * -1); blobPointsPos[4] = new Vector2(blobData[0].rightPoint.x * -1, blobData[0].rightPoint.y * -1); blobPointsPos[5] = new Vector2(blobData[0].closestPoint.x * -1, blobData[0].closestPoint.y * -1); /* Sert blob points colors*/ blobPointColors = new Color[6]; blobPointColors[0] = Color.blue; blobPointColors[1] = Color.yellow; blobPointColors[2] = Color.yellow; blobPointColors[3] = Color.yellow; blobPointColors[4] = Color.yellow; blobPointColors[5] = Color.green; DisplayPoints(); results = m_contour.ProcessImage(new_image); if (results == pxcmStatus.PXCM_STATUS_NO_ERROR && m_contour.QueryNumberOfContours() > 0) { /* Retrieve the detected contour points.*/ results = m_contour.QueryContourData(0, out pointOuter[0]); if (results == pxcmStatus.PXCM_STATUS_NO_ERROR) { if (pointOuter[0] != null && pointOuter[0].Length > 0) { DisplayContour(pointOuter[0], 0); } } } } new_image.Dispose(); }
void ProcessImage(PXCMImage depth) { if (depth == null) { return; } /* Returns the image properties. */ info = depth.QueryInfo(); /* Set the pixel format*/ info.format = PXCMImage.PixelFormat.PIXEL_FORMAT_Y8; /* Perform blob extraction on the specified depth image.*/ m_blob.ProcessImage(depth); /* Create an instance of the PXC[M]Image interface to manage image buffer access. */ new_image = mask_utils.PipelineManager.session.CreateImage(info); int blobCount = m_blob.QueryNumberOfBlobs(); /* To store all blob points */ blobPointsPos = new List <Vector2>(); /* To store all contour points */ countourPoints = new List <PXCMPointI32>(); for (int i = 0; i < blobCount; i++) { results = m_blob.QueryBlobData(i, new_image, out blobData[i]); if (results == pxcmStatus.PXCM_STATUS_NO_ERROR) { blobPointsPos.Add(new Vector2(blobData[i].centerPoint.x * -1, blobData[i].centerPoint.y * -1)); blobPointsPos.Add(new Vector2(blobData[i].topPoint.x * -1, blobData[i].topPoint.y * -1)); blobPointsPos.Add(new Vector2(blobData[i].bottomPoint.x * -1, blobData[i].bottomPoint.y * -1)); blobPointsPos.Add(new Vector2(blobData[i].leftPoint.x * -1, blobData[i].leftPoint.y * -1)); blobPointsPos.Add(new Vector2(blobData[i].rightPoint.x * -1, blobData[i].rightPoint.y * -1)); blobPointsPos.Add(new Vector2(blobData[i].closestPoint.x * -1, blobData[i].closestPoint.y * -1)); DisplayPoints(); results = m_contour.ProcessImage(new_image); if (results == pxcmStatus.PXCM_STATUS_NO_ERROR && m_contour.QueryNumberOfContours() > 0) { results = m_contour.QueryContourData(0, out pointOuter[i]); DisplayContour(pointOuter[i], i); } } } new_image.Dispose(); }