public override CodeResult[] Decode(List <HObject> images) { int countThread = images.Count; Task[] _Tasks = new Task[countThread]; // Barrier _Barrier = new Barrier(countThread); // int rowCount = (int)Math.Ceiling((double)images.Count / countCPU); CodeResult[] result = new CodeResult[countThread]; for (int i = 0; i < countThread; i++) { _Tasks[i] = Task.Factory.StartNew((num) => { HObject image = images[(int)num]; result[(int)num] = new CodeResult(); // int count = (((int)num * rowCount + rowCount) > images.Count) ? (images.Count - (int)num * rowCount) : rowCount; TaskDecode(image, result[(int)num]); // _Barrier.SignalAndWait(); }, i); } Task.WaitAll(_Tasks); return(result); }
public CodeResult[] Decode(List <HObject> regions) { List <HObject> imageReduced = new List <HObject>(); foreach (var member in regions) { HObject _iamge = new HObject(); HOperatorSet.ReduceDomain(m_image, member, out _iamge); imageReduced.Add(_iamge); } TDCode tdcode; CodeResult sss = new CodeResult(); CodeResult[] results = new CodeResult[] { }; if (_form is FormDMCodeParam) { FormDMCodeParam form = (FormDMCodeParam)_form; tdcode = new DMCode(); tdcode.SetCodeParam(form.CodeParameter); results = tdcode.Decode(imageReduced); } else if (_form is FormQRCodeParam) { FormQRCodeParam form = (FormQRCodeParam)_form; tdcode = new QRCode(); tdcode.SetCodeParam(form.CodeParameter); results = tdcode.Decode(imageReduced); } return(results); }
//public HObject InputImage //{ // get { return m_image; } // set { m_image = value; } //} private void btn_Decode_Click(object sender, EventArgs e) { List <HObject> region = new List <HObject>(); List <HObject> imageReduced = new List <HObject>(); region = hDisplay1.GetSearchRegions(); Time_Meter time_Meter = new Time_Meter(); foreach (var member in region) { HObject _iamge = new HObject(); HOperatorSet.ReduceDomain(m_image, member, out _iamge); HOperatorSet.CropDomain(_iamge, out _iamge); imageReduced.Add(_iamge); } TDCode tdcode; CodeResult sss = new CodeResult(); CodeResult[] results = new CodeResult[] { }; if (_form is FormDMCodeParam) { FormDMCodeParam form = (FormDMCodeParam)_form; tdcode = new DMCode(); tdcode.SetCodeParam(form.CodeParameter); results = tdcode.Decode(imageReduced); txt_TimeUse.Text = (time_Meter.TimePass() * 1000).ToString(); } else if (_form is FormQRCodeParam) { FormQRCodeParam form = (FormQRCodeParam)_form; tdcode = new QRCode(); tdcode.SetCodeParam(form.CodeParameter); results = tdcode.Decode(imageReduced); } List <StringX> ss = new List <StringX>(); List <HalWindow.RegionX> regions = new List <HalWindow.RegionX>(); foreach (var member in results) { if (member.code != string.Empty) { HTuple area = new HTuple(); HTuple row = new HTuple(); HTuple column = new HTuple(); HOperatorSet.AreaCenter(member.codexld, out area, out row, out column); StringX sx = new StringX(15, false, false); sx.SetString(member.code, (int)row.D, (int)column.D, System.Drawing.Color.Green); ss.Add(sx); HalWindow.RegionX regionX = new HalWindow.RegionX(member.codexld, "green"); regions.Add(regionX); } } DelegateUIControl.GetInstance().UpdateHDisplay("FormSetHDisplay", m_image, regions, ss); }
private void TaskDecode(HObject image, CodeResult result) { HObject _symbolXld = new HObject(); HTuple _resultHandle = new HTuple(); HTuple _resultstring = new HTuple(); HOperatorSet.FindDataCode2d(image, out _symbolXld, m_codehandle, "stop_after_result_num", 1, out _resultHandle, out _resultstring); if (_resultstring.Length > 0) { result.code = _resultstring.S; HOperatorSet.GenRegionContourXld(_symbolXld, out result.codexld, "margin"); } }
public override CodeResult[] Decode(List <HObject> images) { int countThread = images.Count; Task[] _Tasks = new Task[countThread]; CodeResult[] result = new CodeResult[countThread]; for (int i = 0; i < countThread; i++) { result[i] = new CodeResult(); TaskDecode(images[i], result[i]); //_Tasks[i] = Task.Factory.StartNew((num) => //{ // HObject image = images[(int)num]; // result[(int)num] = new CodeResult(); // TaskDecode(image, result[(int)num]); //}, i); } // Task.WaitAll(_Tasks); return(result); }
protected string m_small_modules_robustness; //小码粒鲁棒性 #endregion public virtual void Decode(HObject image, ref CodeResult results) { }