Inheritance: ISerializable
        public ProcessorState(
            Ref<System.Drawing.Rectangle> crop, Ref<System.Drawing.Rectangle> crop_values, 
            Ref<int> upper, Ref<int> lower,
            KinectData data_, short[] depth, byte[] depth_label_, byte[] rgb, byte[] bitmap_bits,
            Dictionary<Tuple<byte, byte, byte>, byte> nearest_cache_, Dictionary<byte, byte[]> label_color_,
            byte kBackgroundLabel, List<byte[]> centroid_colors_, List<byte> centroid_labels,
            Ref<bool> predict_on_enable_, Ref<bool>feature_extract_on_enable_,
            Ref<bool> overlay_start_, int kNoOverlay, int[] overlay_bitmap_bits_, int[] kEmptyOverlay,
            FeatureExtractionLib.FeatureExtraction feature, float[] predict_output_, int[] predict_labels_,
            List<IWebSocketConnection> all_sockets_,
            Filter.Step[] pipeline,
            HandGestureFormat hand_gesture_value_, RangeModeFormat range_mode_value_, int[] pool, byte[] bitmap_bits_copy, int radius, double density, int cluster_threshold_count)
        {
            this.crop = crop;
            this.crop_values = crop_values;
            this.upper = upper;
            this.lower = lower;
            this.data_ = data_;
            this.depth = depth;
            this.rgb = rgb;
            this.bitmap_bits_ = bitmap_bits;
            this.depth_label_ = depth_label_;
            this.bitmap_bits_copy_ = bitmap_bits_copy;
            
            this.nearest_cache_ = nearest_cache_;
            this.label_color_ = label_color_;
            this.kBackgroundLabel = kBackgroundLabel;
            this.centroid_colors_ = centroid_colors_;
            this.centroid_labels_ = centroid_labels;

            this.predict_on_enable_ = predict_on_enable_;
            this.feature_extract_on_enable_ = feature_extract_on_enable_;

            this.overlay_start_ = overlay_start_;
            this.kNoOverlay = kNoOverlay;
            this.overlay_bitmap_bits_ = overlay_bitmap_bits_;
            this.kEmptyOverlay = kEmptyOverlay;

            this.feature = feature;
            this.predict_output_ = predict_output_;
            this.predict_labels_ = predict_labels_;

            this.all_sockets_ = all_sockets_;
            this.pipeline = pipeline;

            this.hand_gesture_value_ = hand_gesture_value_;
            this.range_mode_value_ = range_mode_value_;

            this.pool_ = pool;
            this.radius_ = radius;
            this.density_ = density;
            this.cluster_threshold_count_ = cluster_threshold_count;

        }
        public DataFeed(DataSource source, RangeModeFormat setRangeModeValue)
        {
            this.source = source;
            RangeModeValue = setRangeModeValue;
            colorPixels = new byte[width * height * stride];
            depthPixels = new short[width * height];
            data = new KinectData();

            // Create the Kinect sensor anyway. Need for mapping depth to image.
            KinectSensor.KinectSensors.StatusChanged += (object sender, StatusChangedEventArgs e) =>
            {
                if (e.Sensor == sensor_ && e.Status != KinectStatus.Connected) SetSensor(null);
                else if ((sensor_ == null) && (e.Status == KinectStatus.Connected)) SetSensor(e.Sensor);
            };

            foreach (var sensor in KinectSensor.KinectSensors)
                if (sensor.Status == KinectStatus.Connected) SetSensor(sensor);
        }
 public void poll()
 {
     while (true)
     {
         data = datafeed.PullData(); 
         foreach (Processor p in processors) p.update(data);
     }
 }
       public void update(KinectData data)
        {
           /*
            DateTime ExecutionStartTime;
            DateTime ExecutionStopTime;
            TimeSpan ExecutionTime;
            ExecutionStartTime = DateTime.Now;
           */
           // Is data_ going to be nullifies? (Michael) 
           if (data_ == null)
            {
                this.data_ = data;
                this.depth_ = data.depth();
                this.rgb_ = data.color();

                PackageState();
            }

           DateTime ExecutionStartTime_new;
           DateTime ExecutionStopTime_new;
           TimeSpan ExecutionTime_new;
           ExecutionStartTime_new = DateTime.Now;

           #region Color Image
           DateTime ExecutionStartTime;
           DateTime ExecutionStopTime;
           TimeSpan ExecutionTime;
           ExecutionStartTime = DateTime.Now;
           
           process(Filter.Step.CopyColor);
           // pontentially dangerous due to creating a new thread here. This is because bitmap_bits will be used later

           color_bitmap_.Dispatcher.Invoke(new Action(() =>
           //           color_bitmap_.Dispatcher.BeginInvoke(new Action(() =>
            {
                color_bitmap_.WritePixels(new Int32Rect(0, 0, color_bitmap_.PixelWidth, color_bitmap_.PixelHeight),
                    bitmap_bits_, color_bitmap_.PixelWidth * sizeof(int), 0);
            }));

           ExecutionStopTime = DateTime.Now;
           ExecutionTime = ExecutionStopTime - ExecutionStartTime;
           SetContent.SetColorImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds)));
           #endregion
           
           #region Depth Image
           ExecutionStartTime = DateTime.Now;

           process(Filter.Step.CopyDepth);
           process(Filter.Step.CheckpointCurrentBitmap);
           process(Filter.Step.EnablePredict);
           process(Filter.Step.PerPixelClassificationOnEnable);
           process(Filter.Step.ShowOverlay);

           depth_bitmap_.Dispatcher.Invoke(new Action(() =>
           //           depth_bitmap_.Dispatcher.BeginInvoke(new Action(() =>
           {
               depth_bitmap_.WritePixels(new Int32Rect(0, 0, depth_bitmap_.PixelWidth, depth_bitmap_.PixelHeight),
                   bitmap_bits_, depth_bitmap_.PixelWidth * sizeof(int), 0);
           }));
           
           ExecutionStopTime = DateTime.Now;
           ExecutionTime = ExecutionStopTime - ExecutionStartTime;
           SetContent.SetDepthImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds) ));
           #endregion

           #region Pool Image
           ExecutionStartTime = DateTime.Now;

           process(Filter.Step.RestoreBitmap);
           process(Filter.Step.PoolingOnPerPixelClassification);
           process(Filter.Step.ShowOverlay);
           
           pool_bitmap_.Dispatcher.Invoke(new Action(() =>
           //pool_bitmap_.Dispatcher.BeginInvoke(new Action(() =>
           {
               pool_bitmap_.WritePixels(new Int32Rect(0, 0, pool_bitmap_.PixelWidth, pool_bitmap_.PixelHeight),
                   bitmap_bits_, pool_bitmap_.PixelWidth * sizeof(int), 0);
           }));
           
           
           ExecutionStopTime = DateTime.Now;
           ExecutionTime = ExecutionStopTime - ExecutionStartTime;
           SetContent.SetPoolImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds) ));
           #endregion

           ExecutionStopTime_new = DateTime.Now;
           ExecutionTime_new = ExecutionStopTime_new - ExecutionStartTime_new;
           Console.WriteLine("Use {0} ms for processing steps", ExecutionTime_new.TotalMilliseconds.ToString());
           SetContent.SetMetaInformation(String.Format("Use {0} ms for everything", Math.Round(ExecutionTime_new.TotalMilliseconds) ));
 
           /* 
           lock (bitmap_lock_)
            {
                if (paused) return;
                foreach (Filter.Step step in pipeline) process(step);
            }

            ExecutionStopTime_new = DateTime.Now;
            ExecutionTime_new = ExecutionStopTime_new - ExecutionStartTime_new;
            Console.WriteLine("Use {0} ms for processing steps", ExecutionTime_new.TotalMilliseconds.ToString());
            
           bitmap_.Dispatcher.Invoke(new Action(() =>
            {
                bitmap_.WritePixels(new Int32Rect(0, 0, bitmap_.PixelWidth, bitmap_.PixelHeight),
                    bitmap_bits_, bitmap_.PixelWidth * sizeof(int), 0);
            }));
            
            */ 
           /*
            ExecutionStopTime = DateTime.Now;
            ExecutionTime = ExecutionStopTime - ExecutionStartTime;
            Console.WriteLine("Use {0} ms for per frame update", ExecutionTime.TotalMilliseconds.ToString());          
             */ 
        }
       public void update(KinectData data)
        {
           // Is data_ going to be nullifies? (Michael) 
           if (data_ == null)
            {
                this.data_ = data;
                this.depth_ = data.depth();
                this.rgb_ = data.color();

                PackageState();
            }

            lock (bitmap_lock_)
            {
                if (paused) return;
                foreach (Filter.Step step in pipeline) process(step);
            }
            bitmap_.Dispatcher.Invoke(new Action(() =>
            {
                bitmap_.WritePixels(new Int32Rect(0, 0, bitmap_.PixelWidth, bitmap_.PixelHeight),
                    bitmap_bits_, bitmap_.PixelWidth * sizeof(int), 0);
            }));
          
        }