Esempio n. 1
0
        public void Test1()
        {
            var camFilter = new VirtualCamFilter();
            var tcpServer = new NetworkCamServer(NetworkCamPortNumber, camFilter);
            var startTask = tcpServer.StartAsync();

            Thread.Sleep(1000);

            var client = new NetworkCamDriverClient();

            client.Connect("127.0.0.1", NetworkCamPortNumber);


            var b     = new byte[1920 * 1080 * 4];
            var image = new Memory <byte>(b);

            //for (var i = 0; i < 10; i++)
            //{
            //    //Thread.Sleep(100);
            //    ConcurrentRandom.NextBytes(b);
            //    client.SendImage(image).Wait();
            //}

            Thread.Sleep(2_000);

            var b1 = VirtualCamFilter.FrontBuffer.ToArray();

            for (var i = 0; i < b.Length; i++)
            {
                Assert.Equal(b[i], b1[i]);
            }
            Assert.Equal(b, b1);
        }
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();


            _cam           = new KinectCam();
            _cam.NewImage += CamOnNewImage;

            _imageMixer = new ImageMixer(_cam.ColorFrameDescription.Width, _cam.ColorFrameDescription.Height);
            _imageMixer.BackgroundImage.LoadFile("Background.jpg");
            // TODO: Load background PNG file into BackgroundImage

            DataContext = _imageMixer;

            _client = new NetworkCamDriverClient();
            _client.Connect("127.0.0.1", 9090);
            // TODO: Not best way to connect :)
            Thread.Sleep(1000);

            // Start a separate thread for sending image
            _sendThread = new Thread(SendThreadLoop)
            {
                Name = "SendThread", IsBackground = true
            };
            _sendThread.Start();
        }