/// <summary>
        /// 用于创建初始的Pcb
        /// </summary>
        /// <returns></returns>
        public static Pcb CreatePcb()
        {
            try
            {
                string id    = new Snowflake(1).nextId().ToString();
                string sPath = @"D:\Power-Ftp\" + id;
                if (!Directory.Exists(sPath))
                {
                    Directory.CreateDirectory(sPath);
                }
                Pcb pcb = new Pcb()
                {
                    Id      = id,
                    PcbPath = id,
                    results = new List <Result>(),
                };

                float            confidence = (float)0.01;
                float            scale      = (float)0.25;
                OneStitchSidePcb front      = new OneStitchSidePcb()
                {
                    confidence = confidence,

                    pcbId    = id,
                    savePath = sPath,

                    allRows     = 10,
                    allCols     = 24,
                    allNum      = 240, // 这里多尺度是需要改变总数*2的
                    currentRow  = 0,
                    currentCol  = 0,
                    zTrajectory = true,
                    dst         = null,
                    roi         = new Rectangle(),
                    scale       = scale,
                    stitchEnd   = false,
                    bitmaps     = new Queue <BitmapInfo>(),
                };

                pcb.SurfaceNumber = 1;
                pcb.FrontPcb      = front;
                pcb.AllPhotoNum   = 240;
                return(pcb);
            }
            catch (Exception er) { return(null); }
        }
        private void btnFuckTest_Click(object sender, EventArgs e)
        {
            //thiscard = true;
            //isBabyYiNing = true;
            nowPcb = Pcb.CreatePcb();

            try
            {
                JsonData <Pcb> jsonData = new JsonData <Pcb>();
                jsonData.data          = nowPcb;
                jsonData.executionTime = 11;
                jsonData.ngNum         = nowPcb.results.Count;
                var jSetting = new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                };
                string[] props = { "FrontPcb", "BackPcb" }; //排除掉,不能让前端看到的字段。为true的话就是只保留这些字段
                jSetting.ContractResolver = new LimitPropsContractResolver(props, false);

                string res = JsonConvert.SerializeObject(jsonData, jSetting);
                RabbitMQClientHandler.GetInstance()
                .TopicExchangePublishMessageToServerAndWaitConfirm("", "work", "work", res);

                //File.WriteAllText(Path.Combine(savePath, "result.json"), ConvertJsonString(res));
            }
            catch (Exception er)
            {
                //LogHelper.WriteLog("连接队列失败!!!", er);
            }
            //string imgPath = "testpic.png";
            //OpenFileDialog ofd = new OpenFileDialog();
            //DialogResult fdr = ofd.ShowDialog();
            //if (fdr == DialogResult.OK)
            //{
            //    imgPath = ofd.FileName;
            //}
            //DirectoryInfo info = new DirectoryInfo(imgPath);
            //string fuckpath = info.Parent.FullName;

            //nowPcb.FrontPcb.allCols = 24;
            //nowPcb.FrontPcb.allRows = 10;
            //nowPcb.FrontPcb.allNum = 240;
            //nowPcb.FrontPcb.or_hl = 0.3;
            //nowPcb.FrontPcb.or_hu = 0.4;
            //nowPcb.FrontPcb.or_vl = 0.1;
            //nowPcb.FrontPcb.or_vu = 0.5;
            //nowPcb.FrontPcb.dr_hu = 0.02;
            //nowPcb.FrontPcb.dr_vu = 0.02;
            //MySmartThreadPool.Instance().QueueWorkItem(() =>
            //{
            //    DirectoryInfo root = new DirectoryInfo(fuckpath);
            //    //int i = 0;
            //    for (int i = 1; i <= nowPcb.FrontPcb.allNum; i++)
            //    {
            //        Bitmap fBitmap = new Bitmap(fuckpath + "/F" + i + ".jpg");
            //        fBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);  //指定不进行翻转的 180 度旋转  (垂直翻转+水平翻转)
            //        nowPcb.FrontPcb.bitmaps.Enqueue(new OneStitchSidePcb.BitmapInfo() { bitmap = (Bitmap)BitmapScaleHelper.ScaleToSize(fBitmap, (float)0.4).Clone(), name = "/F" + i + ".jpg" });
            //        fBitmap.Dispose();

            //        //Aoi.StitchMain(nowPcb.FrontPcb, onStitchCallBack);
            //        MySmartThreadPool.Instance().QueueWorkItem(() =>
            //        {
            //            lock (nowPcb.FrontPcb)
            //            {
            //                Aoi.StitchMain(nowPcb.FrontPcb, onStitchCallBack);
            //            }
            //        });
            //    }
            //});
        }
        private void btnFuckStart_Click(object sender, EventArgs e)
        {
            fuckSaveNum   = 0;
            fuckDetectNum = 0;
            nowPcb        = Pcb.CreatePcb();

            nowPcb.FrontPcb.allCols = 24;
            nowPcb.FrontPcb.allRows = 10;
            nowPcb.FrontPcb.allNum  = 240;
            nowPcb.FrontPcb.or_hl   = 0.3;
            nowPcb.FrontPcb.or_hu   = 0.4;
            nowPcb.FrontPcb.or_vl   = 0.1;
            nowPcb.FrontPcb.or_vu   = 0.5;
            nowPcb.FrontPcb.dr_hu   = 0.02;
            nowPcb.FrontPcb.dr_vu   = 0.02;
            if (fuckType.SelectedValue.ToString() == "请添加新的拍摄方案")
            {
                MessageBox.Show("请去添加页面添加新的拍摄方案");
                return;
            }
            Settings.Default.num = 0;
            conncamera();
            tbSavePath.Enabled = false;
            button6_Click_1();
            button9.Enabled = false;
            btnFuckDetectThisPcb.Enabled = true;
            ismoveative              = false;
            this.xYrulescs           = fuckType.SelectedValue as XYrulescs;
            Settings.Default.canmove = true;
            if (tbSavePath.Text != "图片保存地址,不填为不保存")
            {
                path = tbSavePath.Text;
                try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                catch
                {
                    MessageBox.Show("请输入正确路径");
                    return;
                }

                needsave = true;
                if (newbackgroundWorker.IsBusy != true)                    //判断BackgroundWorker 是否正在运行异步操作。
                {
                    newbackgroundWorker.RunWorkerAsync("object argument"); //启动异步操作,有两种重载。将触发BackgroundWorker.DoWork事件
                }
            }
            if (this.testDevice != null && this.testDevice.IsOpen && this.Camera.IsOpen)
            {
                iscangetstatus       = true;
                fuckType.Enabled     = false;
                button4.Enabled      = false;
                btnFuckStart.Enabled = false;
                button5.Enabled      = true;
                button11.Enabled     = true;
                if (backgroundWorker.IsBusy != true)                    //判断BackgroundWorker 是否正在运行异步操作。
                {
                    backgroundWorker.RunWorkerAsync("object argument"); //启动异步操作,有两种重载。将触发BackgroundWorker.DoWork事件
                }
            }
            else
            {
                MessageBox.Show("请连接设备");
            }
        }