public CamshiftDemo() { InitializeComponent(); bar_ValueChanged(null, null); //write values to variables init(); //create histograms try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); roi = new Rectangle(180, 285, 75, 120); isROISelected = true; this.barVMin.Value = 100; #else videoCapture = new CameraCapture(0); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = new Size(640, 480); //set new Size(0,0) for the lowest one } this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_InitFrame; videoCapture.Open(); }
/// <summary> /// Creates new image stream iterator. /// </summary> /// <param name="streamableSource">Image stream.</param> public ImageStreamReaderEnumerator(ImageStreamReader <TImage> streamableSource) { this.streamableSource = streamableSource; this.length = streamableSource.Length; Reset(); }
/// <summary> /// Reads the image source and save the extracted images to the specified folder. /// </summary> /// <param name="imageSource">Image stream reader.</param> /// <param name="outputDir">Output directory.</param> /// <param name="fileNameFormat">Image file name format.</param> /// <param name="onFrameCompletition">Progress function executed after a frame is saved.</param> public static void SaveFrames(this ImageStreamReader imageSource, string outputDir, string fileNameFormat = "img-{0:000}.png", Action <float> onFrameCompletition = null) { if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } if (imageSource.CanSeek) { imageSource.Seek(0, SeekOrigin.Begin); } var idx = 0; foreach (var frame in imageSource) //use video stream as IEnumerable<IImage> (must support seek operation) { if (frame != null) //some videos skip key frames (discard those frames) { var path = Path.Combine(outputDir, String.Format(fileNameFormat, idx)); ImageIO.TrySave(frame, path); //TODO-noncritical: add compression options } if (onFrameCompletition != null) { onFrameCompletition((float)(idx + 1) / imageSource.Length); } idx++; } }
public FastTPDemo() { InitializeComponent(); initialize(); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); #else videoCapture = new CameraCapture(0); #endif } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = new Size(640 / 2, 480 / 2); //set new Size(0,0) for the lowest one } this.FormClosing += FastTPDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
public FastTP() { InitializeComponent(); TemplPyrs = new List <TemplatePyramid>(); TMP = new TemplateMatching(); string[] fileNames = { "TP-A.bmp", "ha-ha-you-lose.bmp" }; TemplPyrs = TemplateMatching.fromFiles(fileNames, true, CropToSqr: true); //TemplPyrs = TemplateMatching.fromXML("demo.xmll"); try { #if FILE_CAPTURE //string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryCapture(@"./", "TP.bmp"); #else videoCapture = new CameraCapture(1); #endif } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = new DotImaging.Primitives2D.Size(1600 / 2, 1200 / 2); //set new Size(0,0) for the lowest one } this.FormClosing += FastTP_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
public KalmanTrackingDemo() { InitializeComponent(); #if FILE_CAPTURE roi = new Rectangle(115, 220, 30, 15); //user defined rectangle for sample video isROISelected = true; #endif bar_ValueChanged(null, null); //write values to variables initalizeHistograms(); //create histograms try { #if FILE_CAPTURE string videoDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources", "Sequence"); videoCapture = new ImageDirectoryCapture(videoDir, "*.jpg"); #else videoCapture = new CameraCapture(0); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_InitFrame; videoCapture.Open(); }
public SimpleParticleDemoForm() { InitializeComponent(); init(); try { //videoCapture = new CameraCapture(0); string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (videoCapture is CameraCapture) (videoCapture as CameraCapture).FrameSize = imgSize; videoCapture.Open(); this.FormClosing += ColorParticleDemo_FormClosing; Application.Idle += videoCapture_ProcessFrame; }
/// <summary> /// update the framework with objects (templates) find in the frame /// </summary> /// <param name="templPyrs">the list of templates</param> /// <param name="videoCapture">the video stream</param> /// <param name="pictureBox">the picture box of window form</param> /// /// <returns>nothing.</returns> public void CaptureFrame(List <TemplatePyramid> templPyrs, ImageStreamReader videoCapture, PictureBox pictureBox) { DotImaging.Font font = new DotImaging.Font(FontTypes.HERSHEY_DUPLEX, 1, 0.1f); videoCapture.ReadTo(ref frame); if (frame == null) { return; } long preprocessTime, matchTime; var bestRepresentatives = findObjects(frame, templPyrs, out preprocessTime, out matchTime); /************************************ drawing ****************************************/ foreach (var m in bestRepresentatives) { frame.Draw(m.BoundingRect, Bgr <byte> .Blue, 1); frame.Draw(m.Points.Select(x => new Circle(x.X, x.Y, 5)).ToArray(), Bgr <byte> .Blue, -1); Console.WriteLine("Best template: " + m.Template.ClassLabel + " AT " + m.BoundingRect.X + " " + m.BoundingRect.Y + " ANGLE: " + m.Template.Angle + " score: " + m.Score); } frame.Draw(String.Format("Matching {0} templates in: {1} ms", templPyrs.Count, matchTime), font, new DotImaging.Primitives2D.Point(10, 25), Bgr <byte> .Green); /************************************ drawing ****************************************/ pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color //frame.Save(String.Format("C:/probaImages/imgMarked_{0}.jpg", i)); b.Save(String.Format("C:/probaImages/img_{0}.jpg", i)); i++; //GC.Collect(); }
public ParticleFilterModelFittingDemo() { InitializeComponent(); init(); try { string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "SampleVideos", "1"), "*.jpg"); //1st sample //videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "SampleVideos", "2"), "*.jpg"); //2nd sample } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = imgSize; } this.FormClosing += ColorParticleDemo_FormClosing; Application.Idle += videoCapture_ProcessFrame; videoCapture.Open(); }
public SimpleParticleDemoForm() { InitializeComponent(); init(); try { //videoCapture = new CameraCapture(0); string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = imgSize; } videoCapture.Open(); this.FormClosing += ColorParticleDemo_FormClosing; Application.Idle += videoCapture_ProcessFrame; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ImageStreamReader capture = null; string databaseFileName = null; using (var wizard = new Wizard()) { wizard.ShowDialog(); capture = wizard.CaptureObj; databaseFileName = wizard.DatabaseFileName; } //capture = new ImageDirectoryReader(@"C:\Users\Darko-Home\Desktop\HandDatabase\prepared\Nenad_Darko\Tomislav 1\", "*.jpg"); //databaseFileName = @"C:\Users\Darko-Home\Desktop\HandDatabase\prepared\Nenad_Darko\Tomislav 1.xml"; if (capture == null) //a user clicked "X" without data selection { //MessageBox.Show("Capture or database file name is null!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } capture.Open(); if (capture.Length == 0) { MessageBox.Show("The directory does not contain images!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (capture != null && databaseFileName != null) { ObjectAnnotater form = null; //try { form = new ObjectAnnotater(capture, databaseFileName); Application.Run(form); } /*catch (Exception) { var fInfo = new FileInfo(databaseFileName); var autosaveName = fInfo.Name.Replace(fInfo.Extension, String.Empty) + "-autosave" + fInfo.Extension; autosaveName = Path.Combine(fInfo.DirectoryName, autosaveName); form.Database.Save(autosaveName); var msg = "Unfortunately not your fault :/" + "\r\n" + "However your work is successfully saved to:" + "\r\n" + autosaveName; MessageBox.Show(msg, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error); }*/ } capture.Close(); }
public SampleExtraction(Database database, ImageStreamReader capture, Func <long, string> imageKeyFunc) { InitializeComponent(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.database = database; this.capture = capture; this.imageKeyFunc = imageKeyFunc; }
public VideoExtractor(ImageStreamReader imageSource, string outputDir, string fileNameFormat = "img-{0:000}.jpg") { this.imageSource = imageSource; this.outputDir = outputDir; this.fileNameFormat = fileNameFormat; if (!Directory.Exists(outputDir)) Directory.CreateDirectory(outputDir); }
public SampleExtraction(Database database, ImageStreamReader capture, Func<long, string> imageKeyFunc) { InitializeComponent(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.database = database; this.capture = capture; this.imageKeyFunc = imageKeyFunc; }
public VideoExtractor(ImageStreamReader imageSource, string outputDir, string fileNameFormat = "img-{0:000}.jpg") { this.imageSource = imageSource; this.outputDir = outputDir; this.fileNameFormat = fileNameFormat; if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } }
public CaptureDemo() { InitializeComponent(); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; //reader = new CameraCapture(0); //capture from camera //reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome Accord.NET Extensions.mp4")); //capture from video reader = new ImageDirectoryReader(Path.Combine(getResourceDir(), "Sequence"), "*.jpg"); reader.Open(); Application.Idle += capture_NewFrame; }
/// <summary> /// Calls read function defined by the stream and converts an returned image if necessary. /// <para>If the image can not be read (null), null is returned.</para> /// </summary> /// <param name="imageStream">Image stream.</param> /// <returns>Converted image or null if the image can not be read.</returns> public static Image <TColor> ReadAs <TColor>(this ImageStreamReader <IImage> imageStream) where TColor : struct { var image = imageStream.Read(); if (image == null) { return(null); } return(image as Image <TColor>); }
/// <summary> /// Calls read function defined by the stream and converts an returned image if necessary. /// <para>If the image can not be read (null), null is returned.</para> /// </summary> /// <param name="imageStream">Image stream.</param> /// <param name="copyAlways">Forces data copy even if a casting is enough.</param> /// <param name="failIfCannotCast">If data copy is needed throws an exception.</param> /// <returns>Converted image or null if the image can not be read.</returns> public static Image <TColor, TDepth> ReadAs <TColor, TDepth>(this ImageStreamReader <IImage> imageStream, bool copyAlways = false, bool failIfCannotCast = false) where TColor : IColor where TDepth : struct { var image = imageStream.Read(); if (image == null) { return(null); } return(((Image)image).Convert <TColor, TDepth>(copyAlways, failIfCannotCast)); }
public CaptureDemo() { InitializeComponent(); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; reader = new CameraCapture(0); //capture from camera (reader as CameraCapture).FrameSize = new Size(640, 480); //reader = new FileCapture(Path.Combine(getResourceDir(), "Welcome.mp4")); //capture from video //reader = new ImageDirectoryCapture(Path.Combine(getResourceDir(), "Sequence"), "*.jpg"); reader.Open(); Application.Idle += capture_NewFrame; }
public ObjectAnnotater(ImageStreamReader capture, string databaseFileName) { InitializeComponent(); this.capture = capture; drawingManager = new DrawingManager(pictureBox); drawingManager.OnElementSelected += drawingManager_OnElementSelected; this.databaseFileName = databaseFileName; Database = new Database(); Database.Load(databaseFileName); loadCurrentImageAnnotations(); }
public MainForm() { InitializeComponent(); this.picCamera.SizeMode = PictureBoxSizeMode.Zoom; this.picPortrait.SizeMode = PictureBoxSizeMode.Zoom; this.picCamera.Paint += picCamera_Paint; _reader = new CameraCapture(cameraIdx: 0); _reader.Open(); this.FormClosing += MainForm_FormClosing; Application.Idle += Application_Idle; this.btnCapture.Click += btnCapture_Click; this.btnSave.Click += btnSave_Click; }
public KLDemo() { InitializeComponent(); lkStorage = new PyrLKStorage <FlowColor>(pyrLevels: 1); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); prevIm = videoCapture.ReadAs <FlowColor, float>(); oldPositions = prevIm. Convert <Gray, float>(). GoodFeaturesToTrack(winSize, 0.05f) .Select(x => new PointF(x.X, x.Y)).Take(100).ToList(); #else videoCapture = new CameraCapture(0); oldPositions = new List <PointF>(); prevIm = new Image <FlowColor, float>(imgSize); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if (videoCapture is CameraCapture) { (videoCapture as CameraCapture).FrameSize = imgSize; } this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
public KLDemo() { InitializeComponent(); lkStorage = new PyrLKStorage<FlowColor>(pyrLevels: 1); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); prevIm = videoCapture.ReadAs<FlowColor, float>(); oldPositions = prevIm. Convert<Gray, float>(). GoodFeaturesToTrack(winSize, 0.05f) .Select(x => new PointF(x.X, x.Y)).Take(100).ToList(); #else videoCapture = new CameraCapture(0); oldPositions = new List<PointF>(); prevIm = new Image<FlowColor, float>(imgSize); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if(videoCapture is CameraCapture) (videoCapture as CameraCapture).FrameSize = imgSize; this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
public CamshiftDemo() { InitializeComponent(); bar_ValueChanged(null, null); //write values to variables init(); //create histograms try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryReader(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); roi = new Rectangle(180, 285, 75, 120); isROISelected = true; this.barVMin.Value = 100; #else videoCapture = new CameraCapture(0); #endif } catch (Exception) { MessageBox.Show("Cannot find any camera!"); return; } if(videoCapture is CameraCapture) (videoCapture as CameraCapture).FrameSize = new Size(640, 480); //set new Size(0,0) for the lowest one this.FormClosing += CamshiftDemo_FormClosing; Application.Idle += videoCapture_InitFrame; videoCapture.Open(); }
/// <summary> /// Build template with the cemara /// /// State Machine----> /// int -> build template -> resize to find the best -> draw the template then comfirm by user -> /// rotate for angles ->done and return /// /// make sure the object is in green circle /// </summary> /// <param name="name">template name, default to "Template" if the name is null</param> /// <param name="templPyrs">the template list that to be used</param /// <param name="videoCapture">the video stream</param> /// <param name="pictureBox">the picture box of window form</param> /// <param name="minRatio">The ratio of smallest size to original, default to 0.4</param> /// /// <returns>nothing.</returns> public void TemplateCapture(ref List <TemplatePyramid> templPyrs, ImageStreamReader videoCapture, PictureBox pictureBox, string name = null, float minCalibrationRatio = 0.4f) { if (name == null) { name = "Template"; } #if runXML try { Console.WriteLine("Reading from existing Template Data"); templPyrs = fromXML(name); Cap = State.Done; } catch (Exception) { Console.WriteLine("\nTemplate NOT found! \n initiating camera..."); } #endif switch (Cap) { case State.Init: videoCapture.ReadTo(ref frame); if (frame == null) { return; } drawFrameWork(frame); pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color GC.Collect(); break; case State.BuildingTemplate: Console.WriteLine("building template"); videoCapture.ReadTo(ref frame); if (frame == null) { return; } templatePic = frame.ToGray(); //var list = new List<TemplatePyramid>(); try { if (templPyrs == null) { templPyrs = new List <TemplatePyramid>(); } rotateLoad(templPyrs, templatePic, 1, frame.Width(), frame.Height(), userFunc: validateFeatures); } catch (Exception) { Console.WriteLine("ERROR IN CREATING TEMPLATE!"); return; } Cap = State.Calibrate; break; case State.Calibrate: Console.WriteLine("calibrating template " + CabRatio + " " + templatePic.Width() * CabRatio); var bestRepresentatives = findObjects(frame, templPyrs); if (bestRepresentatives.Count == 0) { if (templPyrs.Count != 0) { templPyrs.RemoveAt(templPyrs.Count - 1); } CabRatio -= (float)0.01; int width = (int)(templatePic.Width() * CabRatio); int height = (int)(templatePic.Height() * CabRatio); if (CabRatio < minCalibrationRatio) { Console.WriteLine("Calibration failed"); CabRatio = 1; Cap = State.Init; } DotImaging.Primitives2D.Size Nsize = new DotImaging.Primitives2D.Size(width, height); ResiizedtemplatePic = ResizeExtensions_Gray.Resize(templatePic, Nsize, Accord.Extensions.Imaging.InterpolationMode.NearestNeighbor); try { templPyrs.Add(TemplatePyramid.CreatePyramidFromPreparedBWImage( ResiizedtemplatePic, new FileInfo(name + " #" + TPindex++).Name, 0)); } catch (Exception) { Console.WriteLine("ERROR IN CALIBRATING TEMPLATE!"); } } else { ResiizedtemplatePic = (ResiizedtemplatePic == null ? templatePic : ResiizedtemplatePic); CaptureFrame(templPyrs, videoCapture, pictureBox); drawFrameWork(frame); pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color Cap = State.Confirm; } break; case State.Confirm: Console.WriteLine("comfirm Template, press Y to continue, press R to retry, and other keys to abort"); string a = Console.ReadLine(); switch (a) { case "y": Cap = State.Rotate; break; case "r": templPyrs.RemoveAt(templPyrs.Count - 1); Cap = State.Init; break; default: Cap = State.Done; break; } //if (a == "y") Cap = State.Rotate; //else //{ // Cap = State.Init; //} break; case State.Rotate: int SqrSide = (int)(frame.Height() / Math.Sqrt(2)); templPyrs.AddRange(buildTemplate(ResiizedtemplatePic, SqrSide, SqrSide, false, totalAngles, totalSizes, 0.5f, null, validateFeatures)); //ResiizedtemplatePic, totalAngles, SqrSide, SqrSide, true, userFunc: validateFeatures)); Cap = State.ConfirmDone; break; case State.ConfirmDone: Console.WriteLine("Do you want to build a new template? press y to build another template, other keys to abort"); string OtherTemplate = Console.ReadLine(); if (OtherTemplate == "y" || OtherTemplate == "Y") { Cap = State.Init; } else { string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); XMLTemplateSerializer <ImageTemplatePyramid <ImageTemplate>, ImageTemplate> .ToFile(templPyrs, Path.Combine(resourceDir, name + ".xml")); Cap = State.Done; } break; //break; case State.Done: CaptureFrame(templPyrs, videoCapture, pictureBox); GC.Collect(); break; //break; } pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ImageStreamReader capture = null; string databaseFileName = null; using (var wizard = new Wizard()) { wizard.ShowDialog(); capture = wizard.CaptureObj; databaseFileName = wizard.DatabaseFileName; }//*/ //capture = new ImageDirectoryReader(@"S:\Svjetla - baza podataka\prepared\prednja+straznja-svjetla-4\", "*.jpg"); //databaseFileName = @"S:\Svjetla - baza podataka\prepared\prednja+straznja-svjetla-4.xml";// if (capture == null && databaseFileName == null) //a user clicked "X" without data selection { return; } else if (databaseFileName == null) { MessageBox.Show("Capture or database file name is empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } capture.Open(); if (capture.Length == 0) { MessageBox.Show("The directory does not contain images!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (capture != null && databaseFileName != null) { AnnotaterForm form = null; try { form = new AnnotaterForm(capture, databaseFileName); Application.Run(form); } catch (Exception) { var fInfo = new FileInfo(databaseFileName); var autosaveName = fInfo.Name.Replace(fInfo.Extension, String.Empty) + "-autosave" + fInfo.Extension; autosaveName = Path.Combine(fInfo.DirectoryName, autosaveName); form.Database.Save(autosaveName); var msg = "Unfortunately not your fault :/" + "\r\n" + "However your work is successfully saved to:" + "\r\n" + autosaveName; MessageBox.Show(msg, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error); }//*/ } capture.Close(); }
public FastTPDemo() { InitializeComponent(); initialize(); try { #if FILE_CAPTURE string resourceDir = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources"); videoCapture = new ImageDirectoryCapture(Path.Combine(resourceDir, "ImageSequence"), "*.jpg"); #else videoCapture = new CameraCapture(0); #endif } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if(videoCapture is CameraCapture) (videoCapture as CameraCapture).FrameSize = new Size(640 / 2, 480 / 2); //set new Size(0,0) for the lowest one this.FormClosing += FastTPDemo_FormClosing; Application.Idle += videoCapture_NewFrame; videoCapture.Open(); }
/// <summary> /// Reads an element form the input stream and fills the specified buffer. /// <para>If the read element does not match the specified type a null value will be written.</para> /// </summary> /// <typeparam name="TColor">Color type.</typeparam> /// <param name="imageStream">Image source stream.</param> /// <param name="buffer"> /// Buffer to write to. /// <para>The specified buffer can be null, as it is managed by the function itself.</para> /// </param> public static void ReadTo <TColor>(this ImageStreamReader <IImage> imageStream, ref TColor[,] buffer) where TColor : struct { imageStream.ReadAs <TColor>().CopyToOrCreate(ref buffer); }