Exemplo n.º 1
0
        private void ChangePositionOfROI(int x, int y)
        {
            iBaseROI crect = (iBaseROI)GetROIinfoByType(iROIType.BaseROI);

            crect.org_x = x;
            crect.org_y = y;
            var err = iROI.AssignBaseROI(TrainROITool, crect);

            if (err != E_iVision_ERRORS.E_OK)
            {
                return;
            }
        }
Exemplo n.º 2
0
        public object GetROIinfoByType(iROIType type)
        {
            IntPtr pnt;

            switch (type)
            {
            case iROIType.UnknownROIType:
                break;

            case iROIType.BaseROI:
                iBaseROI baseROI = new iBaseROI();
                pnt = Marshal.AllocHGlobal(Marshal.SizeOf(baseROI));
                Marshal.StructureToPtr(baseROI, pnt, false);
                iROI.GetInfo(TrainROITool, pnt);
                iBaseROI BASEROI = (iBaseROI)Marshal.PtrToStructure(pnt, typeof(iBaseROI));
                Marshal.FreeHGlobal(pnt);
                return(BASEROI);

            default:
                break;
            }
            return(null);
        }
Exemplo n.º 3
0
 public extern static E_iVision_ERRORS AssignBaseROI(IntPtr a_iROI, iBaseROI a_base_roi);
Exemplo n.º 4
0
        public void btn_NCCtraining_Click(object sender, EventArgs e)
        {
            E_iVision_ERRORS err = E_iVision_ERRORS.E_NULL;

            //UpData_NCC_Parameter();
            MinReduceArea = Convert.ToInt32(tbx_MinReduceArea.Text);
            err           = iMatch.iSetMinReduceArea(TheMainfrm.Matchmodel, MinReduceArea);
            if (err != E_iVision_ERRORS.E_OK)
            {
                MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
            }
            else
            {
                label2.Text = "E_OK";
            }

            err = iMatch.iSetDontCareThreshold(TheMainfrm.Matchmodel, DontCarevalue);
            if (err != E_iVision_ERRORS.E_OK)
            {
                MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
            }
            else
            {
                label2.Text = "E_OK";
            }

            if (chk_TrainingFromROI.CheckState == CheckState.Checked)
            {
                iBaseROI l_rect = new iBaseROI();
                double[] l_data = new double[10];
                if (iROI.Size(TheMainfrm.TrainROITool) == 0)
                {
                    label2.Text = "ERROR: the size of ROI is 0.";
                    return;
                }
                l_rect = (iBaseROI)TheMainfrm.GetROIinfoByType(iROIType.BaseROI);


                iRect rect;
                rect.top    = l_rect.org_y;
                rect.bottom = l_rect.org_y + l_rect.height;
                rect.left   = l_rect.org_x;
                rect.right  = l_rect.org_x + l_rect.width;

                if (TheMainfrm.UsingColor)
                {
                    err = iMatch.CreateNCCModelFromROI(TheMainfrm.ColorImg, TheMainfrm.Matchmodel, rect, UsingMask);
                    if (err != E_iVision_ERRORS.E_OK)
                    {
                        MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
                    }
                    else
                    {
                        label2.Text = "E_OK";
                    }
                }
                else
                {
                    err = iMatch.CreateNCCModelFromROI(TheMainfrm.GrayImg, TheMainfrm.Matchmodel, rect, UsingMask);
                    if (err != E_iVision_ERRORS.E_OK)
                    {
                        MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
                    }
                    else
                    {
                        label2.Text = "E_OK";
                    }
                }
                iROI.DeleteROI(TheMainfrm.TrainROITool);
                iROI.Plot(TheMainfrm.TrainROITool, TheMainfrm.hDC);
            }
            else
            {
                if (TheMainfrm.UsingColor)
                {
                    err = iMatch.CreateNCCModel(TheMainfrm.ColorImg, TheMainfrm.Matchmodel, UsingMask);
                    if (err != E_iVision_ERRORS.E_OK)
                    {
                        MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
                    }
                    else
                    {
                        label2.Text = "E_OK";
                    }
                }
                else
                {
                    err = iMatch.CreateNCCModel(TheMainfrm.GrayImg, TheMainfrm.Matchmodel, UsingMask);
                    if (err != E_iVision_ERRORS.E_OK)
                    {
                        MessageBox.Show(err.ToString(), "Error"); label2.Text = "Error";
                    }
                    else
                    {
                        label2.Text = "E_OK";
                    }
                }
            }
        }