コード例 #1
0
 public MainWindow()
 {
     SetContent.SetMainWindowControler(this);
     InitializeComponent();
     // test
     SetContent.SetMetaInformation("Hi!!");
     m = new Manager(this);
     m.start();
 }
コード例 #2
0
        public Processor(Manager.ProcessorModeFormat processor_mode, MainWindow main_window_controller)
        {

            Debug.WriteLine("Start processor contruction");

            //this.manager = manager;
            processor_mode_ = processor_mode; 
            width = 640; height = 480;
            kColorStride = 4; kDepthStride = 1;
            // The following is commented because it's done by the XAML already
            /*
            // generate an control element: image
            image_ = new System.Windows.Controls.Image();
            image_.Width = width;
            image_.Height = height;
             */ 
            depth_label_ = new byte[width * height];
            cluster_threshold_count_ = 100;
            //main_window_controller.MetaLabel.Content = "Hey what's {0}";

            crop_values_ = new System.Drawing.Rectangle(
                Properties.Settings.Default.CropOffset.X,
                Properties.Settings.Default.CropOffset.Y,
                Properties.Settings.Default.CropSize.Width,
                Properties.Settings.Default.CropSize.Height);

            crop_ = new System.Drawing.Rectangle(0, 0, width - 1, height - 1);
            crop_ref_ = new Ref<System.Drawing.Rectangle>(() => crop_, val => { crop_ = val; });
            crop_val_ref_ = new Ref<System.Drawing.Rectangle>(() => crop_values_, val => { crop_values_ = val; });

            upper_ref_ = new Ref<int>(() => upper, val => { upper = val; });
            lower_ref_ = new Ref<int>(() => lower, val => { lower = val; });

            predict_on_enable_ref_ = new Ref<bool>(() => predict_on_enable_, val => { predict_on_enable_ = val; });
            feature_extract_on_enable_ref_ = new Ref<bool>(() => feature_extract_on_enable_, val => {feature_extract_on_enable_ = val; });

            overlay_start_ref_ = new Ref<bool>(() => overlayStart, val => { overlayStart = val; });

            overlayStart = false;
            kEmptyOverlay = new int[width * height * 4];
            for (int i = 0; i < kEmptyOverlay.Length; i++) kEmptyOverlay[i] = kNoOverlay;

            MinHueTarget = 360.0F;
            MaxHueTarget = 0.0F;
            MinSatTarget = 1F;
            MaxSatTarget = 0F;            
			            
            //bitmap_ = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
            
            color_bitmap_ = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
            depth_bitmap_ = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
            pool_bitmap_ = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
            bitmap_bits_ = new byte[640 * 480 * 4];
            bitmap_bits_copy_ = new byte[640 * 480 * 4];
            tmp_buffer_ = new byte[640 * 480 * 4];
            overlay_bitmap_bits_ = new int[640 * 480 * 4]; // overlay
            
            // Set property of the control elements, epsecially those images
            //image_.Source = bitmap_;
            main_window_controller.colorImage.Source = color_bitmap_;
            main_window_controller.depthImage.Source = depth_bitmap_;
            main_window_controller.poolImage.Source = pool_bitmap_;
            /*
            image_.MouseLeftButtonUp += ImageClick;
            image_.MouseRightButtonDown += StartDrag;
            image_.MouseMove += Drag;
            image_.MouseRightButtonUp += EndDrag;
            */ 
            SetCentroidColorAndLabel();
            
            FleckLog.Level = LogLevel.Debug;
            if (server == null)
            {
                server = new WebSocketServer("ws://localhost:8181");
                server.Start(socket =>
                {
                    socket.OnOpen = () =>
                    {
                        Console.WriteLine("Socket opened.");
                        all_sockets_.Add(socket);
                    };

                    socket.OnClose = () =>
                    {
                        Console.WriteLine("Socket closed.");
                        all_sockets_.Remove(socket);
                    };

                    socket.OnMessage = message =>
                    {
                        Console.WriteLine("Message received: {0}", message);
                        socket.Send(String.Format("Message received from you: {0}", message));
                    };
                });
            }

            listOfTransformedPairPosition = new List<int[]>(); // remember to clear.

            Debug.WriteLine("Pass processor setting");
        }
コード例 #3
0
 public MainWindow()
 {
     InitializeComponent();
     m = new Manager(this);
     m.start();
 }
コード例 #4
0
        public Processor(Manager manager)
        {

            Debug.WriteLine("Start processor contruction");
            this.manager = manager;
            width = 640; height = 480;
            kColorStride = 4; kDepthStride = 1;
            image_ = new System.Windows.Controls.Image();
            image_.Width = width;
            image_.Height = height;
            depth_label_ = new byte[width * height];

            crop_values_ = new System.Drawing.Rectangle(
                Properties.Settings.Default.CropOffset.X,
                Properties.Settings.Default.CropOffset.Y,
                Properties.Settings.Default.CropSize.Width,
                Properties.Settings.Default.CropSize.Height);

            crop_ = new System.Drawing.Rectangle(0, 0, width - 1, height - 1);
            crop_ref_ = new Ref<System.Drawing.Rectangle>(() => crop_, val => { crop_ = val; });
            crop_val_ref_ = new Ref<System.Drawing.Rectangle>(() => crop_values_, val => { crop_values_ = val; });

            upper_ref_ = new Ref<int>(() => upper, val => { upper = val; });
            lower_ref_ = new Ref<int>(() => lower, val => { lower = val; });

            predict_on_enable_ref_ = new Ref<bool>(() => predict_on_enable_, val => { predict_on_enable_ = val; });
            feature_extract_on_enable_ref_ = new Ref<bool>(() => feature_extract_on_enable_, val => {feature_extract_on_enable_ = val; });

            overlay_start_ref_ = new Ref<bool>(() => overlayStart, val => { overlayStart = val; });

            overlayStart = false;
            kEmptyOverlay = new int[width * height * 4];
            for (int i = 0; i < kEmptyOverlay.Length; i++) kEmptyOverlay[i] = kNoOverlay;

            MinHueTarget = 360.0F;
            MaxHueTarget = 0.0F;
            MinSatTarget = 1F;
            MaxSatTarget = 0F;            
			            
            bitmap_ = new WriteableBitmap(640, 480, 96, 96, PixelFormats.Bgr32, null);
            bitmap_bits_ = new byte[640 * 480 * 4];
            tmp_buffer_ = new byte[640 * 480 * 4];
            overlay_bitmap_bits_ = new int[640 * 480 * 4]; // overlay
            image_.Source = bitmap_;

            image_.MouseLeftButtonUp += ImageClick;
            image_.MouseRightButtonDown += StartDrag;
            image_.MouseMove += Drag;
            image_.MouseRightButtonUp += EndDrag;

            SetCentroidColorAndLabel();

            if (manager.ProcessorMode == Manager.ProcessorModeFormat.Michael)
                RangeModeValue = RangeModeFormat.Near;
            else if (manager.ProcessorMode == Manager.ProcessorModeFormat.Arun)
                RangeModeValue = RangeModeFormat.Default;
            
            FleckLog.Level = LogLevel.Debug;
            if (server == null)
            {
                server = new WebSocketServer("ws://localhost:8181");
                server.Start(socket =>
                {
                    socket.OnOpen = () =>
                    {
                        Console.WriteLine("Socket opened.");
                        all_sockets_.Add(socket);
                    };

                    socket.OnClose = () =>
                    {
                        Console.WriteLine("Socket closed.");
                        all_sockets_.Remove(socket);
                    };

                    socket.OnMessage = message =>
                    {
                        Console.WriteLine("Message received: {0}", message);
                        socket.Send(String.Format("Message received from you: {0}", message));
                    };
                });
            }

            listOfTransformedPairPosition = new List<int[]>(); // remember to clear.

            Debug.WriteLine("Pass processor setting");
        }