AcquireFrame() 공개 메소드

public AcquireFrame ( bool wait ) : bool
wait bool
리턴 bool
예제 #1
0
    void Update()
    {
        if (pp != null)
        {
            if (pp.AcquireFrame(false))
            {
                print(pp.IsDisconnected()?"Camera unplugged? Please replugin the camera to the same USB port. Thanks.":null);

                int[] labels = new int[3] {
                    0, 256, 256
                };
                pp.QueryLabelMap(labelmap, labels);
                Color32[] pixels = handImage.GetPixels32(0);
                for (int y = 0, yy1 = 0, yy2 = (handImage.height - 1) * handImage.width; y < handImage.height; y++, yy1 += handImage.width, yy2 -= handImage.width)
                {
                    for (int x = 0; x < handImage.width; x++)
                    {
                        int pixel = labelmap[yy1 + x];
                        pixels[yy2 + (handImage.width - 1 - x)] = new Color32(0, 0, 0, (byte)((pixel == labels[1] || pixel == labels[2])?160:0));
                    }
                }
                handImage.SetPixels32(pixels, 0);
                handImage.Apply();

                pp.QueryGeoNode(PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, handData[0]);
                pp.QueryGeoNode(PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, handData[1]);

                pp.QueryGeoNode(PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, mouse_nodes[0]);
                pFingerIndex = GetGeonodeCoordinate(mouse_nodes, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, PXCMGesture.GeoNode.Label.LABEL_FINGER_INDEX);
                pFingerThumb = GetGeonodeCoordinate(mouse_nodes, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB);
                pHandMiddle  = GetGeonodeCoordinate(mouse_nodes, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, PXCMGesture.GeoNode.Label.LABEL_HAND_MIDDLE);

                pMiddleThumbIndex = new Vector2((pFingerThumb.x + pFingerIndex.x) / 2, (pFingerThumb.y + pFingerIndex.y) / 2);
                isMouseDown       = (DistanceBetweenPoints(pFingerThumb, pFingerIndex) == 0) ? true : false;

                Vector3 worldPositionThumb      = Camera.main.ScreenToWorldPoint(new Vector3(pFingerThumb.x, pFingerThumb.y, 1));
                Vector3 worldPositionIndex      = Camera.main.ScreenToWorldPoint(new Vector3(pFingerIndex.x, pFingerIndex.y, 1));
                Vector3 worldPositionHandMiddle = Camera.main.ScreenToWorldPoint(new Vector3(pHandMiddle.x, pHandMiddle.y, 1));

//				options.SetMessage("ImagePosition of Thumb Finger : (" + pFingerThumb.x + ", " + pFingerThumb.y + ")\n\n" +
//                    "ImagePosition of Index Finger : (" + pFingerIndex.x + ", " + pFingerIndex.y + ")\n\n" +
//					"ImagePosition of middle in mittened hand : (" + pHandMiddle.x + ", " + pHandMiddle.y + ")\n\n" +
//                    "Distance between Thumb Finger and Index Finger : " + DistanceBetweenPoints(pFingerThumb, pFingerIndex) + "\n\n" +
//					"WorldPosition of Thumb Finger : (" + worldPositionThumb.x + ", " + worldPositionThumb.y + ")\n\n" +
//					"WorldPosition of Index Finger : (" + worldPositionIndex.x + ", " + worldPositionIndex.y + ")\n\n" +
//					"WorldPosition of middle in mittened hand : (" + worldPositionHandMiddle.x + ", " + worldPositionHandMiddle.y);

                pp.ReleaseFrame();
            }
        }
    }
예제 #2
0
 private void ThreadRoutine()
 {
     while (pp.AcquireFrame(true) && !stop)
     {
         PXCMVoiceRecognition.Recognition rdata;
         if (pp.QueryVoiceRecognized(out rdata))
         {
             lock (cs) {
                 line         = "voice (label=" + rdata.label + ", text=" + rdata.dictation + ")";
                 voiceCommand = rdata.dictation;
             }
         }
         pp.ReleaseFrame();
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (pp == null)
        {
            return;
        }
        if (!pp.AcquireFrame(false))
        {
            return;
        }

        //IplImage frame = Cv.QueryFrame(capture);
        if (rgbTexture != null)
        {
            Debug.Log("rgb not null");
            if (pp.QueryRGB(rgbTexture))
            {
                Debug.Log("query rgb done");
                //rgbTexture.Apply();
                Debug.Log("de pixelo: " + rgbTexture.GetPixels()[0]);

                IplImage frame = Texture2DtoIplImage(rgbTexture);


                using (IplImage img = Cv.CloneImage(frame))
                    using (IplImage smallImg = new IplImage(new CvSize(Cv.Round(img.Width / Scale), Cv.Round(img.Height / Scale)), BitDepth.U8, 1))
                    {
                        using (IplImage gray = new IplImage(img.Size, BitDepth.U8, 1))
                        {
                            Cv.CvtColor(img, gray, ColorConversion.BgrToGray);
                            Cv.Resize(gray, smallImg, Interpolation.Linear);
                            Cv.EqualizeHist(smallImg, smallImg);
                        }

                        using (CvMemStorage storage = new CvMemStorage())
                        {
                            storage.Clear();


                            CvSeq <CvAvgComp> faces = Cv.HaarDetectObjects(smallImg, cascade, storage, ScaleFactor, MinNeighbors, 0, new CvSize(64, 64));


                            for (int i = 0; i < faces.Total; i++)
                            {
                                CvRect  r      = faces[i].Value.Rect;
                                CvPoint center = new CvPoint
                                {
                                    X = Cv.Round((r.X + r.Width * 0.5) * Scale),
                                    Y = Cv.Round((r.Y + r.Height * 0.5) * Scale)
                                };
                                int radius = Cv.Round((r.Width + r.Height) * 0.25 * Scale);
                                img.Circle(center, radius, colors[i % 8], 3, LineType.AntiAlias, 0);
                            }

                            if (faces.Total > 0)
                            {
                                CvRect r = faces[0].Value.Rect;
                                //facepos = new Vector2((r.X + r.Width / 2.0f) / CAPTURE_WIDTH, (r.Y + r.Height / 2.0f) / CAPTURE_HEIGHT);
                            }
                        }
                        Cv.ShowImage("FaceDetect", img);
                    }
            }             // endif queryirasimage
            else
            {
                Debug.Log("failoo");
            }
        }         // endif rgbTexture !null
        else
        {
            Debug.Log("rgb NULL");
        }
        pp.ReleaseFrame();
    }