コード例 #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.Log("CameraServer: destroying duplicate: " + name);
         Destroy(gameObject);
     }
 }
コード例 #2
0
        public async Task CS_W_N_CreateFromMediaCaptureAsync()
        {
            Logger.LogMessage("Creating NullMediaCapture");
            var camera = NullMediaCapture.Create();
            await camera.InitializeAsync();

            Logger.LogMessage("Creating CameraServer");
            using (var server = await CameraServer.CreateFromMediaCaptureAsync(camera))
            {
                Assert.IsTrue(server.Port > 0);
                Assert.IsTrue(server.IPAddresses.Count >= 1);
            }
        }
コード例 #3
0
        public void CanProcessGetByCoordinatesCommandFromString()
        {
            var cmd = new GetByCoordinatesCommand()
            {
                Name = "get-by-coordinates", Parameters = new double[] { -73.532344350311, 45.600982799511 }
            };
            var strCmd = JsonConvert.SerializeObject(cmd);
            var target = new CameraServer();
            var val    = target.ProcessCommand(strCmd);

            Assert.IsNotNull(val);
            Assert.IsTrue(!string.IsNullOrEmpty(val));
        }
コード例 #4
0
        public MainPage()
        {
            this.InitializeComponent();
            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
            Window.Current.CoreWindow.KeyUp   += CoreWindow_KeyUp;

            keyHandler   = new KeyHandler(this);
            cameraServer = new CameraServer(UpdateImageAsync); // Not using MVVM here, directly using imperative code to change image source

            MovementController movementController = new MovementController();

            Task.Factory.StartNew(movementController.MonitorForMovement);

            StreamSocketListener listener = new StreamSocketListener();

            listener.BindEndpointAsync(new HostName(SELF_IP_ADDRESS), SELF_CAMERA_PORT); // It's okay to not use await here because we can register an event handler before the endpoint is bounded
            listener.ConnectionReceived += Listener_ConnectionReceived;
        }
コード例 #5
0
        public override void RobotInit()
        {
            System.Console.WriteLine("Hello, FRC2017!");
            System.Console.WriteLine("TrueMoe RobotCode 2017c");
            oi = new OI();
            FRC2017c.gyroSys.reset();
            chooser   = new WPILib.SmartDashboard.SendableChooser();
            camServer = CameraServer.Instance;
            nt        = NetworkTables.NetworkTable.GetTable("Forgiving/Vision");

            chooser.AddDefault("Center", new AutonomousCommand("center"));
            chooser.AddObject("turn Right", new AutonomousCommand("left"));
            chooser.AddObject("turn Left", new AutonomousCommand("right"));
            WPILib.SmartDashboard.SmartDashboard.PutData("Autonomous Mode", chooser);
            WPILib.SmartDashboard.SmartDashboard.PutString("Team", "5453");
            WPILib.SmartDashboard.SmartDashboard.PutNumber("AutonomousRushing1Delay", 900);
            FRC2017c.gyroSys.resetDisplacement();

            usbCamera = new UsbCamera("USB Camera 0", 0);
            usbCamera.SetFPS(12);
            camServer.StartAutomaticCapture(usbCamera);
        }
コード例 #6
0
    public void Capture()
    {
        isError = false;

        CameraServer.TakePicture((response) =>
        {
            if (response != null && response.code == 0)
            {
                CameraServer.DownloadPicture(response.data, (texture) => {
                    var rect   = new Rect(0, 0, texture.width, texture.height);
                    var sprite = Sprite.Create(texture, rect, Vector2.one / 2f);

                    pictureFrame.sprite = sprite;
                });
            }
            else
            {
                isError = true;
            }

            StartCoroutine(proceed());
        });
    }
コード例 #7
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // Start the camera and open a HTTP listener on port 31415
            m_server = await CameraServer.CreateAsync(31415);

            foreach (IPAddress ip in m_server.IPAddresses)
            {
                Log.Text += String.Format("Server IP address: {0} {1}\n", ip.Type.ToString(), ip.Name);
            }

            // Start an HTTP client, connect to port 31415, and display the video
            var client = await HttpMjpegCaptureSource.CreateFromUriAsync("http://localhost:31415/");

            Source.KeyUp += Source_KeyUp;

            // Log video playback events
            Preview.MediaFailed         += Preview_MediaFailed;
            Preview.MediaEnded          += Preview_MediaEnded;
            Preview.MediaOpened         += Preview_MediaOpened;
            Preview.CurrentStateChanged += Preview_CurrentStateChanged;

            // Start playback
            Preview.SetMediaStreamSource(client.Source);
        }