Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Form1_Load(object sender, EventArgs e)
- {
- WebCam_1 = new Capture(0);
- WebCam_1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 640);
- WebCam_1.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 480);
- Application.Idle += Application_Idle;
- }
- void Application_Idle(object sender, EventArgs e)
- {
- frame = WebCam_1.QueryFrame();
- Capture_Image.Image = frame;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Image<Gray, Byte> GrayImage = frame.Convert<Gray, Byte>();
- CvInvoke.cvShowImage("Gray Image", GrayImage);
- Gray BinaryThreshold = new Gray(130);
- Image<Gray, byte> BinaryImage = GrayImage.ThresholdBinary(BinaryThreshold, new Gray(255));
- CvInvoke.cvShowImage("Binary Image", BinaryImage);
- CircleF[] cir = BinaryImage.HoughCircles(new Gray(255), new Gray(20), 5, 12, 12, 18)[0];
- int total_points = 0;
- foreach (CircleF ci in cir)
- {
- BinaryImage.Draw(ci, new Gray(128), 1);
- total_points++;
- }
- textBox1.Text = total_points.ToString();
- Processed.Image = BinaryImage;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement