浏览代码

20250623001 删除多余的代码

向羽 孟 2 月之前
父节点
当前提交
23e1da2d1a

+ 0 - 34
TestWork.DLL/CameraClass.cs

@@ -381,40 +381,6 @@ namespace CCDCount.DLL
                 throw;
             }
         }
-
-        /// <summary>
-        /// 读取图像像素信息(单行)
-        /// </summary>
-        /// <param name="frameOut">帧数据</param>
-        /// <returns></returns>
-        private byte[] GetImageFristRowsData(IFrameOut frameOut)
-        {
-            //创建
-            byte[] PixelData = new byte[(int)frameOut.Image.Width];
-            //从相机缓存中拷贝出图像数据
-            Marshal.Copy(frameOut.Image.PixelDataPtr, PixelData, 0, (int)frameOut.Image.Width);
-            return PixelData;
-        }
-
-        /// <summary>
-        /// 读取图像像素信息(多行)
-        /// </summary>
-        /// <param name="frameOut"></param>
-        /// <returns></returns>
-        private Queue<byte[]> GetImageRowsData(IFrameOut frameOut)
-        {
-            //创建
-            Queue<byte[]> PixelDatas = new Queue<byte[]>();
-            for (int i = 0;i< OnImageSelectRows;i++)
-            //for (int i = 0;i< frameOut.Image.Height;i++)
-            {
-                byte[] PixelData = new byte[frameOut.Image.Width];
-                Marshal.Copy(IntPtr.Add(frameOut.Image.PixelDataPtr,i * (int)frameOut.Image.Width), PixelData, 0, (int)frameOut.Image.Width);
-                PixelDatas.Enqueue(PixelData.Clone() as byte[]);
-                PixelData = null;
-            }
-            return PixelDatas;
-        }
         #endregion
     }
 }

+ 0 - 311
TestWork.DLL/ShuLiClass.cs

@@ -66,23 +66,6 @@ namespace CCDCount.DLL
             }
         }
 
-        /// <summary>
-        /// 处理图像序列的主入口
-        /// </summary>
-        /// <param name="image">图像像素数据</param>
-        /// <param name="ImageWidth">图像宽</param>
-        /// <param name="currentLine">当前行数</param>
-        /// <returns>检测到的物体总数</returns>
-        public bool ProcessImageSequence(byte[] image, int ImageWidth)
-        {
-            bool result = false;
-            // 每张图像是Width*1的二维数组,判断图象分辨率是否正确
-            if (image.Count() == ImageWidth) 
-                result = ProcessLine(image);
-                currentLine += 1;
-            return result;
-        }
-
         /// <summary>
         /// 处理图像序列的主入口
         /// </summary>
@@ -290,207 +273,6 @@ namespace CCDCount.DLL
             WorkCompleted?.Invoke(this, activeObjectEventArgs);
         }
 
-        /// <summary>
-        /// 处理单行像素数据
-        /// 返回值为false的时候无活跃物体转变为历史物体
-        /// 返回值为true的时候有活跃物体转变为历史物体
-        /// </summary>
-        /// <param name="image">当前行像素数组</param>
-        private bool ProcessLine(byte[] image) 
-        {
-            bool result = false;
-            // 步骤1:检测当前行的有效区域
-            var currentRegions = FindValidRegions(image);
-
-            if (currentRegions.Count == 1)
-            {
-                if (currentRegions[0].End - (currentRegions[0]).Start + 1 == image.Count())
-                {
-                    LOG.error("当前行有效区域为整行,检查视野和光源");
-                    return false;
-                }
-            }
-            // 步骤2:处理当前行每个区域
-            for (int i = 0; i < currentRegions.Count; i++)
-            {
-                var region = currentRegions[i];
-                // 查找全部可合并的活跃物体(有重叠+在允许间隔内)
-                var matcheds = activeObjects.Where(o =>
-                    IsOverlapping(o, region) &&
-                    (currentLine - o.LastSeenLine - 1) <= shuLiConfig.MAX_GAP).ToList();
-                //当有多个可合并的活跃物体时,将多个物体合并
-                if (matcheds.Count >= 2)
-                {
-                    // 合并有效区域队列
-                    var CopeRowsData = new List<RowStartEndCol>();
-                    matcheds.ForEach(o => CopeRowsData = CopeRowsData.Concat(o.RowsData).ToList());
-                    // 合并有效区域并保存在新的区域中
-                    var MergeMatched = new ActiveObjectClass
-                    {
-                        MinStartCol = matcheds.Min(o => o.MinStartCol),
-                        MaxEndCol = matcheds.Max(o => o.MaxEndCol),
-                        StartLine = matcheds.Min(o => o.StartLine),
-                        LastSeenLine = matcheds.Max(o => o.LastSeenLine),
-                        LastSeenLineStartCol = matcheds.Min(o => o.LastSeenLineStartCol),
-                        LastSeenLineEndCol = matcheds.Max(o => o.LastSeenLineEndCol),
-                        StartCheckTime = matcheds.Min(o => o.StartCheckTime),
-                        EndCheckTime = matcheds.Max(o => o.EndCheckTime),
-                        Area = matcheds.Sum(o => o.Area),
-                        RowsData = CopeRowsData,
-                        ImageWidth = matcheds.FirstOrDefault().ImageWidth,
-                    };
-                    // 从活跃区域中删除被合并的区域
-                    matcheds.ForEach(o => activeObjects.Remove(o));
-                    // 保存新的区域到活跃区域中
-                    activeObjects.Add(MergeMatched);
-                }
-
-                // 搜获可用且可合并的活跃区域
-                var matched = activeObjects.FirstOrDefault(o =>
-                    IsOverlapping(o, region) &&
-                    (currentLine - o.LastSeenLine - 1) <= shuLiConfig.MAX_GAP);
-                if (matched != null)
-                {
-                    // 合并区域:扩展物体边界并更新状态
-                    matched.MinStartCol = Math.Min(matched.MinStartCol, region.Start);
-                    matched.MaxEndCol = Math.Max(matched.MaxEndCol, region.End);
-                    matched.Area += region.End - region.Start + 1;
-                    matched.LastSeenLine = currentLine;
-                    matched.RowsData.Add(new RowStartEndCol
-                    {
-                        StartCol = region.Start,
-                        EndCol = region.End,
-                        RowsCol = currentLine,
-                    });
-                }
-                else
-                {
-                    // 创建新物体(首次出现的区域)
-                    activeObjects.Add(new ActiveObjectClass
-                    {
-                        MinStartCol = region.Start,
-                        MaxEndCol = region.End,
-                        StartLine = currentLine,
-                        LastSeenLine = currentLine,
-                        LastSeenLineStartCol = region.Start,
-                        LastSeenLineEndCol = region.End,
-                        StartCheckTime = DateTime.Now,
-                        Area = region.End - region.Start +1 ,
-                        ImageWidth = IdentifyImageWidth,
-                        RowsData = new List<RowStartEndCol> {
-                            new RowStartEndCol {
-                                StartCol = region.Start,
-                                EndCol = region.End,
-                                RowsCol = currentLine,
-                            }
-                        }
-                    });
-                }
-            }
-
-            // 更新有效物体的最后一行的起始点
-            activeObjects.Where(o => o.LastSeenLine == currentLine).ToList().ForEach(o => o.LastSeenLineStartCol = o.RowsData.Where(p => p.RowsCol == currentLine).Min(p => p.StartCol));
-            activeObjects.Where(o => o.LastSeenLine == currentLine).ToList().ForEach(o => o.LastSeenLineEndCol = o.RowsData.Where(p => p.RowsCol == currentLine).Max(p => p.EndCol));
-
-            // 步骤3:清理超时未更新的物体
-            var lostObjects = activeObjects
-                .Where(o => (currentLine - o.LastSeenLine) > shuLiConfig.MAX_GAP|| (o.LastSeenLine - o.StartLine) > shuLiConfig.MAX_Idetify_Height)
-                .ToList();
-
-            List<ActiveObjectClass> OneActive = new List<ActiveObjectClass>();
-
-            // 有物体转变为活跃物体,返回值转为true
-            if (lostObjects.Count()>0)
-            {
-                result = true;
-                foreach (var item in lostObjects)
-                {
-                    //噪点判定
-                    if(item.LastSeenLine - item.StartLine <shuLiConfig.NoiseFilter_Threshold||
-                        item.RowsData.Max(o => o.EndCol - o.StartCol)< shuLiConfig.NoiseFilter_Threshold)
-                        continue;
-                    //转为历史物体,添加缺少的参数
-                    item.Num = ObjectNum += 1;
-                    item.ChannelNO = ActiveChannel(item);
-                    item.EndCheckTime = DateTime.Now;
-                    OneActive.Add(item);
-                    if((item.LastSeenLine - item.StartLine) > shuLiConfig.MAX_Idetify_Height)
-                    {
-                        item.StateCode = 7;
-                        LOG.error("ShuLiClass-ProcessLine:非颗粒,视野异常");
-                        Console.WriteLine("ShuLiClass-ProcessLine:非颗粒,视野异常");
-                    }
-                    else if (shuLiConfig.PandingCode != -1)
-                    {
-                        if (item.Area < shuLiConfig.MinArea
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 1))
-                        {
-                            item.StateCode = 5;
-                            LOG.log(string.Format("颗粒编号{0}:面积过小", item.Num));
-                            Console.WriteLine("颗粒编号{0}:面积过小", item.Num);
-                        }
-                        else if (item.Area > shuLiConfig.MaxArea
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 1))
-                        {
-                            item.StateCode = 6;
-                            LOG.log(string.Format("颗粒编号{0}:面积过大", item.Num));
-                            Console.WriteLine("颗粒编号{0}:面积过大", item.Num);
-                        }
-                        else if (item.LastSeenLine - item.StartLine < shuLiConfig.MIN_OBJECT_HEIGHT
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 0))
-                        {
-                            item.StateCode = 2;
-                            LOG.log(string.Format("颗粒编号{0}:超短粒", item.Num));
-                            Console.WriteLine("颗粒编号{0}:超短粒", item.Num);
-                        }
-                        else if (item.LastSeenLine - item.StartLine > shuLiConfig.MAX_OBJECT_HEIGHT
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 0))
-                        {
-                            item.StateCode = 1;
-                            LOG.log(string.Format("颗粒编号{0}:超长粒", item.Num));
-                            Console.WriteLine("颗粒编号{0}:超长粒", item.Num);
-                        }
-                        else if (item.RowsData.Max(o => o.EndCol - o.StartCol) > shuLiConfig.MAX_OBJECT_WIDTH
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 0))
-                        {
-                            item.StateCode = 3;
-                            LOG.log(string.Format("颗粒编号{0}:超宽粒", item.Num));
-                            Console.WriteLine("颗粒编号{0}:超宽粒", item.Num);
-                        }
-                        else if (item.RowsData.Max(o => o.EndCol - o.StartCol) < shuLiConfig.MIN_OBJECT_WIDTH
-                            && (shuLiConfig.PandingCode == 2 || shuLiConfig.PandingCode == 0))
-                        {
-                            item.StateCode = 4;
-                            LOG.log(string.Format("颗粒编号{0}:超窄粒", item.Num));
-                            Console.WriteLine("颗粒编号{0}:超窄粒", item.Num);
-                        }
-                        else
-                        {
-                            item.StateCode = 0;
-                            LOG.log(string.Format("颗粒编号{0}:正常粒", item.Num));
-                            Console.WriteLine("颗粒编号{0}:正常粒", item.Num);
-                        }
-                    }
-
-                }
-
-                if(OneActive.Count>0)
-                    //触发回调事件
-                    OnWorkCompleted(OneActive);
-            }
-            else
-            {
-                OneActive = null;
-            }
-            lock(_lockObj)
-            {
-                // 累加到总数并从活跃物体转移到历史物体
-                lostObjects.Where(o => o.LastSeenLine - o.StartLine >= shuLiConfig.NoiseFilter_Threshold).ToList().ForEach(o => historyActiveObjects.Add(o));
-                lostObjects.ForEach(o => activeObjects.Remove(o));
-            }
-            return result;
-        }
-
         /// <summary>
         /// 处理单行像素数据
         /// 返回值为false的时候无活跃物体转变为历史物体
@@ -693,64 +475,6 @@ namespace CCDCount.DLL
             return result;
         }
 
-        /// <summary>
-        /// 检测有效物体区域(横向连续黑色像素段)
-        /// </summary>
-        /// <param name="line">当前行像素数组</param>
-        /// <returns>有效区域列表(起始/结束位置)</returns>
-        private List<(int Start, int End)> FindValidRegions(byte[] image)
-        {
-            List<(int Start, int End)> regions = new List<(int Start, int End)>();
-            int start = -1; // 当前区域起始标记
-            // 遍历所有像素列
-            if (shuLiConfig.IsIdentifyRoiOpen)
-            {
-                for (int i = shuLiConfig.IdentifyStartX; i < shuLiConfig.IdentifyStopX; i++)
-                {
-                    if (image[i] < shuLiConfig.RegionThreshold) // 发现黑色像素
-                    {
-                        if (start == -1) start = i; // 开始新区域
-                    }
-                    else if (start != -1) // 遇到白色像素且存在进行中的区域
-                    {
-                        // 检查区域宽度是否达标
-                        if (i - start >= shuLiConfig.MIN_OBJECT_WIDTH)
-                        {
-                            regions.Add((start, i - 1)); // 记录有效区域
-                        }
-                        start = -1; // 重置区域标记
-                    }
-                }
-            }
-            else
-            {
-                for (int i = 0; i < image.Length; i++)
-                {
-                    if (image[i] < shuLiConfig.RegionThreshold) // 发现黑色像素
-                    {
-                        if (start == -1) start = i; // 开始新区域
-                    }
-                    else if (start != -1) // 遇到白色像素且存在进行中的区域
-                    {
-                        // 检查区域宽度是否达标
-                        if (i - start >= shuLiConfig.MIN_OBJECT_WIDTH)
-                        {
-                            regions.Add((start, i - 1)); // 记录有效区域
-                        }
-                        start = -1; // 重置区域标记
-                    }
-                }
-            }
-
-
-            // 处理行尾未闭合的区域
-            if (start != -1 && image.Length - start >= shuLiConfig.MIN_OBJECT_WIDTH)
-            {
-                regions.Add((start, image.Length - 1));
-            }
-            return regions;
-        }
-
         /// <summary>
         /// 检测有效物体区域(横向连续黑色像素段)
         /// </summary>
@@ -884,41 +608,6 @@ namespace CCDCount.DLL
                 }
             }
         }
-        /// <summary>
-        /// 线程方法 - 旧线程方法
-        /// </summary>
-        //private void IdentifyImageProcess()
-        //{
-        //    //Stopwatch stopwatch = Stopwatch.StartNew();
-        //    byte[] ImageByte = null;
-        //    while (IsIdentify)
-        //    {
-        //        //判断队列中是否有数据
-        //        if (ImageBytes.Count() > 0)
-        //        {
-        //            //stopwatch.Restart();
-        //            ImageBytes.TryDequeue(out ImageByte);
-        //            //是否成功取得数据
-        //            if (ImageByte != null)
-        //            {
-        //                //识别
-        //                ProcessImageSequence(ImageByte, IdentifyImageWidth);
-        //            }
-        //            else
-        //            {
-        //                Console.WriteLine("识别数据为空");
-        //                continue;
-        //            }
-        //            //输出耗时
-        //            //stopwatch.Stop();
-        //            ///Console.WriteLine("识别线程单次运行耗时:" + stopwatch.Elapsed.ToString());
-        //        }
-        //        else
-        //        {
-        //            Thread.Sleep(5);
-        //        }
-        //    }
-        //}
         #endregion
     }
 }

+ 0 - 9
TestWork/CCDCount.csproj

@@ -136,12 +136,6 @@
     <Compile Include="Forms\SettingForm.Designer.cs">
       <DependentUpon>SettingForm.cs</DependentUpon>
     </Compile>
-    <Compile Include="Forms\ShuLiForm.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="Forms\ShuLiForm.Designer.cs">
-      <DependentUpon>ShuLiForm.cs</DependentUpon>
-    </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <EmbeddedResource Include="Forms\DataShowForm.resx">
@@ -159,9 +153,6 @@
     <EmbeddedResource Include="Forms\SettingForm.resx">
       <DependentUpon>SettingForm.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Forms\ShuLiForm.resx">
-      <DependentUpon>ShuLiForm.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <SubType>Designer</SubType>

+ 0 - 208
TestWork/Forms/ShuLiForm.Designer.cs

@@ -1,208 +0,0 @@
-namespace CCDCount.Forms
-{
-    partial class ShuLiForm
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.button5 = new System.Windows.Forms.Button();
-            this.button4 = new System.Windows.Forms.Button();
-            this.button3 = new System.Windows.Forms.Button();
-            this.panel1 = new System.Windows.Forms.Panel();
-            this.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.panel2 = new System.Windows.Forms.Panel();
-            this.button1 = new System.Windows.Forms.Button();
-            this.button8 = new System.Windows.Forms.Button();
-            this.panel3 = new System.Windows.Forms.Panel();
-            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
-            this.label2 = new System.Windows.Forms.Label();
-            this.panel1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
-            this.panel2.SuspendLayout();
-            this.panel3.SuspendLayout();
-            this.SuspendLayout();
-            // 
-            // button5
-            // 
-            this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.button5.Location = new System.Drawing.Point(6, 113);
-            this.button5.Name = "button5";
-            this.button5.Size = new System.Drawing.Size(209, 47);
-            this.button5.TabIndex = 6;
-            this.button5.Text = "保存识别参数";
-            this.button5.UseVisualStyleBackColor = true;
-            this.button5.Click += new System.EventHandler(this.button5_Click);
-            // 
-            // button4
-            // 
-            this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.button4.Location = new System.Drawing.Point(6, 60);
-            this.button4.Name = "button4";
-            this.button4.Size = new System.Drawing.Size(209, 47);
-            this.button4.TabIndex = 5;
-            this.button4.Text = "停止相机测试";
-            this.button4.UseVisualStyleBackColor = true;
-            this.button4.Click += new System.EventHandler(this.button4_Click);
-            // 
-            // button3
-            // 
-            this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.button3.Location = new System.Drawing.Point(6, 7);
-            this.button3.Name = "button3";
-            this.button3.Size = new System.Drawing.Size(209, 47);
-            this.button3.TabIndex = 4;
-            this.button3.Text = "相机测试";
-            this.button3.UseVisualStyleBackColor = true;
-            this.button3.Click += new System.EventHandler(this.button3_Click);
-            // 
-            // panel1
-            // 
-            this.panel1.Controls.Add(this.pictureBox1);
-            this.panel1.Controls.Add(this.panel2);
-            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.panel1.Location = new System.Drawing.Point(0, 0);
-            this.panel1.Name = "panel1";
-            this.panel1.Size = new System.Drawing.Size(944, 606);
-            this.panel1.TabIndex = 1;
-            // 
-            // pictureBox1
-            // 
-            this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.pictureBox1.Location = new System.Drawing.Point(0, 0);
-            this.pictureBox1.Name = "pictureBox1";
-            this.pictureBox1.Size = new System.Drawing.Size(717, 606);
-            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
-            this.pictureBox1.TabIndex = 1;
-            this.pictureBox1.TabStop = false;
-            // 
-            // panel2
-            // 
-            this.panel2.Controls.Add(this.button1);
-            this.panel2.Controls.Add(this.button8);
-            this.panel2.Controls.Add(this.button5);
-            this.panel2.Controls.Add(this.panel3);
-            this.panel2.Controls.Add(this.button3);
-            this.panel2.Controls.Add(this.button4);
-            this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
-            this.panel2.Location = new System.Drawing.Point(717, 0);
-            this.panel2.Name = "panel2";
-            this.panel2.Size = new System.Drawing.Size(227, 606);
-            this.panel2.TabIndex = 0;
-            // 
-            // button1
-            // 
-            this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.button1.Location = new System.Drawing.Point(6, 221);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(209, 47);
-            this.button1.TabIndex = 10;
-            this.button1.Text = "关闭程序";
-            this.button1.UseVisualStyleBackColor = true;
-            this.button1.Click += new System.EventHandler(this.button1_Click_1);
-            // 
-            // button8
-            // 
-            this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.button8.Location = new System.Drawing.Point(6, 166);
-            this.button8.Name = "button8";
-            this.button8.Size = new System.Drawing.Size(209, 47);
-            this.button8.TabIndex = 9;
-            this.button8.Text = "查看历史记录";
-            this.button8.UseVisualStyleBackColor = true;
-            this.button8.Click += new System.EventHandler(this.button8_Click);
-            // 
-            // panel3
-            // 
-            this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
-            | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.panel3.Controls.Add(this.richTextBox1);
-            this.panel3.Controls.Add(this.label2);
-            this.panel3.Location = new System.Drawing.Point(0, 274);
-            this.panel3.Name = "panel3";
-            this.panel3.Size = new System.Drawing.Size(227, 332);
-            this.panel3.TabIndex = 3;
-            // 
-            // richTextBox1
-            // 
-            this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
-            | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
-            this.richTextBox1.Location = new System.Drawing.Point(0, 50);
-            this.richTextBox1.Name = "richTextBox1";
-            this.richTextBox1.ReadOnly = true;
-            this.richTextBox1.Size = new System.Drawing.Size(227, 282);
-            this.richTextBox1.TabIndex = 2;
-            this.richTextBox1.Text = "";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(20, 17);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(59, 17);
-            this.label2.TabIndex = 0;
-            this.label2.Text = "总数量";
-            // 
-            // ShuLiForm
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(944, 606);
-            this.Controls.Add(this.panel1);
-            this.MinimumSize = new System.Drawing.Size(962, 653);
-            this.Name = "ShuLiForm";
-            this.Text = "ImageMoniShuLiForm";
-            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImageMoniShuLiForm_FormClosing);
-            this.panel1.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
-            this.panel2.ResumeLayout(false);
-            this.panel3.ResumeLayout(false);
-            this.panel3.PerformLayout();
-            this.ResumeLayout(false);
-
-        }
-
-        #endregion
-        private System.Windows.Forms.Panel panel1;
-        private System.Windows.Forms.Panel panel2;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.PictureBox pictureBox1;
-        private System.Windows.Forms.Button button3;
-        private System.Windows.Forms.Button button4;
-        private System.Windows.Forms.Button button5;
-        private System.Windows.Forms.Panel panel3;
-        private System.Windows.Forms.Button button8;
-        private System.Windows.Forms.RichTextBox richTextBox1;
-        private System.Windows.Forms.Button button1;
-    }
-}

+ 0 - 242
TestWork/Forms/ShuLiForm.cs

@@ -1,242 +0,0 @@
-using CCDCount.DLL;
-using CCDCount.MODEL.ShuLiClass;
-using MvCameraControl;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Threading;
-using System.Windows.Forms;
-using CCDCount.MODEL.ConfigModel;
-
-namespace CCDCount.Forms
-{
-    public partial class ShuLiForm : Form
-    {
-        #region  变量
-        List<byte[]> ImageData = new List<byte[]>();
-        LoadSplieImageClass loadSplieImageClass = new LoadSplieImageClass();
-        //MainThreadClass mainThread = new MainThreadClass(new ShuLiConfigClass());
-        MainThreadClass mainThread = new MainThreadClass(new ShuLiConfigClass(),new MODEL.ConfigModel.CameraConfig());
-        List<RowStartEndCol> RowsShowList = new List<RowStartEndCol>();
-        Stopwatch ShowImageStopwatch = new Stopwatch();
-        int Frame = 24; // 帧率
-        #endregion
-
-        #region 测试
-        ShuLiClass shuLiClass = null;
-        #endregion
-
-        #region 构造函数
-        public ShuLiForm()
-        {
-            InitializeComponent();
-            SDKSystem.Initialize();
-
-            this.FormBorderStyle = FormBorderStyle.None;
-
-            // 全屏显示
-            this.WindowState = FormWindowState.Maximized;
-
-            // 窗口置顶
-            //this.TopMost = true;
-
-            button4.Enabled = false;
-            button5.Enabled = false;
-            button8.Enabled = false;
-        }
-        #endregion
-
-        #region 窗口事件
-        private void button1_Click(object sender, EventArgs e)
-        {
-            var openFileDialog = new OpenFileDialog
-            {
-                Title = "请选择文件",          // 对话框标题
-                Filter = "图片文件|*.bmp;*.jpg;*.png", // 文件类型过滤器
-                Multiselect = false          // 是否允许多选
-            };
-
-            // 显示对话框并判断结果
-            if (openFileDialog.ShowDialog() == DialogResult.OK)
-            {
-                string selectedFilePath = openFileDialog.FileName;
-                loadSplieImageClass.LoadImage(selectedFilePath);
-                ImageData = loadSplieImageClass.SplieImage();
-            }
-        }
-
-        private void button2_Click(object sender, EventArgs e)
-        {
-            RowsShowList.Clear();
-            shuLiClass = new ShuLiClass();
-            shuLiClass.UpdateIdentifyImageWidth(ImageData[0].Count());
-            shuLiClass.InitChannel();
-            shuLiClass.WorkCompleted += Worker_MianThreadToFrom;
-            Stopwatch sw = new Stopwatch();
-            List<ActiveObjectClass> ActivesList = new List<ActiveObjectClass>();
-            for (int i = 0; i < ImageData.Count; i++)
-            {
-                sw.Restart();
-                shuLiClass.ProcessImageSequence(ImageData[i], ImageData[i].Count());
-                sw.Stop();
-                Console.WriteLine(sw.Elapsed.ToString());
-            }
-            if (shuLiClass.GetHistoryActiveNum() > 0)
-            {
-                button8.Enabled = true;
-            }
-        }
-
-        private void button3_Click(object sender, EventArgs e)
-        {
-            if (shuLiClass!=null)
-            {
-                shuLiClass = null;
-                RowsShowList.Clear();
-            }
-            if (mainThread.StartMianThread())
-            {
-                ShowImageStopwatch.Start();
-                mainThread.WorkerToFrom += Worker_MianThreadToFrom;
-                button3.Enabled = false;
-                button4.Enabled = true;
-                button8.Enabled = false;
-            }
-            else
-            {
-                MessageBox.Show("请检查相机是否连接!");
-            }
-        }
-
-        private void button4_Click(object sender, EventArgs e)
-        {
-            mainThread.StopMianThread();
-            mainThread.WorkerToFrom -= Worker_MianThreadToFrom;
-            button3.Enabled = true;
-            button4.Enabled = false;
-            if(mainThread.shuLiClass.GetHistoryActiveNum() > 0)
-                button8.Enabled = true;
-        }
-
-        private void button5_Click(object sender, EventArgs e)
-        {
-            mainThread.SaveAllConfig();
-        }
-
-        private void button8_Click(object sender, EventArgs e)
-        {
-            HistoryImageDataForm historyDataForm = new HistoryImageDataForm();
-            //图像测试模式下获取历史数据
-            if (shuLiClass != null)
-                historyDataForm.historyActive = shuLiClass.GetHistoryActive();
-            //相机模式下获取历史数据
-            else if (mainThread.shuLiClass != null)
-                historyDataForm.historyActive = mainThread.shuLiClass.GetHistoryActive();
-            historyDataForm.ShowDialog();
-        }
-
-        private void ImageMoniShuLiForm_FormClosing(object sender, FormClosingEventArgs e)
-        {
-            SDKSystem.Finalize();
-            mainThread.StopMianThread();
-            Thread.Sleep(1000);
-            //System.Windows.Forms.Application.Exit();
-            this.Dispose();
-        }
-        #endregion
-
-        #region  主界面回调事件
-        /// <summary>
-        /// 通知主界面回调的事件
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void Worker_MianThreadToFrom(object sender, ActiveObjectEventArgsClass e)
-        {
-            // 事件处理逻辑
-            Console.WriteLine("结果已通知到主界面!");
-            e.Actives.ForEach(o => o.RowsData.ForEach(p => RowsShowList.Add(p)));
-            e.Actives.ForEach(o => PrintMianPicrture(o));
-        }
-        #endregion
-
-        #region 私有方法
-        /// <summary>
-        /// 渲染画面方法
-        /// </summary>
-        /// <param name="activeObjects"></param>
-        private void PrintMianPicrture(ActiveObjectClass activeObject)
-        {
-            var timeChaZhi = (DateTime.Now - activeObject.EndCheckTime).TotalMilliseconds;
-            UpdateLable2("总数量:" + activeObject.Num.ToString());
-            UpdateRichTextBox1(string.Format("第{0}识别结束到展示总用时:\n{1}毫秒", activeObject.Num, timeChaZhi));
-            UpdateRichTextBox1(string.Format("第{0}识别结束面积:{1}像素", activeObject.Num, activeObject.Area));
-            UpdateRichTextBox1(string.Format("第{0}识别结果所属通达数为{1}", activeObject.Num, activeObject.ChannelNO+1));
-            Bitmap bitmap = new Bitmap(activeObject.ImageWidth, 2048);
-            Graphics g = Graphics.FromImage(bitmap);
-            Pen redPen = new Pen(Color.Red, 1);
-            List<RowStartEndCol> ShowList = RowsShowList.Where(o => o.RowsCol > activeObject.LastSeenLine - bitmap.Height).ToList();
-            RowsShowList.Where(o => o.RowsCol < activeObject.LastSeenLine - bitmap.Height).ToList().ForEach(o => RowsShowList.Remove(o));
-            if (ShowImageStopwatch.ElapsedMilliseconds < (1000 / Frame))
-            {
-                return;
-            }
-            else
-            {
-                ShowImageStopwatch.Restart();
-            }
-            ShowList.ForEach(o => g.DrawLine(redPen, new Point(o.StartCol, (int)(activeObject.LastSeenLine - o.RowsCol)), new Point(o.EndCol, (int)(activeObject.LastSeenLine - o.RowsCol))));
-            UpdatepictureBox1(bitmap.Clone() as Bitmap);
-
-        }
-
-        private void UpdateLable2(string text)
-        {
-            if (label2.InvokeRequired)
-            {
-                label2.Invoke(new Action<string>(UpdateLable2), text);
-            }
-            else
-            {
-                label2.Text = text;
-            }
-        }
-
-        private void UpdatepictureBox1(Bitmap image)
-        {
-            if (pictureBox1.InvokeRequired)
-            {
-                pictureBox1.Invoke(new Action<Bitmap>(UpdatepictureBox1), image);
-            }
-            else
-            {
-                pictureBox1.Image = image;
-            }
-        }
-
-        private void UpdateRichTextBox1(string text)
-        {
-            if (richTextBox1.InvokeRequired)
-            {
-                richTextBox1.Invoke(new Action<string>(UpdateRichTextBox1), text);
-            }
-            else
-            {
-                richTextBox1.SelectionStart = richTextBox1.TextLength;
-                richTextBox1.SelectionLength = 0;
-                richTextBox1.AppendText(text + Environment.NewLine);
-                richTextBox1.ScrollToCaret();
-            }
-        }
-        #endregion
-
-        private void button1_Click_1(object sender, EventArgs e)
-        {
-            this.Close();
-        }
-    }
-
-}

+ 0 - 120
TestWork/Forms/ShuLiForm.resx

@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-</root>