Esempio n. 1
0
        protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img)
        {
            if (_take_texture_image)
            {
                _take_texture_image = false;
                _texture_image      = img.Copy();
                lock (Context.Viewer) {
                    UpdateAllColors();
                }
            }

            if (_clear_points)
            {
                _clear_points = false;
                _pixel_point_ids.Reset();
                Context.Setup.ScanWorkflow.Reset();
                _pointcloud.ClearPoints();
            }

            // Update the transformation between positioner coordinate system and camera coordinate system
            if (_update_positioner_transformation)
            {
                _update_positioner_transformation = false;
                Context.Setup.Positioner.UpdateTransformation(Context.Setup.Camera);
                _pixel_point_ids.Reset();
                Context.Setup.ScanWorkflow.Reset();
            }

            if (Context.Setup.Camera.FrameSize != _pixel_point_ids.Size)
            {
                _pixel_point_ids.Size = Context.Setup.Camera.FrameSize;
            }

            List <Vector> points;
            List <System.Drawing.Point> pixels;

            if (Context.Setup.ScanWorkflow.Process(Context.Setup, img, out points, out pixels))
            {
                lock (Context.Viewer) {
                    UpdatePoints(points, pixels);
                }
                foreach (System.Drawing.Point p in pixels)
                {
                    img[p.Y, p.X] = new Bgr(Color.Green);
                }
            }
        }
Esempio n. 2
0
        protected override void OnFrame(Parsley.Core.BuildingBlocks.FrameGrabber fp, Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> img)
        {
            #region take texture
            if (_take_texture_image) //even handler jika mengambil texture image
            {
                _take_texture_image = false;
                _texture_image      = img.Copy();
                lock (Context.Viewer)
                {
                    UpdateAllColors();
                }
            }
            #endregion

            #region clear point
            if (_clear_points)
            { //even handler jika menghapus point 3d yg sdh ada
                _clear_points = false;
                _pixel_point_ids.Reset();
                Context.Setup.ScanWorkflow.Reset();
                _pointcloud.ClearPoints();
            }
            #endregion

            #region update positioner
            // Update the transformation between positioner coordinate system and camera coordinate system
            if (_update_positioner_transformation)
            {
                _update_positioner_transformation = false;
                Context.Setup.Positioner.UpdateTransformation(Context.Setup.Camera);
                _pixel_point_ids.Reset();
                Context.Setup.ScanWorkflow.Reset();
            }
            #endregion

            #region penyesuaian proporsi pixel dengan frame size
            if (Context.Setup.Camera.FrameSize != _pixel_point_ids.Size)
            {
                _pixel_point_ids.Size = Context.Setup.Camera.FrameSize;
            }
            #endregion

            List <Vector> points; //array penyimpan koordinat  //sepertinya ini yang out of range
            List <System.Drawing.Point> pixels;

            #region start scanning
            if (_start_scanning)
            {
                //Console.Write(Context.Setup.ScanWorkflow.Process(Context.Setup, img, out points, out pixels));

                if (Context.Setup.ScanWorkflow.Process(Context.Setup, img, out points, out pixels)) //Jika syarat2 dalam scanworkflow.process terpenuhi maka akan ditambahkan pointcloudnya.
                {
                    Console.WriteLine(pixels.Count);
                    lock (Context.Viewer)
                    {
                        UpdatePoints(points, pixels); //memanggil fungsi UpdatePoints untuk update model 3d setiap waktu, tanpa perduli terdeteksi ada nilai baru atau tidak
                    }
                    foreach (System.Drawing.Point p in pixels)
                    {
                        img[p.Y, p.X] = new Bgr(Color.Green);
                    }
                }
            }

            #endregion
        }