// Outlines capture public static OutlineParameters ConfirmCapture() { try { OutlineParameters op; using (IPcLink link = HPPC.CreateLink()) { using (IPcMoment moment = link.CaptureMoment()) { IPcPicture picture = link.ExtractPicture(moment); IPcOutline outline = link.ExtractOutline(moment); op = PictureHandling.SavePicture(picture, outline); outline.Dispose(); picture.Dispose(); moment.Dispose(); } link.Dispose(); } return(op); } catch (Exception exception) { Console.WriteLine("\t\t*****An error occurred*****\n\n{0}{1}\n\nExit now, or this console will automatically exit in 15 seconds.", ToolBox.TimeStamp(), exception.Message); ToolBox.AppExceptionExit(); return(null); } }
// Picture by index capture public static void Capture(Task t, bool repetition) { try { using (IPcLink link = HPPC.CreateLink()) { using (IPcMoment moment = link.CaptureMoment()) { IPcPicture picture = link.ExtractPicture(moment); IPcOutline outline = link.ExtractOutline(moment); if (!repetition) { PictureHandling.SaveIndexedImage(picture, outline, t); } else { PictureHandling.SaveIndexedImageRep(picture, outline, t); } outline.Dispose(); picture.Dispose(); moment.Dispose(); } link.Dispose(); } } catch (Exception exception) { Console.WriteLine("\t\t*****An error occurred*****\n\n{0}{1}\n\nExit now, or this console will automatically exit in 15 seconds.", ToolBox.TimeStamp(), exception.Message); ToolBox.AppExceptionExit(); } }
// Several pictures extracted by index internal static object[] getSamples(List <string> folders, List <int> indexes, List <PcPhysicalPoint> locations, List <System.Drawing.Point> sizes) { try { using (IPcLink link = HPPC.CreateLink()) { object[] returned; using (IPcMoment moment = link.CaptureMoment()) { IPcPicture picture = link.ExtractPicture(moment); IPcOutline outlines = link.ExtractOutline(moment); returned = PictureHandling.SaveSamples(picture, outlines, folders, indexes, locations, sizes); outlines.Dispose(); picture.Dispose(); moment.Dispose(); } link.Dispose(); return(returned); } } catch (Exception exception) { Console.WriteLine("\t\t*****An error occurred*****\n\n{0}{1}\n\nExit now, or this console will automatically exit in 15 seconds.", ToolBox.TimeStamp(), exception.Message); ToolBox.AppExceptionExit(); return(null); } }
// Picture by index capture public static void Capture(Task t) { using (IPcLink link = HPPC.CreateLink()) { using (IPcMoment moment = link.CaptureMoment()) { IPcPicture picture = link.ExtractPicture(moment); PictureHandling.SaveIndexedImage(picture, t); } } }
// Several pictures extracted by index internal static List <Image> getSamples(List <string> folders, List <int> indexes) { try { using (IPcLink link = HPPC.CreateLink()) { using (IPcMoment moment = link.CaptureMoment()) { IPcPicture picture = link.ExtractPicture(moment); List <Image> img = PictureHandling.SaveSamples(picture, folders, indexes); return(img); } } } catch (Exception exception) { Console.WriteLine("\t\t*****An error occurred*****\n\n{0}{1}\n\nExit now, or this console will automatically exit in 15 seconds.", ToolBox.TimeStamp(), exception.Message); ToolBox.AppExceptionExit(); return(null); } }
private void Cancel_Button_Click(object sender, RoutedEventArgs e) { PictureHandling.SweepPicture(); this.Close(); }
// Parameters are received from MainPage listing the features of the new captures to be built // In this method they are built and added to the UI public void AddCaptures(List <int[]> parameters, List <int> ind, List <string> folders, List <bool[]> analysis, List <string> names, List <PcPhysicalPoint> locations, List <System.Drawing.Point> sizes, List <string> maps) { MainCapture mc = new MainCapture(); List <Image> samples = new List <Image>(); List <IPcOutline> outlines; object[] returnable = new object[3]; returnable = mc.Samples(folders, ind, locations, sizes); samples = (List <Image>)returnable[0]; outlines = (List <IPcOutline>)returnable[1]; List <int> moved = (List <int>)returnable[2]; // Capture Window holds the control of a process. int previousCaptures = capturesList.Count; for (int i = 0; i < parameters.Count; i++) { if (moved[i] != 2) { PcPhysicalPoint location = new PcPhysicalPoint(outlines[i].PhysicalBoundaries.Location.X * (outlines[i].PixelDensity.X), outlines[i].PhysicalBoundaries.Location.Y * (outlines[i].PixelDensity.Y)); System.Drawing.Point size = new System.Drawing.Point(Convert.ToInt32(PictureHandling.GetOutlineWidth(outlines[i])), Convert.ToInt32(PictureHandling.GetOutlineHeight(outlines[i]))); if (moved[i] == 0) { capturesList.Add(new CaptureWindow(this, samples.ElementAt(i), parameters.ElementAt(parameters.Count - 1 - i), folders.ElementAt(folders.Count - 1 - i), analysis.ElementAt(analysis.Count - 1 - i), names.ElementAt(names.Count - 1 - i), location, size, false, maps.ElementAt(maps.Count - 1 - i))); } else { capturesList.Add(new CaptureWindow(this, samples.ElementAt(i), parameters.ElementAt(parameters.Count - 1 - i), folders.ElementAt(folders.Count - 1 - i), analysis.ElementAt(analysis.Count - 1 - i), names.ElementAt(names.Count - 1 - i), location, size, true, maps.ElementAt(maps.Count - 1 - i))); } capturesList.ElementAt(i + previousCaptures).Uid = (i + previousCaptures).ToString(); samplesList.Add(samples.ElementAt(i)); samplesList.ElementAt(i + previousCaptures).Uid = (i + previousCaptures).ToString(); capturesNames.Add(names.ElementAt(names.Count - 1 - i)); numberCapturesRunning++; } else { MessageBox.Show("Capture of process " + names.ElementAt(names.Count - 1 - i) + " could not be accomplished. Object not found."); return; } } // UI modification according to new situation sampleSP.Children.Clear(); sampleSP.Children.Add(samplesList.ElementAt(0)); infoLabel.Content = "Process 1/" + capturesList.Count.ToString(); if (capturesList.Count >= 2) { rightSp.Visibility = Visibility.Visible; leftSp.Visibility = Visibility.Visible; } MainPage.capturesRunning = true; Border1.Visibility = Visibility.Visible; Border2.Visibility = Visibility.Visible; sampleSP.Visibility = Visibility.Visible; infoLabel.Visibility = Visibility.Visible; nameLabel.Visibility = Visibility.Visible; ShowButton.IsEnabled = true; // If this is the first time if (parameters.Count == capturesList.Count) { ArtificialScroll(); } }