Exemplo n.º 1
0
        public void SetSelectedTrackingSuite(string newTrackingSuiteName)
        {
            lock (mutex)
            {
                if (newTrackingSuiteName == null)
                {
                    return;
                }
                if (newTrackingSuiteName.Equals(model.SelectedSuiteName))
                {
                    return;
                }

                CMSTrackingSuite oldTrackingSuite = this.model.SelectedSuite;
                if (oldTrackingSuite != null)
                {
                    //oldTrackingSuite.ToggleControl(false);
                    oldTrackingSuite.Clean();
                }

                model.SelectedSuiteName = newTrackingSuiteName;
                ToggleSetup(true);
                CMSTrackingSuite newTrackingSuite = this.model.SelectedSuite;
                newTrackingSuite.CMSTrackingSuiteAdapter = new CMSStandardTrackingSuiteAdapter(model, this, this.videoDisplay);
                newTrackingSuite.Init(model.FrameDims);
                newTrackingSuite.SendSuiteLogEvent();
                ReceiveMessagesFromTracker(null, null);
            }
        }
Exemplo n.º 2
0
        void ProcessFrameFromSource(System.Drawing.Bitmap [] frames)
        {
            lock (mutex)
            {
                if (CMSLogger.CanCreateLogEvent(false, false, true, "CMSLogProcessesEvent"))
                {
                    CMSLogProcessesEvent pEvent = new CMSLogProcessesEvent();
                    pEvent.CaptureProcesses();
                    CMSLogger.SendLogEvent(pEvent);
                }

                if (!controllerState.Equals(CMSState.CameraNotFound))
                {
                    foreach (Bitmap frame in frames)
                    {
                        frame.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    }

                    CMSTrackingSuite currentTracker = model.SelectedSuite;

                    if (currentTracker != null && frames != null && frames.Length > 0)
                    {
                        if (!currentTracker.Initialized)
                        {
                            Size[] sizes = new Size[frames.Length];
                            for (int i = 0; i < frames.Length; i++)
                            {
                                sizes[i] = new Size(frames[i].Width, frames[i].Height);
                            }
                            currentTracker.Init(sizes);
                        }


                        bool control = controllerState.Equals(CMSState.ControlTracking);

                        /*
                         * CMSLogExperimentFrameEvent logExpFrameEvent = null;
                         *
                         * if (ExperimentFrameSaver.IsExperimentFrameEnabled())
                         * {
                         *  if (ExperimentFrameSaver.CanSaveLogEvent())
                         *  {
                         *      logExpFrameEvent = new CMSLogExperimentFrameEvent(frames[0], currentTracker.Name, 0, 0);
                         *  }
                         * }*/

                        currentTracker.ProcessFrame(frames, control);

                        /*
                         * if (logExpFrameEvent != null)
                         * {
                         *  if (currentTracker.TrackingModule != null)
                         *  {
                         *      PointF curPoint = currentTracker.TrackingModule.ImagePoint;
                         *      logExpFrameEvent.X = (int)curPoint.X;
                         *      logExpFrameEvent.Y = (int)curPoint.Y;
                         *      ExperimentFrameSaver.SaveLogEvent(logExpFrameEvent);
                         *  }
                         * }*/

                        if (CMSLogger.CanCreateLogEvent(true, true, false, "CMSLogFrameEvent"))
                        {
                            CMSLogFrameEvent frameEvent = new CMSLogFrameEvent();
                            if (frameEvent != null)
                            {
                                frameEvent.SetImages(frames);
                                CMSLogger.SendLogEvent(frameEvent);
                            }
                        }
                    }

                    videoDisplay.SetVideo(frames);
                }
            }
        }