private void openYUVFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Project.Folder; openFileDialog.Filter = "txt files (*.yuv)|*.txt|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { String filePath = openFileDialog.FileName; String path = Path.GetDirectoryName(filePath); String filename = Path.GetFileNameWithoutExtension(filePath); String dstFile = path + "\\" + filename + ".bmp"; toolStripProgressBar.Visible = true; BackgroundWorker worker = new BackgroundWorker(); Bitmap result = null; worker.DoWork += delegate(object bgworker, DoWorkEventArgs bge) { result = YUVConverter.Convert(filePath, dstFile, ConsoleLogger); }; worker.RunWorkerCompleted += delegate(object bgworker, RunWorkerCompletedEventArgs bge) { toolStripProgressBar.Visible = false; if (result != null) { SingleImageWnd form = new SingleImageWnd(result); form.MdiParent = this; form.Show(); } }; worker.RunWorkerAsync(); } }
private void cornerDetectorToolStripMenuItem_Click(object sender, EventArgs e) { Bitmap image = new Bitmap(System.Drawing.Image.FromFile(@"C:\OSU3\UAS\Training Videos\ZoltanTestSets\test\DJI_0247.rd.JPG")); float threshold = 0.001f; /*int octaves = (int)numOctaves.Value; * int initial = (int)numInitial.Value;*/ ResizeNearestNeighbor filter = new ResizeNearestNeighbor(600, 400); image = filter.Apply(image); // Create a new SURF Features Detector using the given parameters SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector(threshold); List <SpeededUpRobustFeaturePoint> points = surf.ProcessImage(image); // Create a new AForge's Corner Marker Filter FeaturesMarker features = new FeaturesMarker(points, 5); // Apply the filter and display it on a picturebox Bitmap image_feature = features.Apply(image); SingleImageWnd form = new SingleImageWnd(image_feature); form.MdiParent = this; form.Show(); /*Bitmap image = new Bitmap(System.Drawing.Image.FromFile(@"C:\OSU3\CAR\Reports\Targets\Target1\DSC00217.JPG")); * Bitmap image2 = new Bitmap(image.Width, image.Height); * * using (Graphics g = Graphics.FromImage(image2)) * { * g.DrawImage(image, 0, 0); * * Grayscale filter = new Grayscale(.33, .33, .33); * image = filter.Apply(image); * * double sigma = 2; * float k = 4 / 10; * float threshold = 500; * * // Create a new Harris Corners Detector using the given parameters * HarrisCornersDetector harris = new HarrisCornersDetector(k) * { * Measure = HarrisCornerMeasure.Harris, //: HarrisCornerMeasure.Noble, * Threshold = threshold, * Sigma = sigma * }; * * List<IntPoint> corners = harris.ProcessImage(image); * * foreach (IntPoint corner in corners) * { * //A circle with Red Color and 2 Pixel wide line * //gf.DrawEllipse(new Pen(Color.Red, 2), new Rectangle(0, 0, 200, 200)); * DrawCircle(g, new Pen(Color.Red, 1), corner.X, corner.Y, 1); * } * * } * * ImageForm form = new ImageForm(image2); * form.MdiParent = this; * form.Show();*/ }