public ZeroMQConnection(ZeroMQ.ZContext ctx = null) { _context = ctx ?? new ZeroMQ.ZContext(); _socket = new ZSocket(_context, ZSocketType.REP); }
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(); } }
public static void Proxy(ZSocket frontend, ZSocket backend) { Proxy(frontend, backend, null); }
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)); }
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); }
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); } }
public static bool ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket control, out ZError error) { return(ProxySteerable(frontend, backend, null, control, out error)); }
public static void ProxySteerable(ZSocket frontend, ZSocket backend, ZSocket control) { ProxySteerable(frontend, backend, null, control); }
public static bool Proxy(ZSocket frontend, ZSocket backend, out ZError error) { return(Proxy(frontend, backend, null, out error)); }