SetCaptureProperty() публичный Метод

Sets the specified property of video capturing
public SetCaptureProperty ( CvEnum property, double value ) : void
property CvEnum Property identifier
value double Value of the property
Результат void
Пример #1
1
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            m_Playing = true;
            m_Engine = new Engine.Engine();

            if (RadioButtonWebcam.IsChecked.Value)
            {
                m_Capture = new Capture(0);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
            }
            else
            {
                m_Capture = new Capture(System.IO.Path.GetFullPath(".\\..\\Videos\\vidD.mp4"));
            }

            m_Timer = new Timer(ExpectedFrameUpdate, null, 0, 1000 / 15);

            m_DisplayFrames = new Thread(ShowFrames);
            m_DisplayFrames.Start();
        }
Пример #2
0
        public void StartCamera()
        {
            capture = new Emgu.CV.Capture();
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_AUTO_EXPOSURE, 0);

            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_BRIGHTNESS, 33);
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_CONTRAST, 54);
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_EXPOSURE, -7);
        }
Пример #3
0
 private void resolutionsList_SelectedIndexChanged(object sender, EventArgs e)
 {
     {
         var resolution = resolutionsList.Items[resolutionsList.SelectedIndex].ToString();
         var width      = resolution.Split('x')[0];
         var height     = resolution.Split('x')[1];
         _capture.SetCaptureProperty(CapProp.FrameHeight, int.Parse(height));
         _capture.SetCaptureProperty(CapProp.FrameWidth, int.Parse(width));
         cameraPictureBox.Width  = ClientSize.Width;
         cameraPictureBox.Height = ClientSize.Height;
     }
 }
Пример #4
0
 public void InitVideoCapture(string path)
 {
     try
     {
         m_FrameMat = new Mat();
         m_VideoCaptureFilename = path;
         m_VideoCaptureInterface = null;
         m_VideoCaptureInterface = new Capture(m_VideoCaptureFilename);
         m_VideoCaptureInterface.SetCaptureProperty(CapProp.FrameHeight, 640);
         m_VideoCaptureInterface.SetCaptureProperty(CapProp.FrameWidth, 360);
         m_VideoCaptureInterface.SetCaptureProperty(CapProp.Fps, 5);
         m_VideoCaptureInterface.ImageGrabbed += VideoCaptureInterface_ImageGrabbed;
         m_VideoCaptureFrameCount = (int)m_VideoCaptureInterface.GetCaptureProperty(CapProp.FrameCount);
         m_VideoCaptureInterface.Start();
     }
     catch (Exception e)
     {
     }
 }
Пример #5
0
        //filename: Catch image from video file
        //ms: Capture every ms. ms = 0 means capture all frames. (24 frames per second)
        public List<string> CatchImages(string fileName, int ms, string outputPath)
        {
            _log.Debug("Start to capture");
            if (string.IsNullOrWhiteSpace(fileName) || string.IsNullOrWhiteSpace(outputPath))
            {
                _log.Error("Cannot catch images from path: " + fileName + " and output to: " + outputPath);
            }
            //List<Image<Bgr, Byte>> imageList = new List<Image<Bgr, Byte>>();
            List<string> imagePath = new List<string>();
            Capture capture = new Capture(fileName);

            double frameCount = capture.GetCaptureProperty(CapProp.FrameCount);
            capture.Dispose();

            int index = 0;
            int fc = (int)frameCount;
            Mat mat = null;
            try
            {
                //TODO: Modified this to change period of capture image.
                while (index < 30/*fc*/)
                {
                    index++;
                    using (capture = new Capture(fileName))
                    {
                        capture.SetCaptureProperty(CapProp.PosFrames, (double)index);

                        using (mat = capture.QueryFrame())
                        {
                            string indexStr = index < 10 ? "0" + index : index.ToString();
                            string imgPath = outputPath + "\\" + indexStr;
                            if (!Directory.Exists(outputPath))
                            {
                                Directory.CreateDirectory(outputPath);
                            }
                            //long quality = 60;
                            //saveJpeg(imgPath, mat.Bitmap, quality);
                            string grayImgName = saveGrayAndThreshold(imgPath, mat.Bitmap);
                            if (!string.IsNullOrEmpty(grayImgName))
                            {
                                imagePath.Add(grayImgName);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                _log.Error("Exception:", ex);
            }

            return imagePath;
        }
Пример #6
0
        private void SetProperty(Emgu.CV.CvEnum.CAP_PROP prop, int v)
        {
            double value = v;

            lock (this)
            {
                if (IsConnected)
                {
                    _device.SetCaptureProperty(prop, value);
                }
            }
        }
Пример #7
0
		public MainForm()
		{
			InitializeComponent();
			m_UnitsComboBox.SelectedIndex = 0;

			CameraParameters cameraParameters = null;
			HomographyMatrix groundProjectionTransformation = null;

			bool useCamera = false;

			if (useCamera)
			{
				m_Capture = new Capture();
				m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
				m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);

				cameraParameters = CameraParameters.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus14\1280x720\MicrosoftCinemaFocus14_1280x720.txt");

				groundProjectionTransformation = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus14\1280x720\BirdsEyeViewTransformationForCalculation.txt");
				m_GroundProjectionTransformationForUI = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus14\1280x720\BirdsEyeViewTransformationForUI.txt");
			}
			else
			{
				m_Capture = new Capture(@"C:\svnDev\oss\Google\drh-visual-odometry\TestVideos\2010-07-18 11-10-22.853.wmv");
				m_Timer.Interval = 33;
				m_Timer.Enabled = true;

				cameraParameters = CameraParameters.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\MicrosoftCinemaFocus12_1280x720.txt");

				groundProjectionTransformation = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForCalculation.txt");
				m_GroundProjectionTransformationForUI = HomographyMatrixSupport.Load(@"C:\svnDev\oss\Google\drh-visual-odometry\CalibrationFiles\MicrosoftCinema\Focus12\1280x720\BirdsEyeViewTransformationForUI.txt");
			}

			m_VisualOdometer = new VisualOdometer(m_Capture, cameraParameters, groundProjectionTransformation, new OpticalFlow());

			UpdateFromModel();

			m_VisualOdometer.Changed += new EventHandler(OnVisualOdometerChanged);
			Application.Idle += OnApplicationIdle;
		}
Пример #8
0
        public Base()
        {
            var comports = SerialPort.GetPortNames();
            if (comports.Length == 0)
            {
                throw new Exception("Error: No COM ports found");
            }
            for (int i = 0; i < comports.Length; i++)
            {
                try
                {
                    Mega2560 = new Arduino(comports[i]);
                    break;
                }
                catch (Exception) {}
            }
            ForceSensor = new ResistiveForce(Mega2560, Force_Analog_Pin);
            DistanceSensor = new SharpIR(Mega2560, Distance_Analog_Pin);
            LightSensor = new Sensor(Mega2560, Light_Analog_Pin);

            Webcam = new Capture();
            Dictionary = new SpeechDictionary();
            Webcam.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
            Webcam.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720); // set cam resolution to 720P
            Webcam.QueryFrame(); // take a test photo
            Webcam.ImageGrabbed += new EventHandler(Webcam_ImageGrabbed);

            XboxController = new Controller(UserIndex.One);

            xAxisServo = new Servo(ref Mega2560, xServoPin);
            yAxisServo1 = new Servo(ref Mega2560, y1ServoPin, y1ServoMax, y1ServoMin);
            yAxisServo2 = new Servo(ref Mega2560, y2ServoPin, y2ServoMax, y2ServoMin);
            gripperServo = new Servo(ref Mega2560, gripServoPin, gripServoMax, gripServoMin);
            xAxisServo.ServoAngleChange(xServoStart);
            yAxisServo1.ServoAngleChange(y1ServoStart);
            yAxisServo2.ServoAngleChange(y2ServoStart);
            gripperServo.ServoAngleChange(gripServoStart);

            SpeechEngine = new SpeechRecognition.Base();
        }
Пример #9
0
        public faceTrack()
        {
            InitializeComponent();

            CvInvoke.UseOpenCL = false;

            _cascadeClassifierFace = new CascadeClassifier(Application.StartupPath + "/haarcascade_frontalface_default.xml");
            _cascadeClassifierEye = new CascadeClassifier(Application.StartupPath + "/haarcascade_eye.xml");

            try
            {
                capturecam = new Capture(0);
                capturecam.SetCaptureProperty(CapProp.Fps, 30);
                capturecam.SetCaptureProperty(CapProp.FrameHeight, 240);
                capturecam.SetCaptureProperty(CapProp.FrameWidth, 320);
                capturecam.SetCaptureProperty(CapProp.AutoExposure, 1);

                trackBarUpdate(trackBarContrast, (int)capturecam.GetCaptureProperty(CapProp.Contrast));
                trackBarUpdate(trackBarBrightness, (int)capturecam.GetCaptureProperty(CapProp.Brightness));
                //trackBarUpdate(trackBarGain, (int)capturecam.GetCaptureProperty(CapProp.Gain));
                trackBarUpdate(trackBarZoom, (int)capturecam.GetCaptureProperty(CapProp.Zoom));

                textBoxTime.Text = "Time: ";
                textBoxCodec.Text = "Codec: ";
                textBoxFrameRate.Text = "Frame: ";

                capturecam.ImageGrabbed += ProcessFrame;
                //Application.Idle += ProcessFrame;

                //original.Image = capturecam.QueryFrame();
            }
            catch (NullReferenceException excpt)
            {
                MessageBox.Show(excpt.Message);
            }
        }
Пример #10
0
        public Form1()
        {
            InitializeComponent();

            markedPoints = new Dictionary<string, Point[]>();

            try
            {
                capture = new Capture("kinect_local_rgb_raw_synced.avi");
                capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.PosFrames, currentFrame);
                pictureBox.Image = capture.QueryFrame().Bitmap;

                frameCount = (int) capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                
            } catch ( Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #11
0
        public CameraViewModel()
        {
            if(IsInDesignMode)
                return;

            SelectedCam = Properties.Settings.Default.SelectedCam;
            DetectionEnabled = Properties.Settings.Default.DetectionEnabled;
            Fps = 0;

            CameraHandler = new CameraHandler();
            Capture = CameraHandler.CreateCapture(SelectedCam);
            Capture.SetCaptureProperty(CapProp.Fps, 30);
            Capture.ImageGrabbed += CaptureOnImageGrabbed;

            _fpsStopwatch = Stopwatch.StartNew();
            _delayStopwatch = new Stopwatch();

            InitializeMessageHandler();
            RefreshCameras();
        }
Пример #12
0
		public void Initialise(int id, int width, int height)
		{
			if (id == FCameraID && width == FRequestedWidth && height == FRequestedHeight)
				return;

			Close();
			lock (FCaptureLock)
			{
				try
				{
					FCapture = new Capture(id);
					FCapture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
					FCapture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
				}
				catch (Exception e)
				{
					Status = "Camera open failed";
					IsRunning = false;
					return;
				}

				Status = "OK";
				IsRunning = true;

				FCameraID = id;

				FWidth = FCapture.Width;
				FHeight = FCapture.Height;

				FRequestedWidth = width;
				FRequestedHeight = height;
			}

			FCaptureRunThread = true;
			FCaptureThread = new Thread(Capture);
			FCaptureThread.Start();
		}
Пример #13
0
        private void SetupCapture(int Camera_Identifier)
        {
            //update the selected device
            CameraDevice = Camera_Identifier;


            //Dispose of Capture if it was created before
            if (_capture != null) _capture.Dispose();
            try
            {
                //Set up capture device
                _capture = new Capture(CameraDevice);
                _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, Int16.Parse(fpstext.Text));
                if (resolution.SelectedIndex == 0)
                {
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 480);
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 640);
                }

                if (resolution.SelectedIndex == 1)
                {
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 1000);
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 2000);
                    
                }
                selectedWidth= _capture.Width;
                selectedHeight = _capture.Height;
                
                selectedfps = Convert.ToInt16(_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS));
               // _capture.ImageGrabbed += ProcessFrame;
              
            }
            catch (NullReferenceException excpt)
            {MessageBox.Show(excpt.Message);}

        }
Пример #14
0
        /***
            Function: private void MachineExecution()
            Parameter(s):
            Return Value: void
                This is where the main execution of the program takes place. Most of the code called from this function
                resides in the MachineHeuristics.cs file with the facial detection and recognition processing.
        ***/
        private void MachineExecution()
        {
            if (machineInputSourceKind == MachineInputSourceKind.SourceNone)
                PanicAndTerminateProgram();
            if (machineInputSourceKind == MachineInputSourceKind.SourceFile)
            {
                capture = InitCapture();
                frame_count = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameCount);
                frame_rate = capture.GetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps);
                theoretical_delay = (int)(1000 / frame_rate);
                number_of_delayable_frames = (int)(frame_rate / 2);
                dispatcherTimer = new DispatcherTimer(
                        TimeSpan.FromMilliseconds(theoretical_delay),
                        DispatcherPriority.ApplicationIdle,
                        ProcessAnyFrame,
                        Application.Current.Dispatcher
                    );
                dispatcherTimer.Start();
            }
            else if (machineInputSourceKind == MachineInputSourceKind.SourceWebcam)
            {
                /***
                    Some computers have their default, working camera on a different internal number.
                    Note, zero is usually the correct number, and is actually the default in the InputSelection.xaml.cs file.
                ***/
                capture = new Capture(cameraNumber);

                // Locks the camera frame rate to a constant value.
                frame_rate = cameraFrameRate;
                capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps, frame_rate);
                theoretical_delay = (int)frame_rate;
                number_of_delayable_frames = (int)(frame_rate / 2);
                dispatcherTimer = new DispatcherTimer(
                        TimeSpan.FromMilliseconds(1000 / frame_rate),
                        DispatcherPriority.ApplicationIdle,
                        ProcessAnyFrame,
                        Application.Current.Dispatcher
                    );

                // Keep running the ProcessAnyFrame function every time a frame is received (theoretically), should work with no hitches.
                dispatcherTimer.Start();
            }
        }
Пример #15
0
 private void SetResolution(Capture capture, Resolution resolution)
 {
     int width = 0;
     int height = 0;
     switch (resolution)
     {
         case Resolution.R320X240:
             width = 320;
             height = 240;
             break;
         case Resolution.R640X480:
             width = 640;
             height = 480;
             break;
         case Resolution.R800X600:
             width = 800;
             height = 600;
             break;
         case Resolution.R1280X720:
             width = 1280;
             height = 720;
             break;
     }
     capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
     capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
 }
Пример #16
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                var list = DirectShowLib.DsDevice.GetDevicesOfCat(DirectShowLib.FilterCategory.VideoInputDevice);
                int idev = 0;
                foreach (var dev in list)
                {
                    var tsi = new ToolStripMenuItem(dev.Name);
                    tsi.Tag = idev;
                    tsi.CheckOnClick = true;
                    tsi.Click += (a, b) => {
                        var ttt = (ToolStripMenuItem)a;
                        if (ttt != null && ttt.Checked)
                        {
                            foreach (ToolStripMenuItem tm in deviceToolStripMenuItem.DropDownItems)
                                tm.Checked = false;
                            int nTries = 0;
                            timer1.Enabled = false;
                            while (nTries < 5)
                            {
                                try
                                {
                                    _capture = new Capture(Convert.ToInt32(ttt.Tag));
                                    _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
                                    _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
                                    nTries = 20;
                                    ttt.Checked = true;
                                }
                                catch {
                                    Thread.Sleep(100);
                                    nTries++;
                                }

                            }

                            timer1.Enabled = true;
                        }                        
                    };
                    idev++;
                    deviceToolStripMenuItem.DropDownItems.Add(tsi);
                }
            }
            catch { }
            string[] inums = new string[] { "1 sek", "2 sek", "5 sek", "10 sek", "20 sek", "30 sek", "1 min", "2 min", "5 min", "10 min", "20 min", "30 min", "1 tim", "2 tim", "5 tim", "8 tim", "10 tim", "12 tim", "24 tim" };

            foreach(string inum in inums)
            {
                ToolStripItem tsi = intervallToolStripMenuItem.DropDownItems.Add(inum);
                tsi.Click += (a, b) => {
                    setInterval((a as ToolStripMenuItem).Text);
                    foreach (ToolStripMenuItem t in intervallToolStripMenuItem.DropDownItems)
                    {
                        t.Checked = false;
                    }
                    (a as ToolStripMenuItem).Checked = true;
                };
                if (intervallToolStripMenuItem.DropDownItems.Count == 1)
                {
                    (intervallToolStripMenuItem.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                }
                ToolStripItem tsi2 = intervallToolStripMenuItem1.DropDownItems.Add(inum);
                tsi2.Click += (a, b) =>
                {
                    setRInterval((a as ToolStripMenuItem).Text);
                    foreach (ToolStripMenuItem t in intervallToolStripMenuItem1.DropDownItems)
                    {
                        t.Checked = false;
                    }
                    (a as ToolStripMenuItem).Checked = true;
                };
                if (intervallToolStripMenuItem1.DropDownItems.Count == 1)
                {
                    (intervallToolStripMenuItem1.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                }
            }
        }
Пример #17
0
        public Form1()
        {
            #region visual-studio-inserted code (do not modify)
            // This is inserted by VS by default; do not move.
            InitializeComponent();
            #endregion

            #region setup server to wait for glove connection
            //ServerController server = new ServerController();
            ////for every delegate you want to functino
            //server.registerDelegate(CAPIStreamCommon.PacketType.VIDEO_FRAME, new ImageWork(doWorkOnData));
            //server.startServer(CAPIStreamServer.ConnectionType.TCP);
            #endregion

            #region setup decoder
            initFrameConverter(stream_width, stream_height);
            #endregion

            #region combo box 1 (available items to track)
            itemsAvailableForLocation = new List<string>();
            string[] itemNames = Directory.GetFiles("itemsToTrack/", "*.jpg");
            foreach (string s in itemNames)
            {
                string name = System.Text.RegularExpressions.Regex.Replace(s, "itemsToTrack/", "");
                name = System.Text.RegularExpressions.Regex.Replace(name, ".jpg", "");
                comboBox1.Items.Add(name);
                itemsAvailableForLocation.Add(name);
            }
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox1.SelectedIndex = 0;
            #endregion

            #region combo box 2 (serial ports for Arduino connection)
            RefreshSerialPortList();
            comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            //comboBox2.SelectedIndex = 0;
            #endregion

            #region check box 1 (haptic feedback)
            // Haptic feedback starts disabled
            checkBox1.Enabled = false;
            #endregion

            #region picture box
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            #endregion

            #region initialize Capture object

            /**
             * TODO this shouldn't be done here, as the capture can be initialized in a number
             * of ways in the future.
             * There should be menus with options for initializing capture (from webcam, from
             * file, from streaming) and then once the needed information (e.g. camera number,
             * filename, or ip/port) is input and validated, only THEN will the capture be
             * created.
             */

            // TODO this shouldn't be hardcoded
            cap = new Capture(camera);

            float width = 648.0f, height = 1152.0f;

            cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
            cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
            #endregion

            #region create EventHandler

            /**
             * TODO we either need to make this handler work for ALL video input sources,
             * or make different handlers for different situations.
             * Right now, handling from webcam uses this event handler, which gets attached
             * to Application.Idle. However, handling from streaming doesn't use EventHandlers
             * at all; everything happens in the doWorkOnData function. This needs to be changed.
             */

            ShowFromCamHandler = new EventHandler(ShowFromCam);
            #endregion
        }
Пример #18
0
        //btnStart_Click() function is the one that handles our "Start!" button' click
        //event. it creates a new capture object if its not created already. e.g at first time
        //starting. once the capture is created, it checks if the capture is still in progress,
        //if so the
        private void btnStart_Click(object sender, EventArgs e)
        {
            #region if capture is not created, create it now
            if (captures.Count == 0)
            {
                try
                {
                    for (var cameraIndex = 0; cameraIndex < cameras; cameraIndex++)
                    {
                        var capture = new Capture(cameraIndex);
                        capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps, fps);
                        capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, frameHeight);
                        capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth, frameWidth);

                        captures.Add(capture);
                    }
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
            #endregion

            if (captures.Count > 0)
            {
                if (captureInProgress)
                {  //if camera is getting frames then stop the capture and set button Text
                   // "Start" for resuming capture
                    btnStart.Text = "Start!"; //
                    Application.Idle -= ProcessFrame;
                }
                else
                {
                    //if camera is NOT getting frames then start the capture and set button
                    // Text to "Stop" for pausing capture
                    btnStart.Text = "Stop";
                    Application.Idle += ProcessFrame;
                }

                captureInProgress = !captureInProgress;
            }
        }
Пример #19
0
        private void SelectCamera(int camera_index)
        {
            if (grabber == null)
            {
                grabber = new Emgu.CV.Capture();
                width = ((DeviceCapabilityInfo)cam_capability.SelectedItem).FrameSize.Width;
                height = ((DeviceCapabilityInfo)cam_capability.SelectedItem).FrameSize.Height;
                grabber.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
                grabber.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
                InitializeImages(width, height);
            }
            else
            {
                Application.Idle -= FrameGrabber;
                grabber.Dispose();
                ReleaseData();

                grabber = new Emgu.CV.Capture();
                width = ((DeviceCapabilityInfo)cam_capability.SelectedItem).FrameSize.Width;
                height = ((DeviceCapabilityInfo)cam_capability.SelectedItem).FrameSize.Height;
                grabber.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
                grabber.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);

                InitializeImages(width, height);
                Application.Idle += FrameGrabber;
            }
        }
Пример #20
0
        private void button1_Click(object sender, EventArgs e)
        {
            //CvInvoke.cvCreateCameraCapture(2);
            Capture capture = new Capture();
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
            //capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 60);

            label1.Text = "Width:" + Convert.ToInt32(capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH)).ToString()
                + ",Height:" + Convert.ToInt32(capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT)).ToString();
            Application.Idle += new EventHandler(delegate(object sender2, EventArgs e2)
            {
                img = capture.QueryFrame();
                camerabox1.Image = img.ToBitmap();
                if (a > 0)
                {
                    getBox(img);
                    a = 0;
                }
            });
        }
Пример #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (_captureInProgress)
            {
                //stop the capture
                button1.Text = "Start";
                camListComboBox.Enabled = true;
                fpsBox.Enabled = true;
                widthBox.Enabled = true;
                heightBox.Enabled = true;
                _capture.Dispose();
                _frames = 0;
                _fps = 0;
                _dFps = 1;
            }
            else
            {
                try
                {
                    _capture = new Capture(_camIndex);
                    _capture.ImageGrabbed += ProcessFrame;
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
                //start the capture
                button1.Text = "Stop";
                camListComboBox.Enabled = false;
                fpsBox.Enabled = false;
                widthBox.Enabled = false;
                heightBox.Enabled = false;
                if (String.IsNullOrWhiteSpace(fpsBox.Text))
                {
                    fpsBox.Text = sfps.ToString();
                    printConsole("FPS set automaticaly: " + fpsBox.Text + "\n");
                }
                else
                {
                    sfps = Convert.ToInt32(fpsBox.Text);
                }
                if (String.IsNullOrWhiteSpace(widthBox.Text) || String.IsNullOrWhiteSpace(heightBox.Text))
                {
                    widthBox.Text = width.ToString();
                    heightBox.Text = height.ToString();
                    printConsole("Frame size set automaticaly: " + widthBox.Text + " x " + heightBox.Text+ "\n");
                }
                else
                {
                    width = Convert.ToInt32(widthBox.Text);
                    height = Convert.ToInt32(heightBox.Text);
                }
                _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps, sfps);
                _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth, width);
                _capture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, height);
                _capture.Start();
                _currentTime = DateTime.Now.Ticks;
            }

            _captureInProgress = !_captureInProgress;
        }
        public void initializeWebcam()
        {
            capture1 = new Emgu.CV.Capture(0);
            capture1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH);
            capture1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT);

            capture2 = new Emgu.CV.Capture(1);
            capture2.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH);
            capture2.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT);
        }
Пример #23
0
 public static bool PerformSeekOperationInVideo(double starting_time_in_milliseconds, Capture capture)
 {
     try
     {
         if (capture == null)
         {
             throw new ArgumentNullException();
         }
         capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_POS_MSEC, starting_time_in_milliseconds);
         return true;
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return false;
     }
 }
Пример #24
0
        private void ExtractVideoFrames(String Filename)
        {
            Capture _capture = new Capture(Filename);
            try
            {
                TotalVideoFrames = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
                VideoFPS = Math.Round(_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS));
                VideoLength = Convert.ToInt32(Math.Round(TotalVideoFrames / VideoFPS));
                double frameNumber = 0.0;
                IBGFGDetector<Bgr> _detector = new FGDetector<Bgr>(FORGROUND_DETECTOR_TYPE.FGD);

                bool Reading = true;

                while (Reading)
                {
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES, frameNumber);
                    _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_BRIGHTNESS, 100);
                    Image<Bgr, Byte> frame = _capture.QueryFrame();
                    if (frame != null)
                    {
                        frame = frame.Resize(Convert.ToDouble(ConfigurationSettings.AppSettings["OutFrameResizeScalefactor"]), Emgu.CV.CvEnum.INTER.CV_INTER_AREA);
                        frame._EqualizeHist();

                        frame.Save(OutImageLocation + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg");
                    }
                    else
                    {
                        Reading = false;
                    }

                    frameNumber += (VideoFPS * TimeDiff);
                    if (frameNumber > TotalVideoFrames)
                        Reading = false;

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _capture.Dispose();
            }
        }
 private void Awake()
 {
     filteringParameters = new FilteringParameters(new UnityAppSettingsManager());
     if (CamerasDetected())
     {
         capture = new Capture();
         newFrame = true;
         cameraTimer = new Timer(40);
         cameraTimer.Elapsed += new ElapsedEventHandler(OnCameraFrame);
         capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FPS, 25);
         ChangeEditedRange(0);
     }
     else
     {
         NoCameraWarning.SetActive(true);
     }
 }
Пример #26
0
        public void SetCameraDevice(int cameraDeviceIndex)
        {
            if (cameraDeviceIndex < 0 || cameraDeviceIndex > this.CaptureDevices.Count - 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (cameraDeviceIndex == SelectedDeviceIndex) return;
            SelectedDeviceIndex = cameraDeviceIndex;

            try
            {
                if (capture != null && captureInProgress)
                {
                    capture.ImageGrabbed -= ProcessFrame;
                    capture.Pause();
                    captureInProgress = false;
                    capture.Stop();
                }
                capture = new Capture(cameraDeviceIndex);
                capture.SetCaptureProperty(CapProp.FrameWidth, CAPTURE_FRAME_WIDTH);
                capture.SetCaptureProperty(CapProp.FrameHeight, CAPTURE_FRAME_HEIGHT);
                capture.SetCaptureProperty(CapProp.Fps, 15);
                capture.ImageGrabbed += ProcessFrame;
            }
            catch
            {
                throw new NotSupportedException("Device does not support capturing.");
            }
        }
Пример #27
-1
 public ExCamera()
 {
     capture = new Capture(0);
     capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, size.Width);
     capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, size.Height);
     capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_AUTO_EXPOSURE, 0);
 }
Пример #28
-1
       public void StartCamera() {
            capture = new Emgu.CV.Capture();
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_AUTO_EXPOSURE, 0);

            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_BRIGHTNESS, 33);
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_CONTRAST, 54);
            capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_EXPOSURE, -7);
       }
Пример #29
-1
        private void WebcamForm_Load(object sender, EventArgs e)
        {
            Webcam = new Capture(0);
            Webcam.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth, 640);
            Webcam.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, 480);

            //建立系統閒置處理程序
            Application.Idle += Application_Idle;
        }
Пример #30
-1
        public Camera()
        {
            capture = new Capture(); //create a camera captue
            capture.SetCaptureProperty(CapProp.FrameWidth, 2592);
            capture.SetCaptureProperty(CapProp.FrameHeight, 1944);
            capture.FlipVertical = true;
            FrameRate = capture.GetCaptureProperty(CapProp.Fps);

            Debug.DebugStatement("Camera initialized",ConsoleColor.White);
        }
Пример #31
-1
 public WebcamFetcher(float width, float height)
 {
     args = new FrameFetchedEventArgs();
     camera = 0;
     cap = new Capture(camera);
     width = 648.0f;
     height = 1152.0f;
     cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
     cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
 }
Пример #32
-1
        private void Form1_Load(object sender, EventArgs e)
        {
            _capture = new Capture(1);

            Screen s = Screen.FromHandle(board.Handle); 
            _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, s.WorkingArea.Width);
            _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, s.WorkingArea.Height);
            timer1.Enabled = true;
            board.Show();
        }
Пример #33
-1
        private void initCamera()
        {
            try
            {
                _capture = new Capture(0);
                _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, Width);
                _capture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, Height);
            }
            catch
            {
                if (_capture != null)
                    _capture.Dispose();
                _capture = null;

            }
        }