コード例 #1
0
 public ZeroMQConnection(ZeroMQ.ZContext ctx = null)
 {
     _context = ctx ?? new ZeroMQ.ZContext();
     _socket  = new ZSocket(_context, ZSocketType.REP);
 }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            DateTime now = DateTime.Now;

            // Set the icon
            Uri iconUri = new Uri("logo1.ico", UriKind.RelativeOrAbsolute);

            this.Icon = BitmapFrame.Create(iconUri);

            // Warn about the liability
            Liability liab = new Liability();

            liab.Icon = BitmapFrame.Create(iconUri);
            liab.ShowDialog();

            if (!liab.continue_pressed)
            {
                this.Close();
                return;
            }

            BitmapImage src = new BitmapImage();

            src.BeginInit();
            src.UriSource   = new Uri("logo1.png", UriKind.RelativeOrAbsolute);
            src.CacheOption = BitmapCacheOption.OnLoad;
            src.EndInit();

            logoLabel.Source = src;

            // First make the user chooose a webcam
            OpenFaceOffline.CameraSelection cam_select = new OpenFaceOffline.CameraSelection();
            cam_select.Icon = BitmapFrame.Create(iconUri);

            if (!cam_select.no_cameras_found)
            {
                cam_select.ShowDialog();
            }

            if (cam_select.camera_selected)
            {
                // Create the capture device
                int cam_id = cam_select.selected_camera.Item1;
                img_width  = cam_select.selected_camera.Item2;
                img_height = cam_select.selected_camera.Item3;

                UtilitiesOF.SequenceReader reader = new UtilitiesOF.SequenceReader(cam_id, img_width, img_height);

                if (reader.IsOpened())
                {
                    // Create the ZeroMQ context for broadcasting the results
                    zero_mq_context = ZeroMQ.ZContext.Create();
                    zero_mq_socket  = new ZSocket(zero_mq_context, ZeroMQ.ZSocketType.PUB);

                    // Bind on localhost port 5000
                    zero_mq_socket.Bind("tcp://127.0.0.1:5000");

                    processing_thread      = new Thread(() => VideoLoop(reader));
                    processing_thread.Name = "Webcam processing";
                    processing_thread.Start();
                }
                else
                {
                    string           messageBoxText = "Failed to open a webcam";
                    string           caption        = "Webcam failure";
                    MessageBoxButton button         = MessageBoxButton.OK;
                    MessageBoxImage  icon           = MessageBoxImage.Warning;

                    // Display message box
                    MessageBox.Show(messageBoxText, caption, button, icon);
                    this.Close();
                }

                // Create an overlay image for display purposes
                webcam_img = new OpenFaceOffline.OverlayImage();

                webcam_img.SetValue(Grid.RowProperty, 1);
                webcam_img.SetValue(Grid.ColumnProperty, 1);
                MainGrid.Children.Add(webcam_img);

                StartExperiment();
            }
            else
            {
                cam_select.Close();
                this.Close();
            }
        }
コード例 #3
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
 public static void Proxy(ZSocket frontend, ZSocket backend)
 {
     Proxy(frontend, backend, null);
 }
コード例 #4
0
ファイル: ZPollItems.cs プロジェクト: ym1100/MicroZero
 public static bool PollIn(this ZSocket socket, ZPollItem item, out ZMessage incoming, out ZError error, TimeSpan?timeout = null)
 {
     incoming = null;
     return(Poll(socket, item, ZPollEvent.In, ref incoming, out error, timeout));
 }
コード例 #5
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
        public static bool ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket capture, ZSocket control, out ZError error)
        {
            error = ZError.None;

            while (-1 == zmq.proxy_steerable(frontend.SocketPtr, backend.SocketPtr, capture == null ? IntPtr.Zero : capture.SocketPtr, control == null ? IntPtr.Zero : control.SocketPtr))
            {
                error = ZError.GetLastErr();

                if (error == ZError.EINTR)
                {
                    error = default(ZError);
                    continue;
                }
                return(false);
            }
            return(true);
        }
コード例 #6
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
        public static void ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket capture, ZSocket control)
        {
            ZError error;

            if (!ProxySteerable(frontend, backend, capture, control, out error))
            {
                throw new ZException(error);
            }
        }
コード例 #7
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
 public static bool ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket control, out ZError error)
 {
     return(ProxySteerable(frontend, backend, null, control, out error));
 }
コード例 #8
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
 public static void ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket control)
 {
     ProxySteerable(frontend, backend, null, control);
 }
コード例 #9
0
ファイル: ZContext.cs プロジェクト: xulittle/clrzmq4
 public static bool Proxy(ZSocket frontend, ZSocket backend, out ZError error)
 {
     return(Proxy(frontend, backend, null, out error));
 }