コード例 #1
0
ファイル: roiDetection.cs プロジェクト: fray1014/first
        private void CalcDsc(int id)
        {
            RectangleF rectFRoiRecord;

            PointF[] rectFRoiPoints;
            Size     rectRoiSize;

            RectangleF rectFBlkRecord;
            Rectangle  rectBlkRecord;

            PointF[] rectFBlkPoints;
            Size     rectBlkSize;

            string fileName = Path.Combine(fileDir + "-", Convert.ToString(id));;

            rectFRoiRecord = RectConverter.ConvertFromDrawRect(roi[id], slide[id], id);
            rectFRoiPoints = RectConverter.GetAllPointsByRectangleF(rectFRoiRecord, amp);
            rectRoiSize    = RectConverter.GetStepsByRectangleF(rectFRoiRecord, amp);

            rectBlkRecord  = rectsBLK[id];
            rectFBlkRecord = RectConverter.ConvertFromDrawRect(rectsBLK[id], slide[id], id);
            // Cal two Points.
            rectFBlkPoints    = new PointF[2];
            rectFBlkPoints[0] = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
            rectFBlkPoints[1] = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width * 2 / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
            rectBlkSize       = RectConverter.GetStepsByRectangleF(rectFBlkRecord, amp);

            roi[id] = RectConverter.ConvertToDrawRect(roi[id], slide[id], id);

            GenerateTaskDesc(fileName, roi[id], rectFRoiRecord, rectFRoiPoints, rectRoiSize,
                             rectBlkRecord, rectFBlkRecord, rectFBlkPoints, rectBlkSize,
                             id);
        }
コード例 #2
0
        private void btntestmove_Click(object sender, EventArgs e)
        {
            RectangleF testmoveRF = RectConverter.ConvertFromDrawRect(rect, idxRect);
            PointF     testmovePt = RectConverter.GetAllPointsByRectangleF(testmoveRF, amp)[0];
            double     testmovezp = TangoController.TangoGetZPos();

            TangoController.TangoMoveAbs(1, testmovePt.X, testmovePt.Y, testmovezp, 0, true);
        }
コード例 #3
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (isStartPointValid)
            {
                blnDraw = false;
                if (rectSel == 1)
                {
                    rectsROI[idxRect] = rect;
                }
                else if (rectSel == 2)
                {
                    rectsBLK[idxRect] = rect;
                }

                //rectsROI[idxRect] = rect;

                RectangleF debugrectf = RectConverter.ConvertFromDrawRect(rect, idxRect);
                SizeF      sizef      = debugrectf.Size;
                tp_lu = debugrectf.Location;
                tp_ru = new PointF(debugrectf.Left - sizef.Width, debugrectf.Top);
                tp_ld = new PointF(debugrectf.Left, debugrectf.Top - sizef.Height);
                tp_rd = new PointF(debugrectf.Left - sizef.Width, debugrectf.Top - sizef.Height);

                label6.Text = tp_lu.ToString();
                label7.Text = tp_ru.ToString();
                label8.Text = tp_ld.ToString();
                label9.Text = tp_rd.ToString();
                int x_total_steps = (int)((tp_ld.X - tp_rd.X) / x_step);
                int y_total_steps = (int)((tp_ld.Y - tp_lu.Y) / y_step);
                label10.Text = "size: (" + Math.Abs(x_total_steps).ToString() + ", " + Math.Abs(y_total_steps).ToString() + ")";



                using (Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle))
                {
                    foreach (Rectangle _rect in rectsROI)
                    {
                        g.DrawRectangle(new Pen(Color.Red, 4), _rect);
                    }

                    foreach (Rectangle _rect in rectsBLK)
                    {
                        g.DrawRectangle(new Pen(Color.Blue, 4), _rect);
                    }
                }

                InfoPanelUtil.MyConsoleWrite(ref thisForm, "Done");
            }
        }
コード例 #4
0
        private void btnStartScan_Click(object sender, EventArgs e)
        {
            if (isSetName)
            {
                rectFRoiTotalPoints = 0;
                if (MessageBox.Show(generateConfirmMessage(), "确认", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                }
                else
                {
                    RectangleF rectFRoiRecord;
                    Rectangle  rectRoiRecord;
                    PointF[]   rectFRoiPoints;
                    Size       rectRoiSize;

                    RectangleF rectFBlkRecord;
                    Rectangle  rectBlkRecord;
                    PointF[]   rectFBlkPoints;
                    Size       rectBlkSize;


                    for (int i = 0; i < 4; i++)
                    {
                        if (broi[i])
                        {
                            //if (isimporttask[i])
                            //{
                            //    rectFRoiTotalPoints += tdscs[i].rectRoiSize.Width * tdscs[i].rectRoiSize.Height;
                            //    rectFRoiTotalPoints += tdscs[i].rectBlkPts.Length;

                            //    rectRoiRecord = rectsROI[i];
                            //    rectFRoiRecord = RectConverter.ConvertFromDrawRect(rectsROI[i], i);
                            //    rectFRoiPoints = RectConverter.GetAllPointsByRectangleF(rectFRoiRecord, amp);
                            //    rectRoiSize = RectConverter.GetStepsByRectangleF(rectFRoiRecord, amp);
                            //    rectFRoiTotalPoints += rectRoiSize.Width * rectRoiSize.Height;

                            //    rectBlkRecord = rectsBLK[i];
                            //    rectFBlkRecord = RectConverter.ConvertFromDrawRect(rectsBLK[i], i);
                            //    // Cal two Points.
                            //    rectFBlkPoints = new PointF[2];
                            //    rectFBlkPoints[0] = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
                            //    rectFBlkPoints[1] = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width * 2 / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
                            //    rectBlkSize = RectConverter.GetStepsByRectangleF(rectFBlkRecord, amp);
                            //    rectFRoiTotalPoints += rectFBlkPoints.Length;

                            //    Temp = RectConverter.GenerateTaskDesc(colorconfig.location, setnames[i],
                            //        rectRoiRecord, rectFRoiRecord, rectFRoiPoints, rectRoiSize,
                            //        rectBlkRecord, rectFBlkRecord, rectFBlkPoints, rectBlkSize,
                            //        i);

                            //}
                            //else
                            //{
                            rectRoiRecord        = rectsROI[i];
                            rectFRoiRecord       = RectConverter.ConvertFromDrawRect(rectsROI[i], i);
                            rectFRoiPoints       = RectConverter.GetAllPointsByRectangleF(rectFRoiRecord, amp);
                            rectRoiSize          = RectConverter.GetStepsByRectangleF(rectFRoiRecord, amp);
                            rectFRoiTotalPoints += rectRoiSize.Width * rectRoiSize.Height;

                            rectBlkRecord  = rectsBLK[i];
                            rectFBlkRecord = RectConverter.ConvertFromDrawRect(rectsBLK[i], i);
                            // Cal two Points.
                            rectFBlkPoints       = new PointF[2];
                            rectFBlkPoints[0]    = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
                            rectFBlkPoints[1]    = new PointF(rectFBlkRecord.Left - rectFBlkRecord.Width * 2 / 3, rectFBlkRecord.Top + rectFBlkRecord.Height / 2);
                            rectBlkSize          = RectConverter.GetStepsByRectangleF(rectFBlkRecord, amp);
                            rectFRoiTotalPoints += rectFBlkPoints.Length;

                            Temp = RectConverter.GenerateTaskDesc(colorconfig.location, setnames[i],
                                                                  rectRoiRecord, rectFRoiRecord, rectFRoiPoints, rectRoiSize,
                                                                  rectBlkRecord, rectFBlkRecord, rectFBlkPoints, rectBlkSize,
                                                                  i);
                            //}
                        }
                    }

                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("请先设置扫描玻片的名字");
            }
        }