Esempio n. 1
0
        private bool RunDisplayTest(TestItem testItem, Bitmap bitmap, List <IntPoint> ptCorners)
        {
            bool       flag      = true;
            ColorPanel panel     = (ColorPanel)Enum.Parse(typeof(ColorPanel), testItem.TestName);
            string     imageName = string.Format("{0}{1}{2:yyyyMMddHHmmss}_{3}", IMAGE_SAVE_PATH, SerialNumber, DateTime.Now, panel.ToString());

            if (panel == ColorPanel.White)
            {
                ip.GetDisplayCornerfrombmp(bitmap, out ptCorners);
            }

            // save original image
            bitmap.Save(imageName);

            // cropping screen image
            Bitmap srcimg    = new Bitmap(System.Drawing.Image.FromFile(imageName, true));
            Bitmap updateimg = CroppingImage(srcimg, ptCorners);

            args.Image = updateimg;
            dataChange.Invoke(this, args);

            // 截取区域图像
            Bitmap cropimg = ip.croppedimage(srcimg, ptCorners, dut.ui_width, dut.ui_height);

            cropimg.Save(imageName + "_cropped.bmp");
            args.Image = cropimg;
            dataChange.Invoke(this, args);

            // anaylse
            ColorimeterResult colorimeterRst = new ColorimeterResult(cropimg, panel);

            colorimeterRst.Analysis();
            this.DrawZone(cropimg, panel);

            switch (panel)
            {
            case ColorPanel.White:
            case ColorPanel.Black:
                testItem.SubNodes[0].Value = colorimeterRst.Luminance;
                testItem.SubNodes[1].Value = colorimeterRst.Uniformity5;
                testItem.SubNodes[2].Value = colorimeterRst.Mura;
                break;

            case ColorPanel.Red:
            case ColorPanel.Green:
            case ColorPanel.Blue:
                testItem.SubNodes[0].Value = colorimeterRst.CIE1931xyY.x;
                testItem.SubNodes[1].Value = colorimeterRst.CIE1931xyY.y;
                testItem.SubNodes[2].Value = colorimeterRst.CIE1931xyY.Y;
                break;
            }

            foreach (TestNode node in testItem.SubNodes)
            {
                flag &= node.Run();
            }
            dataChange.Invoke(this, args);

            return(flag);
        }
Esempio n. 2
0
        private bool DisplayTest(List <IntPoint> displaycornerPoints, Bitmap bitmap, ColorPanel panelType)
        {
            // show cropping image
            this.refreshtestimage(bitmap, picturebox_test);

            if (panelType == ColorPanel.White)
            {
                ip.GetDisplayCornerfrombmp(bitmap, out displaycornerPoints);
            }

            // ԭʼͼÏñ
            string imageName = tempdirectory + tbox_sn.Text + str_DateTime + "_" + panelType.ToString() + ".bmp";

            bitmap.Save(imageName);
            //need save bmp outside as file format and reload so that
            Bitmap srcimg = new Bitmap(System.Drawing.Image.FromFile(imageName, true));
            // ÕÒ³öÆÁÄ»ÇøÓòµÄͼÏñ
            Bitmap updateimg = croppingimage(srcimg, displaycornerPoints);

            this.refreshtestimage(updateimg, picturebox_test);

            // ½ØÈ¡ÇøÓòͼÏñ
            Bitmap cropimg = ip.croppedimage(srcimg, displaycornerPoints, dut.ui_width, dut.ui_height);

            cropimg.Save(tempdirectory + tbox_sn.Text + str_DateTime + "_cropped.bmp");
            picturebox_test.Width  = cropimg.Width;
            picturebox_test.Height = cropimg.Height;
            this.refreshtestimage(cropimg, picturebox_test);

            // binary ͼÏñ
            Bitmap binimg = new Bitmap(cropimg, new Size(dut.bin_width, dut.bin_height));

            binimg.Save(tempdirectory + tbox_sn.Text + str_DateTime + "_" + panelType.ToString() + "_bin.bmp");

            ColorimeterResult colorimeterRst = new ColorimeterResult(bitmap, panelType);

            colorimeterRst.Analysis();

            switch (panelType)
            {
            case ColorPanel.White:
                this.DrawZone(binimg, panelType);
                cbox_white_lv.Checked = cbox_white_uniformity.Checked = cbox_white_mura.Checked = true;
                tbox_whitelv.Text     = colorimeterRst.Luminance.ToString();
                tbox_whiteunif.Text   = (colorimeterRst.Uniformity5 * 100).ToString();
                tbox_whitemura.Text   = colorimeterRst.Mura.ToString();
                log.WriteUartLog(string.Format("luminance: {0}, uniformity5: {1}, mura: {2}",
                                               colorimeterRst.Luminance, colorimeterRst.Uniformity5, colorimeterRst.Mura));
                break;

            case ColorPanel.Black:
                this.DrawZone(binimg, panelType);
                cbox_black_lv.Checked = cbox_black_uniformity.Checked = cbox_black_mura.Checked = true;
                tbox_blacklv.Text     = colorimeterRst.Luminance.ToString();
                tbox_blackunif.Text   = (colorimeterRst.Uniformity5 * 100).ToString();
                tbox_blackmura.Text   = colorimeterRst.Mura.ToString();
                log.WriteUartLog(string.Format("luminance: {0}, uniformity5: {1}, mura: {2}",
                                               colorimeterRst.Luminance, colorimeterRst.Uniformity5, colorimeterRst.Mura));
                break;

            case ColorPanel.Red:
                cbox_red.Checked = true;
                tbox_red.Text    = colorimeterRst.CIE1931xyY.ToString();
                log.WriteUartLog(colorimeterRst.CIE1931xyY.ToString());
                break;

            case ColorPanel.Green:
                cbox_green.Checked = true;
                tbox_green.Text    = colorimeterRst.CIE1931xyY.ToString();
                log.WriteUartLog(colorimeterRst.CIE1931xyY.ToString());
                break;

            case ColorPanel.Blue:
                cbox_blue.Checked = true;
                tbox_blue.Text    = colorimeterRst.CIE1931xyY.ToString();
                log.WriteUartLog(colorimeterRst.CIE1931xyY.ToString());
                break;
            }
            log.WriteUartLog("\r\n");

            return(this.AnaylseResult(colorimeterRst, panelType));
        }