示例#1
0
        public virtual int checkNote(MYPoint pt)
        {
            p = pt;
            ps.Add(pt);
            isClick();
            int num = isContain();
            if (getPress() && oneNote && num != 0)
            {
                oneNote = false;
                return num;
            }

            checkPoint tcp = new checkPoint();
            if (ps.Count() > 1)
            {
                tcp = new checkPoint(ps[ps.Count() - 2]);
                tcp.isClick();
                if (!this.getPress() && tcp.getPress())
                {
                    oneNote = true;
                    ps.Clear();
                }
            }
            return 0;
        }
示例#2
0
        /* Using PXCMSenseManager to handle data */
        public void SimplePipeline(int mod)
        {
            mode = mod;
            if (mod == 0)
            {
                rightcp = new checkPiano();
                leftcp = new checkPiano();
            }
            else if (mod == 1)
            {
                rightcp = new checkDrum();
                leftcp = new checkDrum();
            }

            bool liveCamera = false;

            bool flag = true;
            PXCMSenseManager instance = null;
            _disconnected = false;
            instance = Program.session.CreateSenseManager();
            if (instance == null)
            {
                Console.WriteLine("Failed creating SenseManager");
                return;
            }
                        
            /* Set Module */
            pxcmStatus status = instance.EnableHand();//form.GetCheckedModule());
            PXCMHandModule handAnalysis = instance.QueryHand();

            if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || handAnalysis == null)
            {
                Console.WriteLine("Failed Loading Module");
                return;
            }

            PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler();
            handler.onModuleProcessedFrame = new PXCMSenseManager.Handler.OnModuleProcessedFrameDelegate(OnNewFrame);

            PXCMHandConfiguration handConfiguration = handAnalysis.CreateActiveConfiguration();
            PXCMHandData handData = handAnalysis.CreateOutput();

            if (handConfiguration == null)
            {
                Console.WriteLine("Failed Create Configuration");
                return;
            }

            if (handData == null)
            {
                Console.WriteLine("Failed Create Output");
                return;
            }
           
            if (handAnalysis != null && instance.Init(handler) == pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                PXCMCapture.DeviceInfo dinfo;

                PXCMCapture.Device device = instance.captureManager.device;
                if (device != null)
                {
                    device.QueryDeviceInfo(out dinfo);
                    _maxRange = device.QueryDepthSensorRange().max;
                }

                if (handConfiguration != null)
                {
                    handConfiguration.EnableAllAlerts();
                    handConfiguration.EnableSegmentationImage(true);

                    handConfiguration.ApplyChanges();
                    handConfiguration.Update();
                }
                Console.WriteLine("PXCSenseManager Initializing OK\n");
                int frameCounter = 0;
                int frameNumber = 0;

                //for thread 
                //ThreadPlay tp = new ThreadPlay();
                //int t = tp.play("music.txt");
                
                while (!mon.stop)
                {
                    
                    if (instance.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    frameCounter++;

                    if (!DisplayDeviceConnection(!instance.IsConnected()))
                    {

                        if (handData != null)
                        {
                            handData.Update();
                        }

                        PXCMCapture.Sample sample = instance.QueryHandSample();
                        if (sample != null && sample.depth != null)
                        {
                            if (handData != null)
                            {
                                frameNumber = liveCamera ? frameCounter : instance.captureManager.QueryFrameIndex();

                                DisplayJoints(handData);
                                DisplayGesture(handData, frameNumber);
                            }
                        }
                    }
                    instance.ReleaseFrame();
                }
            }
            else
            {
                Console.WriteLine("Init Failed");
                flag = false;
            }
            foreach (PXCMImage pxcmImage in m_images)
            {
                pxcmImage.Dispose();
            }


            //store as a file
            sr.Close();
            //string filename = System.Guid.NewGuid().ToString() + ".txt";
            eventReceiver2.ClickStore("temp.txt");

            // Clean Up
            if (handData != null) handData.Dispose();
            if (handConfiguration != null) handConfiguration.Dispose();
            instance.Close();
            instance.Dispose();

            if (flag)
            {
                Console.WriteLine("Stopped");
            }
        }