Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using AForge;
  11. using AForge.Video;
  12. using AForge.Video.DirectShow;
  13. using AForge.Imaging.Filters;
  14.  
  15.  
  16. namespace WindowsFormsApp1
  17. {
  18.     public partial class Form1 : Form
  19.     {
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private FilterInfoCollection capture;
  26.         private VideoCaptureDevice source;
  27.  
  28.         private void Form1_Load(object sender, EventArgs e)
  29.         {
  30.             capture = new FilterInfoCollection(FilterCategory.VideoInputDevice);
  31.             foreach(FilterInfo Device in capture)
  32.             {
  33.                 comboBox1.Items.Add(Device.Name);
  34.             }
  35.             comboBox1.SelectedIndex = 0;
  36.             source = new VideoCaptureDevice();
  37.         }
  38.  
  39.         private void button1_Click(object sender, EventArgs e)
  40.         {
  41.             source = new VideoCaptureDevice(capture[comboBox1.SelectedIndex].MonikerString);
  42.             source.NewFrame += new NewFrameEventHandler(VideoSource_NewFrame);
  43.             //source.DesiredFrameSize = new Size(320, 240);
  44.             source.VideoResolution = source.VideoCapabilities[7];
  45.  
  46.             source.Start();
  47.         }
  48.  
  49.         private void VideoSource_NewFrame(object sender, NewFrameEventArgs e)
  50.         {
  51.  
  52.             //
  53.             Bitmap bitmap = (Bitmap)e.Frame.Clone();
  54.             var filter = new Mirror(false, true);
  55.             filter.ApplyInPlace(bitmap);
  56.             pictureBox1.Image = bitmap;
  57.         }
  58.  
  59.         private void pictureBox1_Click(object sender, EventArgs e)
  60.         {
  61.  
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement