// 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); } } }
public static Texture2D captureFrame() { const int DOWN_SAMPLE_RATE = 1; int FRAME_WIDTH = 2048; Texture2D frame; IPcLink link = HPPC.CreateLink(); IPcMoment moment = link.CaptureMoment(); IPcPicture picture = link.ExtractPicture(moment); Bitmap bmp = SproutExtension.createBitmap(picture.Image); GraphicsUnit units = GraphicsUnit.Pixel; RectangleF rect = bmp.GetBounds(ref units); int width = (int)rect.Width / DOWN_SAMPLE_RATE, height = (int)rect.Height / DOWN_SAMPLE_RATE; frame = new Texture2D(FRAME_WIDTH, FRAME_WIDTH); int xOffset = (width / 2) - (FRAME_WIDTH / 2); int yOffset = (height / 2) - (FRAME_WIDTH / 2); UnityEngine.Color[] colors = new UnityEngine.Color[FRAME_WIDTH * FRAME_WIDTH]; for (int x = 0; x < FRAME_WIDTH; x++) { for (int y = 0; y < FRAME_WIDTH; y++) { System.Drawing.Color sysColor = bmp.GetPixel(xOffset + x, yOffset + y); Color32 uc32 = new Color32(sysColor.R, sysColor.B, sysColor.G, sysColor.A); //UnityEngine.Color unityColor = new UnityEngine.Color((float)sysColor.R / 255f, (float)sysColor.G / 255f, (float)sysColor.B / 255f, (float)sysColor.A / 255f); int index = (FRAME_WIDTH - 1 - y) * FRAME_WIDTH + x; if (index < colors.Length && index >= 0) { colors[index] = uc32; } else { Debug.Log("Index out of range."); } } } // test - only take a square of pixels in middle of screen frame.SetPixels(colors); frame.Apply(); TextureScale.Point(frame, 1024, 1024); return(frame); }
// 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); } }