Esempio n. 1
0
 // Start video source
 public void Start( )
 {
     if (videoSource != null)
     {
         videoSource.Start( );
     }
 }
Esempio n. 2
0
        private void StartCamera()
        {
            var rectangle = new Rectangle();

            foreach (var screen in System.Windows.Forms.Screen.AllScreens)
            {
                rectangle = Rectangle.Union(rectangle, screen.Bounds);
            }
            videoSource           = new ScreenCaptureStream(rectangle);
            videoSource.NewFrame += capturedWebCamNewFrame;
            videoSource.Start();

            /*
             * if (CurrentDevice != null)
             * {
             *  videoSource = new VideoCaptureDevice(CurrentDevice.MonikerString);
             *  videoSource.NewFrame += capturedWebCamNewFrame;
             *  videoSource.Start();
             * }
             * else
             * {
             *  MessageBox.Show("Current device can't be null");
             * }
             */
        }
        public void StartCamera(LiveCamStatus cameraId)
        {
            switch (cameraId)
            {
            case LiveCamStatus.webCamLocal2:
                StopCamera();
                _videoSource           = new MJPEGStream("http://192.168.1.192:8089/video");
                _videoSource.NewFrame += video_NewFrame;
                _videoSource.Start();
                IsWebCamLocal1Play = false;
                IsWebCamLocal2Play = true;
                break;

            case LiveCamStatus.webCamLocal1:
                if (CurrentDevice != null)
                {
                    StopCamera();
                    _videoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(CurrentDevice.MonikerString);
                    _videoSource.NewFrame += video_NewFrame;
                    _videoSource.Start();
                    IsWebCamLocal1Play = true;
                    IsWebCamLocal2Play = false;
                }
                else
                {
                    MessageBox.Show("Current device can't be null");
                }
                break;


            default:
                break;
            }
        }
Esempio n. 4
0
 //Defines actions,happening after clicking the Start button:Calls OpenConnections method(described below) and Starts the camera
 private void btnStart_Click(object sender, EventArgs e)
 {
     OpenConnections();
     videoSource           = new VideoCaptureDevice(videoDevicesList[cmbVideoSource.SelectedIndex].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     videoSource.Start();
 }
Esempio n. 5
0
 private void StartCamera()
 {
     //przypisanie wybranej kamerki jako ta z której będziemy korzystać
     videoSource           = new VideoCaptureDevice(cameraDevices[cameraListComboBox.SelectedIndex].MonikerString);
     videoSource.NewFrame += video_NewFrame;
     videoSource.Start();
 }
Esempio n. 6
0
 // Start video source
 public void start()
 {
     if (_videoSource != null)
     {
         _videoSource.Start();
     }
 }
Esempio n. 7
0
 private void LoanBtn_Click(object sender, EventArgs e)
 {
     if (videoSource != null && videoSource.IsRunning)
     {
         lblErrorMessage.Text = "You are already scanning!";
         timer2.Start();
     }
     else
     {
         double value = Convert.ToDouble(StockNUD.Value);
         Item   item  = type[ItemCb.SelectedIndex];
         if (item.Quantity != 0)
         {
             if (value != 0)
             {
                 btnStopCamera.Enabled = true;
                 btnStopCamera.Visible = true;
                 videoSource.Start();
                 timer1.Start();
             }
             else
             {
                 lblErrorMessage.Text = "Please select a quantity for the item!";
                 timer2.Start();
             }
         }
         else
         {
             lblErrorMessage.Text = "Item not in stock!";
             timer2.Start();
         }
     }
 }
Esempio n. 8
0
        private void MotionForm_Shown(object sender, EventArgs e)
        {
            AppendLog("程序已加载...");
            try
            {
                AppendLog("正在读取摄像头设备列表...");
                //初始化摄像头设备
                VideoDevicesList = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                AppendLog("使用默认摄像头设备...");
                //使用默认设备
                VideoSource = new VideoCaptureDevice(VideoDevicesList[0].MonikerString);
                //绑定事件
                AppendLog("注册警报事件");
                VideoSource.NewFrame += new NewFrameEventHandler(Alert);
                AppendLog("正在启动摄像头...");
                //启动摄像头
                VideoSource.Start();
            }
            catch (Exception ex)
            {
                AppendLog("无法连接或启动摄像头,程序即将退出...\n{0}", ex.Message);
                MessageBox.Show(string.Format("无法连接摄像头:\n{0}", ex.Message));
                Application.Exit();
            }
            AppendLog("设备初始化完成!开始监视...");

            //运动监视
            LunchDetector = new MotionDetector(motionDetector, motionProcessing);
            AppendLog("运行监视创建完成...");
            AppendLog("————————————");
        }
        public virtual void StartRecording()
        {
            _videoSource.NewFrame += VideoNewFrame;
            _videoSource.Start();

            StartNewVideoFileWriter();
        }
Esempio n. 10
0
 /// <summary>
 /// Starts the video stream.
 /// </summary>
 /// <remarks></remarks>
 public void Start()
 {
     if (Source != null && !Source.IsRunning)
     {
         Source.Start();
     }
 }
Esempio n. 11
0
        public void StartCamera(FilterInfo filterInfo = null, PictureBox pictureBox = null)
        {
            try
            {
                if (IsDesktopSource)
                {
                    if (File.Exists(Program.Localpath + "\\resolution.txt"))
                    {
                        var str = File.ReadAllText(Program.Localpath + "\\resolution.txt").Split('_');
                        Program.width  = int.Parse(str[0]);
                        Program.height = int.Parse(str[1]);
                        wf             = float.Parse(str[2]);
                        hf             = float.Parse(str[3]);
                    }
                    else
                    {
                        Program.width  = SystemInformation.VirtualScreen.Width;
                        Program.height = SystemInformation.VirtualScreen.Height;
                    }
                    ClsCommon.WriteLog(Environment.OSVersion.Version.Major + "   Major " + Environment.OSVersion.Version.Major + "  Minor.   METHOD :- StartCamera();");
                    var rectangle = new Rectangle(0, 0, Program.width, Program.height);
                    heigth = rectangle.Height;
                    widht  = rectangle.Width;
                    ClsCommon.WriteLog(heigth + "X" + widht + " Method :- Screen Height and width.");
                    _videoSource           = new ScreenCaptureStream(rectangle);
                    _videoSource.NewFrame += video_NewFrame;
                    _videoSource.Start();
                }
                else if (IsWebcamSource)
                {
                    _PictureBox   = pictureBox;
                    CurrentDevice = filterInfo;

                    if (CurrentDevice != null)
                    {
                        _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
                        _videoSource.NewFrame += video_NewFrame;
                        _videoSource.Start();
                        var video = new VideoCaptureDevice(CurrentDevice.MonikerString).VideoCapabilities;
                        heigth = video[0].FrameSize.Height;
                        widht  = video[0].FrameSize.Width;
                        ClsCommon.WriteLog(heigth + "X" + widht + " Method :- video Height and width.");
                    }
                    else
                    {
                        MessageBox.Show("Current device can't be null");
                    }
                }
                else if (IsIpCameraSource)
                {
                    _videoSource           = new MJPEGStream(IpCameraUrl);
                    _videoSource.NewFrame += video_NewFrame;
                    _videoSource.Start();
                }
            }
            catch (Exception ex)
            {
                ClsCommon.WriteLog(ex.Message + " Method :- Start Camera");
            }
        }
Esempio n. 12
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (videoSource == null)
            {
                var vcd = new VideoCaptureDevice(videoDevicesList[cmbVideoSource.SelectedIndex].MonikerString);
                vcd.VideoResolution = vcd.VideoCapabilities[resolutionsBox.SelectedIndex];
                Debug.WriteLine(vcd.VideoCapabilities[1].FrameSize.ToString());
                Debug.WriteLine(resolutionsBox.SelectedIndex);
                videoSource           = vcd;
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
                videoSource.Start();
                StartButton.Text       = "Стоп";
                controlPanel.Enabled   = true;
                cmbVideoSource.Enabled = false;
            }
            else
            {
                videoSource.SignalToStop();
                if (videoSource != null && videoSource.IsRunning && originalImageBox.Image != null)
                {
                    originalImageBox.Image.Dispose();
                }

                videoSource            = null;
                StartButton.Text       = "Старт";
                controlPanel.Enabled   = false;
                cmbVideoSource.Enabled = true;
            }
        }
Esempio n. 13
0
 // Start video source
 public void Start()
 {
     if (mVideoSource != null)
     {
         mVideoSource.Start();
     }
 }
Esempio n. 14
0
 private void Button_ResumeFeeding_Click(object sender, RoutedEventArgs e)
 {
     if (videoSource != null)
     {
         videoSource.Start();
     }
 }
Esempio n. 15
0
 private void StartCamera()
 {
     if (IsDesktopSource)
     {
         var rectangle = new Rectangle();
         foreach (var screen in System.Windows.Forms.Screen.AllScreens)
         {
             rectangle = Rectangle.Union(rectangle, screen.Bounds);
         }
         _videoSource           = new ScreenCaptureStream(rectangle);
         _videoSource.NewFrame += video_NewFrame;
         _videoSource.Start();
     }
     else if (IsWebcamSource)
     {
         if (CurrentDevice != null)
         {
             _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
             _videoSource.NewFrame += video_NewFrame;
             _videoSource.Start();
         }
         else
         {
             MessageBox.Show("Current device can't be null");
         }
     }
     else if (IsIpCameraSource)
     {
         _videoSource           = new MJPEGStream(IpCameraUrl);
         _videoSource.NewFrame += video_NewFrame;
         _videoSource.Start();
     }
 }
Esempio n. 16
0
 public void Start()
 {
     if (ivideo != null)
     {
         ivideo.Start();
     }
 }
Esempio n. 17
0
        public void StartCamera(LiveCamStatus cameraId, System.Windows.Controls.Image image, String ipWebcam = null)
        {
            switch (cameraId)
            {
            case LiveCamStatus.webCamLocal2:
                _videoSource           = new MJPEGStream(ipWebcam);
                _videoSource.NewFrame += new NewFrameEventHandler((sender, args) => {
                    video_NewFrame(sender, args, image);
                });
                _videoSource.Start();
                break;

            case LiveCamStatus.webCamLocal1:
                if (CurrentDevice != null)
                {
                    StopCamera(image);
                    Thread.Sleep(1000);
                    _videoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(CurrentDevice.MonikerString);
                    _videoSource.NewFrame += new NewFrameEventHandler((sender, args) => {
                        video_NewFrame(sender, args, image);
                    });
                    _videoSource.Start();
                }
                else
                {
                    MessageBox.Show("Current device can't be null");
                }
                break;


            default:
                break;
            }
        }
Esempio n. 18
0
        public void Start(Rectangle position)
        {
            _position = position;
            //resolution can't be odd
            _position.Width  = _position.Width % 2 == 0 ? _position.Width : _position.Width - 1;
            _position.Height = _position.Height % 2 == 0 ? _position.Height : _position.Height - 1;

            CreateInputDirectoryIfNotExists();

            try
            {
                _watermarkImage = Image.FromFile(Properties.Settings.Default.WatermarkPath);
            }
            catch (FileNotFoundException e)
            {
            }

            _videoSource           = new ScreenCaptureStream(_position);
            _videoSource.NewFrame += CaptureFrame;
            _videoSource.Start();

            _videoWriter = new VideoFileWriter();

            var inputFilePath = $"{Properties.Settings.Default.SaveToPath}\\{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.{FILE_CONTAINER}";

            _videoWriter.Open(inputFilePath, _position.Width, _position.Height, FRAME_RATE, VideoCodec.H264, BIT_RATE);

            _isRecording    = true;
            _firstFrameTime = null;
        }
Esempio n. 19
0
 private void button1_Click(object sender, EventArgs e)
 {
     videoSource           = new VideoCaptureDevice(videoDevicesList[comboBox1.SelectedIndex].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     videoSource.Start();
     decode_QRtag();
 }
Esempio n. 20
0
        public void Instantiate_Camera()
        {
            int cam_count = 0;

            videoDevicesList = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo videoDevice in videoDevicesList)
            {
                Console.WriteLine("Kamera[" + cam_count + "]: " + videoDevice.Name);
                cam_count++;
            }
            if (videoDevicesList.Count > 0)
            {
                Console.WriteLine("mamy kamerek: " + videoDevicesList.Count);
            }
            else
            {
                Console.WriteLine("Nie mamy kamerek :/");
            }
            try
            {
                Console.WriteLine("Wpisz 0 lub 1 i zatwierdz enterem zeby wybrac kamerke");
                int camera = Int32.Parse(Console.ReadLine());
                videoSource           = new VideoCaptureDevice(videoDevicesList[camera].MonikerString);
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
                videoSource.Start();
                Console.WriteLine("kamerka wybrana: " + videoDevicesList[camera].Name);
            }
            catch (Exception)
            {
                Console.WriteLine("KUPA :3");
            }
        }
        public void CameraOn()
        {
            _videoCaptureDevice.NewFrame += VideoCaptureDevice_NewFrame;
            _videoCaptureDevice.Start();

            //write line to output class for testing purpose
            _output.OutputLine("Camera on");
        }
Esempio n. 22
0
        private void btn_Start_Click(object sender, EventArgs e)
        {
            string ConnectionString = "http://" + cameraIp.Text + "/axis-cgi/jpg/image.cgi";

            videoSource           = new JPEGStream(ConnectionString);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            videoSource.Start();
        }
Esempio n. 23
0
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            string ConnectionString = "http://" + ipInfo.Text + "/axis-cgi/jpg/image.cgi";

            _videoSource           = new JPEGStream(ConnectionString);
            _videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            _videoSource.Start();
        }
Esempio n. 24
0
 public void Start()
 {
     if (CurrentDevice != null)
     {
         _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
         _videoSource.NewFrame += this.DisplayWindow.video_NewFrame;
         _videoSource.Start();
     }
 }
Esempio n. 25
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     GettingConnection();
     videoSource           = new VideoCaptureDevice(videoDevicesList[cmbVideoSource.SelectedIndex].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     videoSource.Start();
     //if (pictureBox1.InvokeRequired) { pictureBox1.Invoke(new MethodInvoker(() => VideoSender())); } else VideoSender();
     //VideoSender();
 }
Esempio n. 26
0
 private void StartCamera()
 {
     if (((FilterInfo)cbDevices.SelectedItem) != null)
     {
         videoSource           = new VideoCaptureDevice(((FilterInfo)cbDevices.SelectedItem).MonikerString);
         videoSource.NewFrame += video_NewFrame;
         videoSource.Start();
     }
 }
Esempio n. 27
0
        private VideoFeed(IVideoSource source)
        {
            videoSource = source;

            //videoSource.DesiredFrameRate = 60;
            //videoSource.DesiredFrameSize = new Size(640, 480);

            videoSource.Start();
        }
Esempio n. 28
0
        private void StartLastAddedCamera()
        {
            _videoSource = new MJPEGStream(IpCameraUrls.Last().ImageSourcePath);
            var image = MonitoringImages.FirstOrDefault(mi => mi.Url == IpCameraUrls.Last().ImageSourcePath);

            image.VideoSource      = _videoSource;
            _videoSource.NewFrame += CaptureVideo_Frame;
            _videoSource.Start();
        }
Esempio n. 29
0
        private static void RunDemoApplication(IVideoSource videoSource, IAudioSource audioSource)
        {
            // Create a simple form with just a button and an image
            var form = new Form()
            {
                Text            = "SmartApp",
                ClientSize      = new Size(640, 550),
                StartPosition   = FormStartPosition.CenterScreen,
                MinimizeBox     = false,
                MaximizeBox     = false,
                FormBorderStyle = FormBorderStyle.FixedSingle
            };

            // Image to render the video
            var buffer = new Bitmap(640, 480, PixelFormat.Format24bppRgb);
            var image  = new PictureBox()
            {
                Size     = new Size(640, 480),
                Location = new Point(0, 0),
                Image    = buffer
            };

            form.Controls.Add(image);

            // Button to start/stop recording
            var btn = new Button()
            {
                Size     = new Size(640, 70),
                Location = new Point(0, 480),
                Text     = "Keep pressed to record",
                Font     = new Font(FontFamily.GenericSansSerif, 16.0f, FontStyle.Bold)
            };

            btn.MouseDown += (_, __) => { videoSource.Start(); audioSource.Start(); };
            btn.MouseUp   += (_, __) => { videoSource.Stop(); audioSource.Stop(); };
            form.Controls.Add(btn);

            // Draw the rectangles for the faces on the bitmap and show it on the screen
            videoSource.FrameReady += (_, frame) => {
                using (var g = Graphics.FromImage(buffer))
                    using (var pen = new Pen(Color.Red, 3f))
                    {
                        g.DrawImage(frame.Image, new Rectangle(0, 0, buffer.Width, buffer.Height));
                        foreach (var face in frame.Faces)
                        {
                            g.DrawRectangle(pen, face.Bounds);
                        }
                    }
                image.Invoke((Action)(() => {
                    image.Refresh();
                }));
            };

            // Show the form and block
            Application.EnableVisualStyles();
            form.ShowDialog();
        }
Esempio n. 30
0
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     if (_videoSource == null)
     {
         _videoSource           = new MJPEGStream(ConnectionString);
         _videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
         _videoSource.Start();
     }
 }
Esempio n. 31
0
 private void StartCamera()
 {
     if (CurrentDevice != null)
     {
         _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
         _videoSource.NewFrame += video_NewFrame;
         _videoSource.Start();
     }
 }
Esempio n. 32
0
        // Start cameras
        private void StartCameras(IVideoSource videoSource)
        {
            // create first video source

            videoSourcePlayer1.VideoSource = videoSource;

            if (CWViewer1 == null || !CWViewer1.Visible)
                videoSourcePlayer1.VideoSource = videoSource;

            if (CWViewer2 == null || !CWViewer2.Visible)
                videoSourcePlayer2.VideoSource = videoSource;

            // Start feed
            videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
            videoSource.Start();

            // Start image processing worker
            new RunWorkerDelegate(this.RunWorker).BeginInvoke(null, this);

            // start timer
            timer.Start( );
        }