Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Emgu.CV.Structure;
- using Emgu.Util;
- using Emgu.CV;
- using Emgu.CV.Util;
- namespace Lab9
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- Capture cp;
- private void button1_Click(object sender, EventArgs e)
- {
- cp = new Capture(@"D:\filmik.avi");
- cp.ImageGrabbed += Pobierz;
- cp.Start();
- }
- public void Pobierz (object o,EventArgs e)
- {
- Mat obraz = new Mat();
- Mat obraz1 = new Mat();
- Mat obraz2 = new Mat();
- cp.Retrieve(obraz);
- System.Threading.Thread.Sleep(40);
- Image<Bgr, double> jakis_obraz = obraz.ToImage<Bgr, double>();
- double[, ,] dane = jakis_obraz.Data;
- for (int y = 0; y < jakis_obraz.Height; y++)
- for (int x = 0; x < jakis_obraz.Width; x++)
- {
- double G = dane[y, x, 1];
- dane[y, x, 0] = dane[y, x, 1] = dane[y, x, 2] = G;
- }
- Mat jakis_obraz1 = new Mat();
- Mat obraz10 = CvInvoke.CvArrToMat(jakis_obraz);
- Mat obraz4 = new Mat();
- obraz10.ConvertTo(obraz4, Emgu.CV.CvEnum.DepthType.Cv8U);
- CvInvoke.Canny(obraz4, jakis_obraz1, 400, 50, 3, false);
- VectorOfVectorOfPoint kontury = new VectorOfVectorOfPoint();
- Mat hierarchia = new Mat();
- CvInvoke.FindContours(jakis_obraz1,kontury,hierarchia,Emgu.CV.CvEnum.RetrType.List,
- Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
- double A=0;
- double b;
- for (int i = 0; i < kontury.Size; i++)
- {
- if (CvInvoke.ContourArea(kontury[i]) > A) A = CvInvoke.ContourArea(kontury[i]);
- if (CvInvoke.ContourArea(kontury[i]) == A)
- imageBox2.Image = jakis_obraz1;
- }
- imageBox1.Image = obraz;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement