Exemple #1
0
        public void AttachDrawObj(HDrawingObject obj)
        {
            drawing_objects.Add(obj);
            obj.OnDrag(SobelFilter);
            obj.OnAttach(SobelFilter);
            obj.OnResize(SobelFilter);
            obj.OnSelect(OnSelectDrawingObject);
            obj.OnAttach(SobelFilter);

            //HObject region = null;

            //if (obj.GetDrawingObjectParams("type") == "line")
            //{
            //    HTuple a = obj.GetDrawingObjectParams("row1");
            //    HOperatorSet.GenRegionLine(out region, obj.GetDrawingObjectParams("row1"),
            //        obj.GetDrawingObjectParams("column1"), obj.GetDrawingObjectParams("row2"),
            //        obj.GetDrawingObjectParams("column2"));
            //}
            //else
            //{
            //    region = new HRegion(obj.GetDrawingObjectIconic());
            //}

            //AddToStack(region);
            if (selected_drawing_object == null)
            {
                selected_drawing_object = obj;
            }
            // hsmartControl.HalconWindow.AttachDrawingObjectToWindow(obj);
            HOperatorSet.AttachDrawingObjectToWindow(m_windowHandle, obj);
        }
 public void AttachDrawObj(HDrawingObject obj)
 {
     drawing_objects.Add(obj);
     // The HALCON/C# interface offers convenience methods that
     // encapsulate the set_drawing_object_callback operator.
     obj.OnDrag(user_actions.SobelFilter);
     obj.OnAttach(user_actions.SobelFilter);
     obj.OnResize(user_actions.SobelFilter);
     obj.OnSelect(OnSelectDrawingObject);
     obj.OnAttach(user_actions.SobelFilter);
     //if (selected_drawing_object == null)
     selected_drawing_object = obj;
     halconWindow.HalconWindow.AttachDrawingObjectToWindow(obj);
 }
Exemple #3
0
        public HALCONDialog()
        {
            InitializeComponent();

            width_ratio        = halconWindow.Width / (float)Width;
            height_ratio       = halconWindow.Height / (float)Height;
            buttonRun.Location =
                new Point(buttonRun.Location.X,
                          halconWindow.Location.Y + halconWindow.Height + 10);
            buttonStop.Location =
                new Point(buttonStop.Location.X,
                          halconWindow.Location.Y + halconWindow.Height + 10);

            HOperatorSet.GenCrossContourXld(out dummy, -10, -10, 5, 0);
            halconWindow.HalconWindow.SetColor("green");
            halconWindow.HalconWindow.SetLineWidth(2);
            // Allow the shape model to be found when lying partly outside of the image
            HOperatorSet.SetSystem("border_shape_models", "true");

            //  the drawing object allows the user to dynamically select the ROI
            //  and see how it affects to the resulting shape based model
            roi_object = new HDrawingObject(350.0, 400.0, 0.0, 200.0, 100.0);
            HImage img = new HImage("metal-parts/circle_plate_01");
            HTuple width, height;

            img.GetImageSize(out width, out height);
            halconWindow.HalconWindow.SetPart(-1.0, -1.0, height - 1, width - 1);
            delayCheckBox.Checked = true;

            dummy_msg = new HMessage();
            HOperatorSet.GenEmptyObj(out dummy);
            dummy_msg.SetMessageObj(dummy, "dummy");
            // this example emulates the case where one continuously grabs images
            // in order to adapt the camera parameters so that the image processing
            // works properly. In this case, the framegrabber acquires the same image
            // continuously.
            createsbm = new ShapeModelDisplay("metal-parts/circle_plate_01", roi_object, this);
            createsbm.Start();

            roi_object.OnAttach(DefineShapeBasedModel);
            roi_object.OnDrag(DefineShapeBasedModel);
            roi_object.OnResize(DefineShapeBasedModel);
            halconWindow.HalconWindow.AttachDrawingObjectToWindow(roi_object);
            halconWindow.HalconWindow.SetColor("green");

            //  initialize the chain of responsibility pattern
            findsbm    = new ShapeModelFinder(this);
            imggrabber = new ImageGrabber("circle_plate.seq", findsbm);
        }