// Constructor public LevelsLinearForm(AForge.Imaging.ImageStatistics imgStat) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.imgStat = imgStat; if (!imgStat.IsGrayscale) { // RGB picture channelCombo.Items.AddRange(new object[] {"Red", "Green", "Blue"}); channelCombo.Enabled = true; } else { // grayscale picture channelCombo.Items.Add("Gray"); channelCombo.Enabled = false; allCheckBox.Enabled = false; } channelCombo.SelectedIndex = 0; filterPreview.Filter = filter; }
private void VideoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Invoke((MethodInvoker)delegate { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } Bitmap clone = (Bitmap)eventArgs.Frame.Clone(); try { Rectangle rect = new Rectangle(0, 0, eventArgs.Frame.Width, eventArgs.Frame.Height); System.Drawing.Imaging.BitmapData bmpData = eventArgs.Frame.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, eventArgs.Frame.PixelFormat); IntPtr ptr = bmpData.Scan0; var bytes = _encoder.EncodeFrame(ptr); eventArgs.Frame.UnlockBits(bmpData); if (bytes != null && bytes.Length > 0) { _writer.Write(bytes); _socket.SendTo(bytes, _endPoint); } } catch (Exception e) { Console.WriteLine(e.Message); } pictureBox1.Image = clone; }); }
void device_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Bitmap shoot = eventArgs.Frame.Clone() as Bitmap; try { frameCounter++; if (frameCounter > 10) { invoices = invoiceProcess.GetInvoiceCollection(shoot); frameCounter = 0; } if (invoices!=null&&invoices.Count>0) { using (Graphics graph = Graphics.FromImage(shoot)) { foreach (Invoice invoice in invoices) { graph.DrawPolygon(pen, invoice.Corners); //Draw a polygon around card PointF point = invoiceProcess.GetStringPoint(invoice.Corners); //Find Top left corner point.Y += 10; graph.DrawString(invoice.Code == null ? "" : invoice.Code, font, Brushes.Lime, point); //Write string on card } } } //Draw Rectangle around cards and write card strings on card } catch (Exception ex) { File.AppendAllText("e:\\error.txt",ex.Message); throw; } pb_Cinema.Image = ResizeShoot(shoot); }
public void setImagePoint(AForge.Point[] imagePoints) { pointCord1.Text = imagePoints[0].ToString(); pointCord2.Text = imagePoints[1].ToString(); pointCord3.Text = imagePoints[2].ToString(); pointCord4.Text = imagePoints[3].ToString(); }
private void _videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { if (OnNewFrame != null) { OnNewFrame(eventArgs.Frame); } }
/// <summary> /// Generates the next boardstate or returns false if unable /// </summary> private Board generate(AForge.Genetic.ShortArrayChromosome max, Board b) { Debug.Assert(b.Turn % 2 == 0); int i = b.Turn / 2; Move m = b.legalMoves[max.Value[i] % b.legalMoves.Count]; return b.generate(m); }
public Sample( string imageName, AForge.Point[] imagePoints, Vector3[] modelPoints, float focalLength, bool isCoplanar ) { ImageName = imageName; ImagePoints = imagePoints; ModelPoints = modelPoints; FocalLength = focalLength; IsCoplanar = isCoplanar; }
public AForge.Point NormalEnd { get; set; } // (needed in drawing, avoid calculating twice) public Component(AForge.Point centr, double alignmnt, List<IntPoint> outln, LineSegment lngst, AForge.Point Nstart, AForge.Point Nend) { Center = centr; Alignment = alignmnt; Outline = outln; Longest = lngst; NormalStart = Nstart; NormalEnd = Nend; }
public bool CheckPoint(AForge.IntPoint pt) { float radius = 20.0f; return (Points.FindAll((p) => { if (p.DistanceTo(pt) <= 2 * radius) { return true; } return false; }).Count > 0); }
public void NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { if (pictureBoxVideo.Image != null) { pictureBoxVideo.Image.Dispose(); } bitmap = (Bitmap) eventArgs.Frame.Clone(); //processedBitmap = PedestrianMain.Find(new Image<Bgr, byte>((Bitmap)eventArgs.Frame.Clone()), out processingTime); //pictureBoxVideo.Image = processedBitmap.ToBitmap(); pictureBoxVideo.Image = getProcessedBitmap(bitmap); }
public static Polygon ToPolygon(this AForge.Imaging.Blob blob, AForge.Imaging.BlobCounterBase counter, AForge.Math.Geometry.IConvexHullAlgorithm hullAlgorithm) { List<AForge.IntPoint> leftPoints, rightPoints, edgePoints; counter.GetBlobsLeftAndRightEdges(blob, out leftPoints, out rightPoints); edgePoints = leftPoints.Union(rightPoints).ToList(); var hull = hullAlgorithm.FindHull(edgePoints); // blob's convex hull return new Polygon(blob.Rectangle, from point in hull select point.ToPoint(), new System.Drawing.Point((int)(blob.CenterOfGravity.X), (int)(blob.CenterOfGravity.Y))); }
// Constructor public YCbCrLinearForm(AForge.Imaging.ImageStatisticsYCbCr imgStat) { // // Required for Windows Form Designer support // InitializeComponent(); // this.imgStat = imgStat; componentCombo.SelectedIndex = 0; filterPreview.Filter = filter; }
// Mouse cursor's position has changed within histogram control private void histogramControl_PositionChanged( object sender, AForge.Controls.HistogramEventArgs e ) { if ( histogram != null ) { int pos = e.Position; if ( pos != -1 ) { textBox.Text = string.Format( "Value: {0} Count: {1} Percent: {2:F2}", pos, histogram.Values[pos], ( (float) histogram.Values[pos] * 100 / histogram.TotalCount ) ); } else { textBox.Text = string.Empty; } } }
// Mouse cursor's position has changed within histogram control private void histogram_PositionChanged( object sender, AForge.Controls.HistogramEventArgs e ) { int pos = e.Position; if ( pos != -1 ) { levelLabel.Text = pos.ToString( ); countLabel.Text = activeHistogram.Values[pos].ToString( ); percentileLabel.Text = ( (float) activeHistogram.Values[pos] * 100 / stats.PixelsCount ).ToString( "F2" ); } else { levelLabel.Text = ""; countLabel.Text = ""; percentileLabel.Text = ""; } }
// Selection has changed within histogram control private void histogramControl_SelectionChanged( object sender, AForge.Controls.HistogramEventArgs e ) { if ( histogram != null ) { int min = e.Min; int max = e.Max; int count = 0; // count pixels for ( int i = min; i <= max; i++ ) { count += histogram.Values[i]; } textBox.Text = string.Format( "Values: {0}...{1} Count: {2} Percent: {3:F2}", min, max, count, ( (float) count * 100 / histogram.TotalCount ) ); } }
public void videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Bitmap bmp = (Bitmap)eventArgs.Frame.Clone(); string fullPath = ConfigInfo.FileDir; string ipath = fullPath + "GP.jpg"; bmp.Save(ipath, ImageFormat.Jpeg); pic.Image = bmp; Clscamera.videoSource.NewFrame -= new NewFrameEventHandler(videoSource_NewFrame); /////////////////////////// //把图片发送至服务器 //// //MessageBox.Show("操作完成,3秒后程序关闭。。。。。。", "提示", MessageBoxIcon.Information); //Tip tip = new Tip("操作完成,3秒后程序关闭。。。。。。"); //tip.Show(); //System.Threading.Thread.Sleep(3000); //tip.Dispose(); }
public void viewSceneMarker(int id, AForge.Math.Matrix4x4 mtxProj, System.Drawing.Bitmap cameraImg) { if (videoMode) { // viewMoveLayerAndCameraLayer(); updateDisplayCameraLayer(cameraImg); if (moveLayerScene.getMoveStop()) { videoMode = false; } } else { string mediumType = piktoViewDB.getMediaType(id); string mediumName = piktoViewDB.getMediaName(id); if (mediumName != "null") { if (mediumType == "video") { viewMoveLayerAndCameraLayer(); moveLayerScene.setMove(mediumName); moveLayerScene.playMove(); videoMode = true; } if (mediumType == "3dobject") { List<E3DModel> list = new List<E3DModel>(); list.Add(new E3DModel(mediumName, mtxProj, 80.0f)); view3DModelLayerAndCameraLayer(); model3dSceneLayer.setModels(list); updateDisplayCameraLayer(cameraImg); } } else { updateDisplayCameraLayer(cameraImg); } } }
public void videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Bitmap bmp = (Bitmap)eventArgs.Frame.Clone(); //string fullPath = txtDir.Text + "\\temp\\"; string ipath = path + "\\" + "GP_" + count++.ToString() + ".jpg"; bmp.Save(ipath, ImageFormat.Jpeg); //动态添加控件有问题,会在添加控件前再次执行GP if (flag) i = count - 1; if (i == count - 1) { ////////////*********************8/////////////// //图片名需得和截图分开,因为改变文本框会影响newFrame //////////////////////////////////////////////////// if (pictureBox3.Image != null) pictureBox3.Image.Dispose(); pictureBox3.Image = System.Drawing.Image.FromFile(ipath); //textBox3.Text = ipath.Substring(ipath.LastIndexOf("\\" + 2)); string imgp = @path + "\\" + "GP_" + (count - 2).ToString() + ".jpg"; string imgpp = @path + "\\" + "GP_" + (count - 3).ToString() + ".jpg"; if (File.Exists(@imgp)) { if (pictureBox2.Image != null) pictureBox2.Image.Dispose(); pictureBox2.Image = System.Drawing.Image.FromFile(@imgp); // textBox2.Text = imgp.Substring(imgp.LastIndexOf("\\")+2); } if (File.Exists(@imgpp)) { if (pictureBox1.Image != null) pictureBox1.Image.Dispose(); pictureBox1.Image = System.Drawing.Image.FromFile(@imgpp); //textBox3.Text = imgpp.Substring(imgpp.LastIndexOf("\\") +2); } } else { } Clscamera.videoSource.NewFrame -= new NewFrameEventHandler(videoSource_NewFrame); }
void _mStream_PlayingFinished(object sender, AForge.Video.ReasonToFinishPlaying reason) { videoPlayback1.CurrentState = VideoPlayback.PlaybackState.Stopped; }
void videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { }
/// <summary> /// Matches two sets of points using RANSAC. /// </summary> /// /// <returns>The homography matrix matching x1 and x2.</returns> /// public float[,] Estimate(AForge.Point[] points1, AForge.Point[] points2) { // Initial argument checks if (points1.Length != points2.Length) throw new ArgumentException("The number of points should be equal."); if (points1.Length < 7) throw new ArgumentException("At least eight points are required."); PointF[] p1 = new PointF[points1.Length]; PointF[] p2 = new PointF[points2.Length]; for (int i = 0; i < points1.Length; i++) { p1[i] = new PointF(points1[i].X, points1[i].Y); p2[i] = new PointF(points2[i].X, points2[i].Y); } return Estimate(p1, p2); }
void device__NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { if (OnFrame != null) OnFrame.Invoke(this, new FrameEventArgs { Image = eventArgs.Frame }); }
public USBMocapRecorder(AForge.Video.DirectShow.VideoCaptureDevice device, string name, string moniker) { device_ = device; Name = name; Moniker = moniker; }
void MStreamNewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { if (eventArgs.Frame != null) { UnmanagedImage umi = UnmanagedImage.FromManagedImage(eventArgs.Frame); videoPlayback1.LastFrame = umi.ToManagedImage(); } if (_firstFrame) { videoPlayback1.ResetActivtyGraph(); videoPlayback1.Duration = TimeSpan.FromMilliseconds(_mStream.Duration).ToString().Substring(0, 8); _firstFrame = false; if (_mStream.RecordingFormat != null) { _mStream.Listening = true; _mStream.WaveOutProvider.BufferLength = _mStream.WaveOutProvider.WaveFormat.AverageBytesPerSecond*2; _mStream.VolumeProvider = new VolumeWaveProvider16New(_mStream.WaveOutProvider); WaveOut = new DirectSoundOut(100); WaveOut.Init(_mStream.VolumeProvider); WaveOut.Play(); } } videoPlayback1.Time = TimeSpan.FromMilliseconds(_mStream.Time).ToString().Substring(0, 8); var pc = Convert.ToDouble(_mStream.Time)/_mStream.Duration; var newpos = pc * 100d; if (newpos < 0) newpos = 0; if (newpos > 100) newpos = 100; videoPlayback1.Value = newpos; }
void videoSource_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { //Cast the frame as Bitmap object and don't forget to use ".Clone()" otherwise //you'll probably get access violation exceptions pictureBoxVideo.BackgroundImage = (Bitmap)eventArgs.Frame.Clone(); }
/// <summary> /// Returns point who has minimum x and y /// </summary> /// <param name="points">Points to be searched</param> /// <returns>Returns point who has minimum x and y</returns> public static AForge.Point GetStringPoint(AForge.Point[] points) { AForge.Point[] tempArr = new AForge.Point[points.Length]; Array.Copy(points, tempArr, points.Length); Array.Sort(tempArr, new PointComparer()); return tempArr[0].X < tempArr[1].X ? tempArr[0] : tempArr[1]; }
// Open video source private void OpenVideoSource(AForge.Video.IVideoSource source) { // set busy cursor this.Cursor = Cursors.WaitCursor; // close previous video source CloseVideoSource(); // create camera Camera camera = new Camera(source, null); //camera.NewFrame += new EventHandler(camera_NewFrame); // start camera camera.Start(); // attach camera to camera window gridBox.Camera = camera; this.Cursor = Cursors.Default; }
/// <summary> /// Initializes a new instance of the <see cref="TexturedMerge"/> class. /// </summary> /// /// <param name="generator">Texture generator.</param> /// public TexturedMerge( AForge.Imaging.Textures.ITextureGenerator generator ) : this( ) { this.textureGenerator = generator; }
/// <summary> /// Matches two sets of points using RANSAC. /// </summary> /// /// <returns>The homography matrix matching x1 and x2.</returns> /// public MatrixH Estimate(AForge.Point[] points1, AForge.Point[] points2) { // Initial argument checks if (points1.Length != points2.Length) throw new ArgumentException("The number of points should be equal."); if (points1.Length < 4) throw new ArgumentException("At least four points are required to fit an homography"); PointF[] p1 = new PointF[points1.Length]; PointF[] p2 = new PointF[points2.Length]; for (int i = 0; i < points1.Length; i++) { p1[i] = new PointF(points1[i].X, points1[i].Y); p2[i] = new PointF(points2[i].X, points2[i].Y); } return Estimate(p1, p2); }
/// <summary> /// Initializes a new instance of the <see cref="Texturer"/> class. /// </summary> /// /// <param name="generator">Texture generator.</param> /// <param name="filterLevel">Filter level value (see <see cref="FilterLevel"/> property).</param> /// <param name="preserveLevel">Preserve level value (see <see cref="PreserveLevel"/> property).</param> /// public Texturer( AForge.Imaging.Textures.ITextureGenerator generator, double filterLevel, double preserveLevel ) : this( ) { this.textureGenerator = generator; this.filterLevel = filterLevel; this.preserveLevel = preserveLevel; }