static void Main(string[] args) { Operator op = new Operator(640,480,280); try { op.FindMiddleByPath("D:\\5.jpg"); } catch (TextException ex) { Console.WriteLine(ex.Message); Console.Read(); } }
private async void _camera_PreviewFrameAvailable(object sender, PreviewArrivedEventArgs e) { try { _stream = new MemoryStream(e.Frame.ImageStream); if (null == _stream) return; await Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { try { _bitmapImage = new BitmapImage(); _bitmapImage.BeginInit(); _bitmapImage.StreamSource = _stream; // Copy stream to local _bitmapImage.EndInit(); cam.Source = _bitmapImage; observed = new Image<Bgr, byte>(UiHandler.Bmimg2Bitmap(_bitmapImage)); Operator op = new Operator(640, 480, 280); status.Content= op.FindMiddleByImg(observed); UiHandler.show_Image(cam_right, op.GetRoadImg()); } catch (Exception) { // ignored } })); } catch (Exception) { // ignored } }