Emgucv Camera Capure, frame rate less then 1FPS

236 views Asked by At

I am really new in programming and EemguCV and I am struggling with really basics and I hope you guys can help me out. I am writting a little program for my school to show differnt filters and Imageconverting methods. I am trying to grab images from a USB webcam and illustrate them in Imageboxes. e.g convertign it into Greyscale(Binary, changing resolutiona and Framerate etc. . I think I am doing something wrong because I am receiveing frame rates less then 1 FPS in from the camera. Also with low resolution (640/300px). My question isyou can help me out to encrease my frame rate. Also it was not possible to grab Image with the QuereFrame() metho, so I went with the Mat Obgect and retreive it to the Images. Here is my code:

    private void Capture_ImageGrabbed(object sender, EventArgs e) \\capure function
    {                      
           
            
            capture.Retrieve(m);
            capture.SetCaptureProperty(CapProp.FrameHeight, resolution_X);
            capture.SetCaptureProperty(CapProp.FrameWidth, resolution_Y);
            ImgInput = m.ToImage<Bgr, byte>();
            ImgGrayInput = m.ToImage<Gray, byte>();
            iB_colour_Image.Image = ImgInput;
            iB_Grey.Image = ImgGrayInput;

            if (imgchange)
            {
                ImgReference = ImgInput;
                ImgGrayReference = ImgReference.Convert<Gray , byte>();
                imgchange = false;
            }


            ImgBinarizedInput = new Image<Gray, byte>(ImgGrayInput.Width, ImgGrayInput.Height);
            double thresholdInput = CvInvoke.Threshold(ImgGrayInput, ImgBinarizedInput, tb_value, 255, Emgu.CV.CvEnum.ThresholdType.Binary);
            ImgBinarizedReference = new Image<Gray, byte>(ImgGrayReference.Width, ImgGrayReference.Height);
            double thresholdReference = CvInvoke.Threshold(ImgGrayReference, ImgBinarizedReference, tb_value, 255, Emgu.CV.CvEnum.ThresholdType.Binary);


            iB_Binary.Image = ImgBinarizedInput;
      
    }

    private void bt_play_stop_Click(object sender, EventArgs e) \\Buton to start stop the capture
    {
        if (buttonstate == false)
        {
            if (capture == null)
            {
                capture = new VideoCapture(selectedcamera, VideoCapture.API.DShow);
            }
            capture.Start();
            capture.ImageGrabbed += Capture_ImageGrabbed;                
            buttonstate = true;
            bt_play_stop.Text = "Stop";
        }
        else
        {
            capture.Stop();
            buttonstate = false;
            bt_play_stop.Text = "Play";
        }


    }
0

There are 0 answers