Пример #1
0
        // 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();
            }
        }
Пример #2
0
        // 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);
            }
        }
Пример #3
0
        // 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);
            }
        }
Пример #4
0
        public void HandleProjection(System.Windows.Controls.Image img)
        {
            IPcLink link = HPPC.CreateLink();

            Form matForm = new Form();

            IPcWindowRegistration registration = null;

            //Instantiates a FormWindowManager to Display the window through the WindowRegistration instance
            ProjectedWindow manager = new ProjectedWindow(matForm);

            //Requesting Sprout's HW specification
            IPcSpecification spec = link.AccessSpecification();

            IPcTouch touch = null;

            matForm.Show();

            //Event raised when the Form handle is created
            matForm.HandleCreated += (sender, eventArgs) =>
            {
                // Register this window in the Sprout Platform.
                registration = link.RegisterWindow(matForm.Handle.ToInt64());

                // Loading Sprout's touch handler for this window
                touch = link.AccessTouch(registration);
            };

            matForm.Load += (sender, eventArgs) =>
            {
                //Display the window using the appropriate IPcWindowManager
                registration.Display(manager);

                //Make the input layer available for the user
                using (IPcTouchLayer layer = touch.GetTouchLayer(spec.Touch.Input))
                {
                    layer.Enable();
                }

                // Adding a simple UI control (button) to allow closing the application
                System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
                matForm.Controls.Add(btn);
                btn.Bounds = new Rectangle(2, 2, 40, 30);
                btn.Text   = "Close";
                btn.Click += (s, e) =>
                {
                    matForm.Close();
                };
            };


            //Called when the the window handle is destroyed by the application
            matForm.HandleDestroyed += (sender, eventArgs) =>
            {
                // Hiding the input layer
                using (IPcTouchLayer layer = touch.GetTouchLayer(spec.Touch.Input))
                {
                    layer.Disable();
                }

                //Unregister the window within the platform
                registration.Unregister();
            };

            //When the form is disposed we dispose remaining resources allocated in this scope
            matForm.Disposed += (sender, eventArgs) =>
            {
                touch.Dispose();
                spec.Dispose();
                registration.Dispose();
                manager.Dispose();
                link.Dispose();
            };

            Application.Run(matForm);
        }