Beispiel #1
0
        private void DetectCamera()
        {
            CameraDiscovery cameraDiscover = new CameraDiscovery();

            if (cameraDiscover.UDPSocketSetup())
            {
                stateLabel.Content = "UDP Socket Ready";
                if (cameraDiscover.MSearch())
                {
                    stateLabel.Content = "Camera found.";

                    cameraResp = cameraDiscover.DeviceDescription();
                    _cameraCotrol.ControlCamera(cameraResp);
                    _imageControl.ImageTransfer(cameraResp);
                    if (_cameraCotrol.StartRecMode() == "{\"id\":1,\"result\":[0]}")
                    {
                        stateLabel.Content = "Camera Ready.";

                        _timer          = new DispatcherTimer();
                        _timer.Interval = TimeSpan.FromMilliseconds(100);
                        _timer.Tick    += _timer_Tick;

                        _timer.Start();
                    }
                }
            }
        }
        public DeviceDescriptor Connect(string address)
        {
            CameraDiscovery cameraDiscover = new CameraDiscovery();

            if (cameraDiscover.UDPSocketSetup())
            {
                if (cameraDiscover.MSearch())
                {
                    var cameraResp = cameraDiscover.DeviceDescription();
                    var info       = cameraDiscover.AnalyzeDescription(cameraResp);
                    var camera     = new SonyWifiCamera();
                    camera.Init(info.Endpoints["camera"]);
                    camera.DeviceName   = info.FriendlyName;
                    camera.SerialNumber = info.UDN;
                    DeviceDescriptor descriptor = new DeviceDescriptor {
                        WpdId = "SonyWifiCamera"
                    };
                    descriptor.CameraDevice = camera;
                    //cameraDevice.SerialNumber = StaticHelper.GetSerial(portableDevice.DeviceId);
                    return(descriptor);
                }
            }
            throw new Exception("No camera was found !");
        }