Example #1
0
 // Start video source
 public void Start( )
 {
     if (videoSource != null)
     {
         videoSource.Start( );
     }
 }
Example #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;
            }
        }
Example #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();
 }
Example #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();
 }
Example #6
0
 // Start video source
 public void start()
 {
     if (_videoSource != null)
     {
         _videoSource.Start();
     }
 }
Example #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();
         }
     }
 }
Example #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();
        }
Example #10
0
 /// <summary>
 /// Starts the video stream.
 /// </summary>
 /// <remarks></remarks>
 public void Start()
 {
     if (Source != null && !Source.IsRunning)
     {
         Source.Start();
     }
 }
Example #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");
            }
        }
Example #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;
            }
        }
Example #13
0
 // Start video source
 public void Start()
 {
     if (mVideoSource != null)
     {
         mVideoSource.Start();
     }
 }
Example #14
0
 private void Button_ResumeFeeding_Click(object sender, RoutedEventArgs e)
 {
     if (videoSource != null)
     {
         videoSource.Start();
     }
 }
Example #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();
     }
 }
Example #16
0
 public void Start()
 {
     if (ivideo != null)
     {
         ivideo.Start();
     }
 }
Example #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;
            }
        }
Example #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;
        }
Example #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();
 }
Example #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");
        }
Example #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();
        }
Example #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();
        }
Example #24
0
 public void Start()
 {
     if (CurrentDevice != null)
     {
         _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
         _videoSource.NewFrame += this.DisplayWindow.video_NewFrame;
         _videoSource.Start();
     }
 }
Example #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();
 }
Example #26
0
 private void StartCamera()
 {
     if (((FilterInfo)cbDevices.SelectedItem) != null)
     {
         videoSource           = new VideoCaptureDevice(((FilterInfo)cbDevices.SelectedItem).MonikerString);
         videoSource.NewFrame += video_NewFrame;
         videoSource.Start();
     }
 }
Example #27
0
        private VideoFeed(IVideoSource source)
        {
            videoSource = source;

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

            videoSource.Start();
        }
Example #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();
        }
Example #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();
        }
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     if (_videoSource == null)
     {
         _videoSource           = new MJPEGStream(ConnectionString);
         _videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
         _videoSource.Start();
     }
 }
Example #31
0
 private void StartCamera()
 {
     if (CurrentDevice != null)
     {
         _videoSource           = new VideoCaptureDevice(CurrentDevice.MonikerString);
         _videoSource.NewFrame += video_NewFrame;
         _videoSource.Start();
     }
 }
Example #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( );
        }