public void appendQRPosition(string xmlPath, QRCodeInfo qrROI, string qrContent)
        {
            XElement xdoc = XElement.Load(xmlPath);

            //XElement info = xdoc.Element("info");

            var qrinfo = xdoc.Elements("QRCODE");

            if (qrinfo != null)
            {
                xdoc.Elements("QRCODE").Remove();
            }

            XElement QR = new XElement("QRCODE");

            QR.Add(new XElement("startX", qrROI.startX),
                   new XElement("startY", qrROI.startY),
                   new XElement("width", qrROI.width),
                   new XElement("height", qrROI.height),
                   new XElement("content", qrContent));

            xdoc.AddFirst(QR);
            //xdoc.Add(QR);

            xdoc.Save(xmlPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 寻找指定区域内的二维码
        /// </summary>
        /// <param name="srcPath"></param>
        /// <param name="searchArea"></param>
        /// <param name="qrcode"></param>
        /// <param name="qrcontent"></param>
        /// <param name="cameraOption"></param>
        public void searchQRwithregion(string srcPath, ROIInfo searchArea, ref QRCodeInfo qrcode, ref string qrcontent, int cameraOption)
        {
            StringBuilder CONTENT = new StringBuilder(20);
            int           resp    = visionAlgorithm.findQRcodeinRegion(srcPath, cameraOption, searchArea, ref qrcode, CONTENT);

            if (resp != DLLDefine.sg_OK)
            {
                Console.WriteLine("检测二维码出错");
                return;
            }

            qrcontent = CONTENT.ToString();
        }
Ejemplo n.º 3
0
        // 确认二维码位置 //用检测来做
        private void buttonQR_Click(object sender, EventArgs e)
        {
            QRCodeInfo qrcodeinfo = new QRCodeInfo();

            //visiondll.GetQRregion(xmlimagepath, ref qrcodeinfo);

            numericUpDownStartX.Value = qrcodeinfo.startX;
            numericUpDownStartY.Value = qrcodeinfo.startY;
            numericUpDownwidth.Value  = qrcodeinfo.width;
            numericUpDownheight.Value = qrcodeinfo.height;

            ROIInfo roi = new ROIInfo((uint)numericUpDownStartX.Value, (uint)numericUpDownStartY.Value, (uint)numericUpDownwidth.Value, (uint)numericUpDownheight.Value);

            xmlProcess.appendQRPosition(textBoxXMLpath.Text, roi);
        }
        // 确认添加二维码信息
        private void confirmQR_Click(object sender, EventArgs e)
        {
            ROIInfo    roi       = new ROIInfo((int)numericUpDownStartX.Value, (int)numericUpDownStartY.Value, 0, 0, (int)numericUpDownwidth.Value, (int)numericUpDownheight.Value);
            QRCodeInfo realQR    = new QRCodeInfo();
            string     QRcontent = "";

            visiondll.searchQRwithregion(imgInBoxPath, roi, ref realQR, ref QRcontent, cameraside);

            MessageBox.Show("二维码的位置为:" + "(" + realQR.startX + "," + realQR.startY + "), w= " + realQR.width + ", h= " + realQR.height + "\n"
                            + "二维码的内容为: " + QRcontent + "\n"
                            + "已添加至配置表");

            QRCodeRefer = realQR;

            xmlProcess.appendQRPosition(textBoxXMLpath.Text, realQR, QRcontent);
        }
        public void GetQRregionorigin(string xmlpath, ref QRCodeInfo qrcodeorigin)
        {
            // 1. 加载XML文件
            XElement xe = XElement.Load(xmlpath);

            XElement QRCODE = xe.Element("QRCODE");

            int startX = Convert.ToInt16(QRCODE.Element("startX").Value);
            int startY = Convert.ToInt16(QRCODE.Element("startY").Value);
            int width  = Convert.ToInt16(QRCODE.Element("width").Value);
            int height = Convert.ToInt16(QRCODE.Element("height").Value);

            qrcodeorigin.startX = startX;
            qrcodeorigin.startY = startY;
            qrcodeorigin.width  = width;
            qrcodeorigin.height = height;
        }
        // 增加仪表项
        // 现在变为计算相对位置
        public void appendDevice(string xmlPath, string deviveName, TaskInfo task, ROIInfo roi, string addtionText, string order, QRCodeInfo qrRefer)
        {
            XElement xdoc = XElement.Load(xmlPath);

            XElement xeDevice = new XElement("device");

            xeDevice.SetAttributeValue("type", task.type);

            // 增加一项名字
            XElement xeName = new XElement("name", deviveName);

            xeDevice.Add(xeName);

            XElement xeTask = new XElement("taskinfo");

            xeTask.Add(new XElement("type", task.type),
                       new XElement("subtype", task.subtype),
                       new XElement("number", task.number),
                       new XElement("order", order));   //增加序号供C++层返回结果

            xeDevice.Add(xeTask);

            XElement xeROI = new XElement("roiinfo");

            xeROI.Add(new XElement("startX", roi.startX),
                      new XElement("startY", roi.startY),
                      new XElement("distX", roi.startX - qrRefer.startX),
                      new XElement("distY", roi.startY - qrRefer.startY),
                      new XElement("width", roi.width),
                      new XElement("height", roi.height));

            xeDevice.Add(xeROI);

            if (DLLDefine.sg_task_pointer == task.type)
            {
                XElement pointerInfo = new XElement("unitinfo");    //TODO 此处获取指针额外配置
                getElementFromText(addtionText, task.type, ref pointerInfo);
                xeDevice.Add(pointerInfo);
            }
            else if (DLLDefine.sg_task_knob == task.type)
            {
                XElement knobInfo = new XElement("unitinfo");   // TODO 此处解析旋钮额外配置
                getElementFromText(addtionText, task.type, ref knobInfo);
                xeDevice.Add(knobInfo);
            }


            xdoc.Add(xeDevice);

            xdoc.Save(xmlPath);
        }
Ejemplo n.º 7
0
 public static extern int findQRcodeinRegion(string filename, int cameraType, ROIInfo searchArea, ref QRCodeInfo QRcode, StringBuilder content);
Ejemplo n.º 8
0
 public static extern int DrawROIArray(string filename, ROIInfo[] ROIArray, int num, string processedName, ref QRCodeInfo qrcode, int cameraType);