Exemple #1
0
        public async Task <ActionResult> AddCamera(string streamUrl, string streamType)
        {
            if (string.IsNullOrWhiteSpace(streamUrl))
            {
                return(null);
            }
            Debug.WriteLine($"Adding stream {streamUrl}");
            IVideoSource stream;

            switch (streamType)
            {
            case "jpeg":
                stream = new JPEGStream(streamUrl);
                break;

            case "mjpeg":
                stream = new MJPEGStream(streamUrl);
                break;

            default:
                return(null);
            }
            var(url, id) = await MJPEGStreamManager.AddStreamAsync(stream);

            return(Json(new { url, id }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
 public CameraHTTPClientJPEG(string url)
 {
     client = new JPEGStream(url);
     client.NewFrameBuffer   += client_NewFrameBuffer;
     client.NewFrame         += client_NewFrame;
     client.VideoSourceError += client_VideoSourceError;
 }
        // Open URL
        private void OpenURLFileItem_Click(object sender, System.EventArgs e)
        {
            URLForm form = new URLForm
            {
                Description = "Enter URL of an updating JPEG from a web camera:",
                URLs        = new string[]
                {
                    "http://61.220.38.10/axis-cgi/jpg/image.cgi?camera=1",
                    "http://212.98.46.120/axis-cgi/jpg/image.cgi?resolution=352x240",
                    "http://webcam.mmhk.cz/axis-cgi/jpg/image.cgi?resolution=320x240",
                    "http://195.243.185.195/axis-cgi/jpg/image.cgi?camera=1"
                }
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                // create video source
                JPEGStream jpegSource = new JPEGStream
                {
                    VideoSource = form.URL
                };

                // open it
                OpenVideoSource(jpegSource);
            }
        }
Exemple #4
0
 public JLvideo()
 {
     // create JPEG video source
     mStream = new AForge.Video.JPEGStream();
     // set NewFrame event handler
     mStream.NewFrame += new AForge.Video.NewFrameEventHandler(video_NewFrame);
     // instantiate AVI writer, use WMV3 codec
     mAviWriter = new AVIWriter("wmv3");
 }
        public Form1()
        {
            stream = new JPEGStream("http://192.168.1.104:8080/photo.jpg");
            //http://192.168.1.5:8080/shot.jpg?rnd=660075

            InitializeComponent();
            stream.NewFrame += stream_NewFrame;
            InitializeComponent();
        }
Exemple #6
0
        private void StartVideoPlayer()
        {
            StopVideoPlayer();
            JPEGStream videoStream = videoPlayer.VideoSource as JPEGStream;

            videoStream.Source   = Properties.Settings.Default.CameraURL;
            videoStream.Login    = Properties.Settings.Default.CameraUser;
            videoStream.Password = Properties.Settings.Default.CameraPassword;
            videoPlayer.Start();
        }
Exemple #7
0
 private void StartStreamingForOuter(JPEGStream _videoSource)
 {
     if (recOuterVdo == null || !recOuterVdo.RecordingStarted())
     {
         recOuterVdo = new VideoRecorder();
         recOuterVdo.SerialNumber = SerialNo.Text;
     }
     _videoSource.NewFrame += new NewFrameEventHandler(outervideo_NewFrame);
     _videoSource.Start();
 }
Exemple #8
0
        public CameraHTTPClientJPEG(string url, string login, string password)
        {
            client = new JPEGStream(url);
            if (!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password))
            {
                client.Login    = login;
                client.Password = password;
            }

            client.NewFrameBuffer   += client_NewFrameBuffer;
            client.NewFrame         += client_NewFrame;
            client.VideoSourceError += client_VideoSourceError;
        }
Exemple #9
0
        public test()
        {
            Form1      f1          = new Form1();
            JPEGStream jpegSource1 = new JPEGStream("http://" + f1.IPadd + "/jpg/image.jpg?resolution=320x240");

            jpegSource1.Login     = f1.UsrID;
            jpegSource1.Password  = f1.pswd;
            jpegSource1.NewFrame += new NewFrameEventHandler(jpegSource1_NewFrame);
            //source1.VideoSourceError += new VideoSourceErrorEventHandler(source1_VideoSourceError);
            jpegSource1.VideoSourceError += new VideoSourceErrorEventHandler(jpegSource1_VideoSourceError);
            Player1.VideoSource           = jpegSource1;

            InitializeComponent();
        }
Exemple #10
0
        private void OpenVideoPlayer()
        {
            StopVideoPlayer();

            JPEGStream cameraStream = new JPEGStream(
                Properties.Settings.Default.CameraURL);

            cameraStream.Login    = Properties.Settings.Default.CameraUser;
            cameraStream.Password = Properties.Settings.Default.CameraPassword;
            this.Cursor           = Cursors.WaitCursor;

            videoPlayer.VideoSource = cameraStream;
            videoPlayer.Start();;
            this.Cursor = Cursors.Default;
        }
Exemple #11
0
        private void button8_Click(object sender, EventArgs e)
        {
            AForge.Controls.VideoSourcePlayer playerControl = new VideoSourcePlayer();
            // set new frame event handler if we need processing of new frames
            playerControl.NewFrame += new VideoSourcePlayer.NewFrameHandler(playerControl_NewFrame);

            // create nested video source, for example JPEGStream
            AForge.Video.JPEGStream stream = new JPEGStream("some url");
            // create video source
            IVideoSource videoSource = new AsyncVideoSource(stream);

            // start playing it
            playerControl.VideoSource = videoSource;
            playerControl.Start( );
        }
Exemple #12
0
        private void OpenJpegUrlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new UrlForm();

            form.Description = "Enter URL of an updating JPEG from a web camera:";
            form.Urls        = new[]
            {
                "http://195.243.185.195/axis-cgi/jpg/image.cgi?camera=1"
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                var jpegSource = new JPEGStream(form.Url);
                OpenVideoSource(jpegSource);
            }
        }
    public test(string Ip, string Id, string Pass, string file, FileStream stream)
    {
        InitializeComponent();
        IPadd    = Ip;
        usrID    = Id;
        pswd     = Pass;
        filename = file;
        ws       = stream;
        JPEGStream jpegSource1 = new JPEGStream("http://" + IPadd + "/jpg/image.jpg?resolution=320x240");

        jpegSource1.Login            = usrID;
        jpegSource1.Password         = pswd;
        jpegSource1.NewFrame        += new NewFrameEventHandler(jpegSource1_NewFrame);
        source1.VideoSourceError    += new VideoSourceErrorEventHandler(source1_VideoSourceError);
        pegSource1.VideoSourceError += new VideoSourceErrorEventHandler(jpegSource1_VideoSourceError);
        Player1.VideoSource          = jpegSource1;
    }
Exemple #14
0
        private void SetCamera(int index)
        {
            if (videoSource != null)
            {
                videoSource.Stop();
                videoSource.NewFrame -= frameHandler;
            }

            var camera = Cache.Cameras[index];

            videoSource = new JPEGStream(camera.Url);

            frameHandler          = new NewFrameEventHandler(video_NewFrame);
            videoSource.NewFrame += frameHandler;
            videoSource.Start();

            RefreshPlaces();
        }
Exemple #15
0
        private void Initialize()
        {
            nonCash.Checked = true;
            this.helper     = new TKHelper();
            //textBox4.Text = this.helper.GetCurrentDatetime();
            try
            {
                stream           = new JPEGStream(liveCameraURL);
                stream.NewFrame += stream_NewFrame;
                stream.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Error : Cannot Connect to Live Camera. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LiveCamera.Image = Properties.Resources.no_image;
            }
            this.bni = new BNI(this);
            this.bni.RunMain();
            //this.StartTimer();

            // initialize vehicle type options
            try
            {
                comboBox1.Items.Add("- Pilih Tipe Kendaraan -");
                string masterDataFile = this.helper.GetApplicationExecutableDirectoryName() + "\\src\\master-data.json";
                using (StreamReader reader = new StreamReader(masterDataFile))
                {
                    string  json         = reader.ReadToEnd();
                    dynamic vehicleTypes = JsonConvert.DeserializeObject(json);
                    foreach (var types in vehicleTypes["VehicleTypes"])
                    {
                        comboBox1.Items.Add(types);
                    }
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Error : failed to fetch vehicle type data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #16
0
        // Open JPEG URL
        private void openJPEGURLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            URLForm form = new URLForm( );

            form.Description = "Enter URL of an updating JPEG from a web camera:";
            form.URLs        = new string[]
            {
                "http://195.243.185.195/axis-cgi/jpg/image.cgi?camera=1",
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                // create video source
                JPEGStream jpegSource = new JPEGStream(form.URL);

                // open it
                OpenVideoSource(jpegSource);
            }
        }
Exemple #17
0
 private void RecordOuter_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(SerialNo.Text))
     {
         MessageBox.Show("Enter serial number");
     }
     else
     {
         if ((bool)outerJpeg.IsChecked)
         {
             if (outerJpegStream != null && outerJpegStream.IsRunning)
             {
                 outerJpegStream.Stop();
                 recOuterVdo?.StopRecording();
                 RecordOuter.Content = "Record";
             }
             else
             {
                 outerJpegStream = new JPEGStream(outerIPCamUrl.Text);
                 StartStreamingForOuter(outerJpegStream);
                 RecordOuter.Content = "Stop";
             }
         }
         else // UseMJpegStream
         {
             if (outerMjpegStream != null && outerMjpegStream.IsRunning)
             {
                 outerMjpegStream.Stop();
                 recOuterVdo?.StopRecording();
                 RecordOuter.Content = "Record";
             }
             else
             {
                 outerMjpegStream = new MJPEGStream(outerIPCamUrl.Text);
                 StartStreamingForOuter(outerMjpegStream);
                 RecordOuter.Content = "Stop";
             }
         }
     }
 }
Exemple #18
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            // I'm making sure that filters actually contains something.
            if (rdoCaptureDevice.Checked && filters.Count > 0)
            // Chose to use a capture videoSource.
            {
                // create video source
                VideoCaptureDevice localSource = new VideoCaptureDevice();
                localSource.Source           = filters[deviceCombo.SelectedIndex].MonikerString;
                localSource.DesiredFrameSize = new Size(int.Parse(txtWidth.Text), int.Parse(txtHeight.Text));
                videoSource = localSource;
            }
            // Make sure that the text box contains a path.
            else if (!txtFileName.Text.Equals(String.Empty))             // Chose to load a movie.
            {
                // create video source
                AVIFileVideoSource fileSource = new AVIFileVideoSource();
                fileSource.Source = txtFileName.Text;
                videoSource       = fileSource;
            }
            else if (!txtMjpegUrl.Text.Equals(String.Empty))               // Chose to load a url.
            {
                MJPEGStream stream = new MJPEGStream(txtMjpegUrl.Text);
                videoSource = stream;
            }
            else if (!txtJpgUrl.Text.Equals(String.Empty))               // Chose to load a url.
            {
                JPEGStream stream = new JPEGStream(txtJpgUrl.Text);
                videoSource = stream;
            }
            else             // Unable to display.
            {
                showErrorMessage("No video source was chosen.");
                return;
            }

            DialogResult = DialogResult.OK;
            Hide();
        }
Exemple #19
0
        private void btnLink_Click(object sender, EventArgs e)
        {
            string url = comboBoxUrls.Text;

            if (url.Trim().Length == 0)
            {
                MessageBox.Show("请输入远程URL地址!");
                return;
            }
            switch (currentChoice)
            {
            case LINKTYPE.JPEG:
            {
                // create video source
                JPEGStream jpegSource = new JPEGStream(url);

                // open it
                OpenVideoSource(jpegSource);
                break;
            }

            case LINKTYPE.MJPEG:
            {
                // create video source
                MJPEGStream mjpegSource = new MJPEGStream(url);

                // open it
                OpenVideoSource(mjpegSource);
                break;
            }

            case LINKTYPE.RTPS:
            {
                vlcControl.Play(new Uri(url.Trim()));
                break;
            }
            }
        }
Exemple #20
0
 private void btnLinkJPEG_Click(object sender, EventArgs e)
 {
     if (!isJPEGOpen)
     {
         btnLinkJPEG.Text = "关闭";
         isJPEGOpen       = true;
         string url = comboBoxJPEG.Text;
         if (url.Trim().Length == 0)
         {
             MessageBox.Show("请输入远程URL地址!");
             return;
         }
         JPEGStream jpegSource = new JPEGStream(url);
         OpenVideoSource(jpegSource, videoSourcePlayerJPEG);
     }
     else
     {
         btnLinkJPEG.Text  = "连接";
         isJPEGOpen        = false;
         comboBoxJPEG.Text = "";
         CloseVideoSource(videoSourcePlayerJPEG);
     }
 }
Exemple #21
0
        // Connect to a PiRex bot
        private bool Connect( )
        {
            string strIpAddress = ipAddressBox.Text.Trim( );
            string strLogin     = loginBox.Text.Trim( );
            string strPassword  = passwordBox.Text.Trim( );
            bool   ret          = false;

            if ((string.IsNullOrEmpty(strIpAddress)) ||
                (!Regex.IsMatch(strIpAddress, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")))
            {
                ErrorBox("The specified IP address does not look valid.");
            }
            else
            {
                string baseAddress = string.Format("http://{0}:{1}", strIpAddress, portUpDown.Value);

                commandsThread.BaseAddress = baseAddress;
                commandsThread.Login       = strLogin;
                commandsThread.Password    = strPassword;

                commandsThread.Start( );

                ret = CheckPiRexConnectivity( );

                if (!ret)
                {
                    commandsThread.SignalToStop( );
                    commandsThread.WaitForStop( );
                }
                else
                {
                    if (videoModeCombo.SelectedIndex == 0)
                    {
                        MJPEGStream videoSource = new MJPEGStream(baseAddress + "/camera/mjpeg");

                        videoSource.Login    = strLogin;
                        videoSource.Password = strPassword;

                        videoSourcePlayer.VideoSource = videoSource;
                    }
                    else
                    {
                        JPEGStream videoSource = new JPEGStream(baseAddress + "/camera/jpeg");

                        videoSource.FrameInterval = 33;
                        videoSource.Login         = strLogin;
                        videoSource.Password      = strPassword;

                        videoSourcePlayer.VideoSource = videoSource;
                    }

                    videoSourcePlayer.Start( );

                    // start distance measurement thread
                    distanceLabel.Text = (distanceMeasurementAvailable) ? string.Empty : "Unavailable";
                    if (distanceMeasurementAvailable)
                    {
                        stopDistanceMeasurementEvent.Reset( );
                        distanceMeasurementThread = new Thread(new ThreadStart(DistanceMeasurementThreadHandler));
                        distanceMeasurementThread.Start( );
                    }

                    // start timer for reporting video FPS
                    fpsTimer.Start( );

                    connectionStatusLabel.Text = "Connected to PiRex bot";
                }
            }

            EnableConnectionControls(ret);

            return(ret);
        }
Exemple #22
0
        public void Enable()
        {
            _processing = true;

            switch (Camobject.settings.sourceindex)
            {
            case 0:
                var jpegSource = new JPEGStream(Camobject.settings.videosourcestring);
                if (Camobject.settings.frameinterval != 0)
                {
                    jpegSource.FrameInterval = Camobject.settings.frameinterval;
                }
                if (Camobject.settings.login != "")
                {
                    jpegSource.Login    = Camobject.settings.login;
                    jpegSource.Password = Camobject.settings.password;
                }
                //jpegSource.SeparateConnectionGroup = true;
                jpegSource.RequestTimeout = iSpyServer.Default.IPCameraTimeout;
                OpenVideoSource(jpegSource, false);
                break;

            case 1:
                var mjpegSource = new MJPEGStream(Camobject.settings.videosourcestring)
                {
                    Login          = Camobject.settings.login,
                    Password       = Camobject.settings.password,
                    RequestTimeout = iSpyServer.Default.IPCameraTimeout,
                    HttpUserAgent  = Camobject.settings.useragent
                };
                //mjpegSource.SeparateConnectionGroup = true;
                OpenVideoSource(mjpegSource, false);
                break;

            case 2:
                //var fileSource = new AVIFileVideoSource(Camobject.settings.videosourcestring);
                //OpenVideoSource(fileSource, true);
                break;

            case 3:
                string moniker = Camobject.settings.videosourcestring;

                var      videoSource = new VideoCaptureDevice(moniker);
                string[] wh          = Camobject.resolution.Split('x');
                var      sz          = new Size(Convert.ToInt32(wh[0]), Convert.ToInt32(wh[1]));
                var      vc          = videoSource.VideoCapabilities.Where(p => p.FrameSize == sz).ToList();
                if (vc.Count > 0)
                {
                    var vc2 = vc.FirstOrDefault(p => p.AverageFrameRate == Camobject.settings.framerate) ??
                              vc.FirstOrDefault();
                    videoSource.VideoResolution = vc2;
                }

                if (Camobject.settings.crossbarindex != -1 && videoSource.CheckIfCrossbarAvailable())
                {
                    var cbi =
                        videoSource.AvailableCrossbarVideoInputs.FirstOrDefault(
                            p => p.Index == Camobject.settings.crossbarindex);
                    if (cbi != null)
                    {
                        videoSource.CrossbarVideoInput = cbi;
                    }
                }

                OpenVideoSource(videoSource, true);
                break;

            case 4:
                Rectangle area = Rectangle.Empty;
                if (!String.IsNullOrEmpty(Camobject.settings.desktoparea))
                {
                    var i = Array.ConvertAll(Camobject.settings.desktoparea.Split(','), int.Parse);
                    area = new Rectangle(i[0], i[1], i[2], i[3]);
                }
                var desktopSource = new DesktopStream(Convert.ToInt32(Camobject.settings.videosourcestring), area)
                {
                    MousePointer = Camobject.settings.desktopmouse
                };
                if (Camobject.settings.frameinterval != 0)
                {
                    desktopSource.FrameInterval = Camobject.settings.frameinterval;
                }
                OpenVideoSource(desktopSource, false);
                break;

            case 5:
                var ks = new KinectStream(Nv("UniqueKinectId"), Convert.ToBoolean(Nv("KinectSkeleton")));
                OpenVideoSource(ks, true);
                break;
            }


            if (Camera != null)
            {
                if (!Camera.IsRunning)
                {
                    Camera.Start();
                }

                Camobject.settings.active = true;

                if (File.Exists(Camobject.settings.maskimage))
                {
                    Camera.Mask = Image.FromFile(Camobject.settings.maskimage);
                }
            }
            _frameCount             = 0;
            VideoSourceErrorState   = false;
            VideoSourceErrorMessage = "";
            Camobject.ftp.ready     = true;
            MainForm.NeedsSync      = true;

            Invalidate();
            _lastRun    = DateTime.Now.Ticks;
            _processing = false;
        }
Exemple #23
0
        public void StartPlay()
        {
            try
            {
                LoadCamInfo();
                if (IsPlaying)
                {
                    return;
                }

                // create video source
                switch (_CamType)
                {
                case 1:    //Local Device
                    CaptureDevice CD = new CaptureDevice();
                    CD.Login       = _UserName;
                    CD.Password    = _Pass;
                    CD.VideoSource = _IP;
                    // open it
                    IsPlaying = OpenVideoSource(CD);
                    break;

                case 2:    //Axis Cam
                    MJPEGStream mjpegSource = new MJPEGStream();
                    mjpegSource.Login       = _UserName;
                    mjpegSource.Password    = _Pass;
                    mjpegSource.VideoSource = _IP;
                    // open it
                    IsPlaying = OpenVideoSource(mjpegSource);
                    break;

                case 3:    //Local Device
                    JPEGStream JS = new JPEGStream();
                    JS.Login       = _UserName;
                    JS.Password    = _Pass;
                    JS.VideoSource = _IP;

                    // open it
                    IsPlaying = OpenVideoSource(JS);
                    break;

                case 4:    //Open File Movie
                    VideoFileSource VF = new VideoFileSource();
                    VF.Login       = _UserName;
                    VF.Password    = _Pass;
                    VF.VideoSource = _IP;

                    // open it
                    IsPlaying = OpenVideoSource(VF);
                    break;
                }

                if (IsPlaying)
                {
                    toolStripStatusLabel1.Text = "Playing";
                }

                //toolStripButton2.Enabled = IsPlaying ;
            }
            catch (ArgumentException ArgEx)
            {
                IsPlaying = false;
                //MessageBox.Show(ArgEx.Message, "Error");
                toolStripStatusLabel2.Text = "" + ArgEx.Message;
            }
            catch (Exception Ex)
            {
                //MessageBox.Show(Ex.Message, "Error");
                toolStripStatusLabel2.Text = "" + Ex.Message;
            }
            finally
            {
                toolStripButton1.Enabled = false;
                EnableBar(IsPlaying);
            }
        }
Exemple #24
0
		private bool ConnectToDevice(DeviceDescriptor _device)
		{
			log.DebugFormat("Connecting to {0}", _device.Name);
			
			Disconnect();
			bool created = false;
			if(_device.Network)
			{
				// Network Camera. Connect to last used url.
				// The user will have to open the dialog again if parameters have changed or aren't good.
				
				// Parse URL for inline username:password.
				string login = "";
				string pass = "";
				
				Uri networkCameraUrl = new Uri(_device.NetworkCameraUrl);
				if(!string.IsNullOrEmpty(networkCameraUrl.UserInfo))
				{
					string [] split = networkCameraUrl.UserInfo.Split(new Char [] {':'});
					if(split.Length == 2)
					{
						login = split[0];
						pass = split[1];
					}
				}
				
				if(_device.NetworkCameraFormat == NetworkCameraFormat.JPEG)
				{
					JPEGStream source = new JPEGStream(_device.NetworkCameraUrl);
					if(!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(pass))
					{
						source.Login = login;
						source.Password = pass;
					}
					
					m_VideoSource = source;
				}
				else
				{
					MJPEGStream source = new MJPEGStream(_device.NetworkCameraUrl);
					if(!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(pass))
					{
						source.Login = login;
						source.Password = pass;
					}
					
					m_VideoSource = source;
				}
				/*PreferencesManager.CapturePreferences.NetworkCameraFormat = _device.NetworkCameraFormat;
				PreferencesManager.CapturePreferences.NetworkCameraUrl = _device.NetworkCameraUrl;
				PreferencesManager.Save();*/
				
				created = true;
			}
			else
			{
				m_VideoSource = new VideoCaptureDevice(_device.Identification);
				VideoCaptureDevice captureDevice = m_VideoSource as VideoCaptureDevice;
				if(captureDevice != null)
				{
					if((captureDevice.VideoCapabilities != null) && (captureDevice.VideoCapabilities.Length > 0))
					{
						// Import the capabilities of the device.
						foreach(VideoCapabilities vc in captureDevice.VideoCapabilities)
						{
							DeviceCapability dc = new DeviceCapability(vc.FrameSize, vc.FrameRate);
							_device.Capabilities.Add(dc);
							
							log.Debug(String.Format("Device Capability. {0}", dc.ToString()));
						}
						
						DeviceCapability selectedCapability = null;
						
						// Check if we already know this device and have a preferred configuration.
						/*foreach(DeviceConfiguration conf in PreferencesManager.CapturePreferences.DeviceConfigurations)
						{
							if(conf.ID == _device.Identification)
							{							
								// Try to find the previously selected capability.
								selectedCapability = _device.GetCapabilityFromSpecs(conf.Capability);
								if(selectedCapability != null)
									log.Debug(String.Format("Picking capability from preferences: {0}", selectedCapability.ToString()));
							}
						}*/
	
						/*if(selectedCapability == null)
						{
							// Pick the one with max frame size.
							selectedCapability = _device.GetBestSizeCapability();
							log.Debug(String.Format("Picking a default capability (best size): {0}", selectedCapability.ToString()));
							PreferencesManager.CapturePreferences.UpdateDeviceConfiguration(_device.Identification, selectedCapability);
							PreferencesManager.Save();
						}*/
						
						_device.SelectedCapability = selectedCapability;
						captureDevice.DesiredFrameSize = selectedCapability.FrameSize;
						captureDevice.DesiredFrameRate = selectedCapability.Framerate;
						m_FrameSize = selectedCapability.FrameSize;
						m_FramesInterval = 1000 / (double)selectedCapability.Framerate;
					}
					else
					{
						captureDevice.DesiredFrameRate = 0;
					}
					
					created = true;
				}
			}
			
			if(created)
			{
				m_CurrentVideoDevice = _device;
				m_VideoSource.NewFrame += new NewFrameEventHandler( VideoDevice_NewFrame );
				m_VideoSource.VideoSourceError += new VideoSourceErrorEventHandler( VideoDevice_VideoSourceError );
				m_bIsConnected = true;
			}
			else
			{
				log.Error("Couldn't create the capture device.");
			}
			
			return created;
		}
Exemple #25
0
        public Main()
        {
            Log.Debug("Start");

            this.InitializeComponent();

            this._deviceConfigurationHelper = new DeviceConfigurationHelper();
            this._deviceConfiguration       = this._deviceConfigurationHelper.LoadConfig("default");

            using (var dialog = new ConfigDialog(_deviceConfiguration))
            {
                dialog.StartPosition = FormStartPosition.CenterParent;
                var dialogResult = dialog.ShowDialog(this);
                switch (dialogResult)
                {
                case DialogResult.OK:
                    this._deviceConfiguration = dialog.DeviceConfiguration;
                    this._deviceConfigurationHelper.SaveConfig("default", this._deviceConfiguration);
                    break;

                case DialogResult.Cancel:
                case DialogResult.None:
                    Task.Run(() => this.Invoke(o => o.Close()));
                    return;
                }
            }

            this.Text = $"Alturos PanTilt TestUI - v{Application.ProductVersion}";
            this.labelPositionPan.Text  = "Pan: ?,??";
            this.labelPositionTilt.Text = "Tilt: ?,??";

            this.SetConfigurationInfo();

            var startPtHeadCommunication = Task.Run(() => this.StartPanTiltCommunication());

            this.UpdateMousePanel();

            if (this._deviceConfiguration.CameraActive)
            {
                //Live Camera Image
                var url = $"http://{this._deviceConfiguration.CameraIpAddress}{this._deviceConfiguration.CameraJpegUrl}";

                IVideoSource source = new JPEGStream(url);
                ((JPEGStream)source).FrameInterval = 200;

                this._videoSourcePlayer = new Accord.Controls.VideoSourcePlayer
                {
                    VideoSource = source,
                    Dock        = DockStyle.Fill
                };
                this._videoSourcePlayer.Start();
                this.tabPageLiveView.Controls.Add(this._videoSourcePlayer);
            }
            else
            {
                //Visual Map
                this._cameraDrawEngine = new DrawEngine(4);
                this.UpdateCurrentImage();
                this.pictureBox_CameraPos.Visible = true;
            }

            startPtHeadCommunication.Wait();

            if (this._panTiltControl != null)
            {
                this.continiousMovementControl1.SetPanTiltControl(this._panTiltControl);
                this.fastMovementControl1.SetPanTiltControl(this._panTiltControl);
                this.absolutePositionControl1.SetPanTiltControl(this._panTiltControl);
                this.eneoUserControl1.SetPanTiltControl(this._panTiltControl);
                this.alturosUserControl1.SetPanTiltControl(this._panTiltControl);
                this.movementFloodControl1.SetPanTiltControl(this._panTiltControl);
                this.commandSequenceControl1.SetPanTiltControl(this._panTiltControl);
                this.alturosUserControl1.SetDeviceConfiguration(this._deviceConfiguration);
                this.feedbackAnalyzeControl1.SetPanTiltControl(this._panTiltControl);
                this._panTiltControl.PanTiltAbsolute(0, 0);
            }
        }
        private void timerLoad_Tick(object sender, EventArgs e)
        {
            istatistikGuncelle();


            // MessageBox.Show(otopark1.bosParkyerleri().ElementAt(0));
            toolStripLabel2.Text = otopark1.dolulukOrani(kapasite) + "/" + kapasite;
            if (Convert.ToInt16(otopark1.dolulukOrani(kapasite)) >= kapasite)
            {
                kameraGroup1.Enabled = false;
            }
            if (Convert.ToInt16(otopark1.dolulukOrani(kapasite)) >= kapasite)
            {
                kameraGroup1.Enabled = true;
            }

            try
            {
                if (kamera1Video != null)
                {
                    kamera1Video.Stop();
                }

                if (kamera2Video != null)
                {
                    kamera2Video.Stop();
                }

                labelFiligran1.Text = "zzz";
                labelFiligran2.Text = "";
                kamera1Video        = null;
                kamera2Video        = null;
            }
            catch
            {
                MessageBox.Show("hata");
            }

            try
            {
                aktifkameralar = kamera1.kameraGetirAktif();
                if (aktifkameralar[0].k_lokasyon == "1" && aktifkameralar[1].k_lokasyon == "0")
                {
                    Kamera tempKamera = new Kamera();
                    tempKamera        = aktifkameralar[0];
                    aktifkameralar[0] = aktifkameralar[1];
                    aktifkameralar[1] = tempKamera;
                }

                if (aktifkameralar[0] != null)
                {
                    kamera1           = (Kamera)aktifkameralar[0];
                    kameraGroup1.Text = kamera1.k_adi;


                    kamera1Video = new JPEGStream(kamera1.k_url.ToString());

                    labelFiligran1.Text = aktifkameralar[0].k_filigran;

                    kamera1Video.NewFrame   += kamera1Video_NewFrame;
                    kamera1LoadingLabel.Text = "";

                    if (CheckURLValid(aktifkameralar[0].k_url))
                    {
                        labelFiligran1.Visible = true;
                        kamera1Video.Start();
                        timerKamera1.Start();
                    }
                    else
                    {
                        pictureBoxKamera1.Image  = Properties.Resources.connecting;
                        labelFiligran1.Visible   = false;
                        kamera1LoadingLabel.Text = "'" + aktifkameralar[0].k_adi + "' isimli kameraya bağlanılıyor.";
                    }
                }

                if (aktifkameralar[1] != null)
                {
                    kamera2                  = (Kamera)aktifkameralar[1];
                    kameraGroup2.Text        = kamera2.k_adi;
                    kamera2Video             = new JPEGStream(kamera2.k_url.ToString());
                    labelFiligran2.Text      = aktifkameralar[1].k_filigran;
                    kamera2Video.NewFrame   += kamera2Video_NewFrame;
                    kamera2LoadingLabel.Text = "";
                    if (CheckURLValid(aktifkameralar[1].k_url))
                    {
                        //   MessageBox.Show("");
                        labelFiligran2.Visible = true;
                        kamera2Video.Start();
                        timerKamera2.Start();
                    }
                    else
                    {
                        pictureboxKamera2.Image  = Properties.Resources.connecting;
                        labelFiligran2.Visible   = false;
                        kamera2LoadingLabel.Text = "'" + aktifkameralar[1].k_adi + "' isimli kameraya bağlanılıyor.";
                    }
                }
            }
            catch
            {
            }
        }
Exemple #27
0
        public Main()
        {
            this.InitializeComponent();

            this._deviceConfigurationHelper = new DeviceConfigurationHelper();
            this._deviceConfiguration       = this._deviceConfigurationHelper.LoadConfig("default");

            using (var dialog = new ConfigDialog(_deviceConfiguration))
            {
                dialog.StartPosition = FormStartPosition.CenterParent;
                var dialogResult = dialog.ShowDialog(this);
                switch (dialogResult)
                {
                case DialogResult.OK:
                    this._deviceConfiguration = dialog.DeviceConfiguration;
                    this._deviceConfigurationHelper.SaveConfig("default", this._deviceConfiguration);
                    break;

                case DialogResult.Cancel:
                case DialogResult.None:
                    Task.Run(() => this.Invoke(o => o.Close()));
                    return;
                }
            }

            this.Text = $"Alturos PanTilt TestUI ({Application.ProductVersion})";
            this.SetConfigurationInfo();

            var startPtHeadCommunication = Task.Run(() => this.StartPanTiltCommunication());

            this.UpdateMousePanel();
            this.panelMouseControl.MouseWheel += MouseWheelZoom;

            //Disable TabPage Zoom - No ZoomProvider available
            //this.tabControl1.TabPages.Remove(this.tabPageCameraZoom);
            this._zoomProvider = new MockZoomProvider();
            this._zoomProvider.SetZoomAsync(0);
            this._zoomProvider.ZoomChanged += CameraControlZoomChanged;

            if (this._deviceConfiguration.CameraActive)
            {
                //Live Camera Image
                var url = $"http://{this._deviceConfiguration.CameraIpAddress}{this._deviceConfiguration.CameraJpegUrl}";

                IVideoSource source = new JPEGStream(url);
                ((JPEGStream)source).FrameInterval = 200;

                this._videoSourcePlayer             = new Accord.Controls.VideoSourcePlayer();
                this._videoSourcePlayer.VideoSource = source;
                this._videoSourcePlayer.Start();
                this._videoSourcePlayer.Dock = DockStyle.Fill;
                this.tabPageLiveView.Controls.Add(this._videoSourcePlayer);
            }
            else
            {
                //Visual Map
                this._cameraDrawEngine = new DrawEngine(4);
                this.UpdateCurrentImage();
                this.pictureBox_CameraPos.Visible = true;
            }

            startPtHeadCommunication.Wait();

            if (this._panTiltControl != null)
            {
                this.continiousMovementControl1.SetPanTiltControl(this._panTiltControl);
                this.fastMovementControl1.SetPanTiltControl(this._panTiltControl);
                this.absolutePositionControl1.SetPanTiltControl(this._panTiltControl);
                this._panTiltControl.PanTiltAbsolute(0, 0);
            }
        }