public override HMessage ActorTask(HMessage imsg)
        {
            HTuple row, column, angle, score;
            HImage img = new HImage(imsg.GetMessageObj("image"));

            if (sbm == null)
            {
                return(GenFinishMessage());
            }
            HMessage msg = new HMessage();

            msg.SetMessageObj(img, "image");
            Monitor.Enter(lockobj);
            try
            {
                sbm.FindShapeModel(img, -Math.PI, 2 * Math.PI, 0.5, 1, 0.5,
                                   "least_squares", 0, 0.9, out row, out column, out angle, out score);
                if (row.Length > 0)
                {
                    HXLDCont  contours = sbm.GetShapeModelContours(1);
                    HHomMat2D homMat2D = new HHomMat2D();
                    homMat2D.VectorAngleToRigid(0.0, 0.0, 0.0, row.D, column.D, angle.D);
                    HXLDCont projcont = homMat2D.AffineTransContourXld(contours);
                    msg.SetMessageObj(projcont, "contour");
                }
            }
            finally
            {
                Monitor.Exit(lockobj);
            }
            imsg.Dispose();
            return(msg);
        }
Beispiel #2
0
        public void AddMessage(HMessage objs)
        {
            HTuple finish = objs.GetMessageParam("key_exists", "finish_processing");

            if ((int)finish == 0)
            {
                HTuple hasmatch = objs.GetMessageParam("key_exists", "contour");
                if ((int)hasmatch == 1)
                {
                    AddToStack(objs.GetMessageObj("contour"));
                }
                AddToStack(objs.GetMessageObj("image"));
            }
            DisplayResults();

            // clean up previously sent HALCON objects
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
        public override HMessage ActorTask(HMessage imsg)
        {
            HImage  img = new HImage(imsg.GetMessageObj("image"));
            HRegion roi = new HRegion(ActiveObject);
            HObject obj = new HObject();

            if (roi != null)
            {
                obj.ConcatObj(img);
                obj.ConcatObj(img.ReduceDomain(roi).SobelAmp("sum_abs", 3));
            }
            else
            {
                obj.ConcatObj(img.SobelAmp("sum_abs", 3));
            }
            HMessage msg = new HMessage();

            msg.SetMessageObj(obj, "filter_image");
            return(msg);
        }