示例#1
0
        public HandsRecognition(int mod)
        {
			try
			{
				session = PXCMSession.CreateInstance();
				mode = mod;
				if (mod == 0)
				{
					rightcp = new checkPiano();
					leftcp = new checkPiano();
				}
				else if (mod == 1)
				{
					rightcp = new checkDrum();
					leftcp = new checkDrum();
				}

				_disconnected = false;

				instance = session.CreateSenseManager();
				if (instance == null)
				{
					MessageBox.Show("Failed creating SenseManager", "OnAlert");
					return;
				}

				/* Set Module */
				pxcmStatus status = instance.EnableHand();//form.GetCheckedModule());
				handAnalysis = instance.QueryHand();

				if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || handAnalysis == null)
				{
					MessageBox.Show("Failed Loading Module", "OnAlert");
					return;
				}

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

				handData = handAnalysis.CreateOutput();
			}
			catch
			{
				MessageBox.Show("Init Failed.");
				Environment.Exit(0);
			}
        }
示例#2
0
        public override int checkNote(MYPoint pt)//bool oneNote)
        {
            p = pt;
            ps.Add(pt);
            isClick();
            int num = isContain();
            if (getPress() && oneNote && num != 0)
            {
                oneNote = false;
                return num;
            }

            checkPiano tcp = new checkPiano();
            if (ps.Count() > 1)
            {
                tcp = new checkPiano(ps[ps.Count() - 2]);
                tcp.isClick();
                if (!this.getPress() && tcp.getPress())
                {
                    oneNote = true;
                    ps.Clear();
                }
            }
            return 0;
        }