|
|
|
@ -210,9 +210,13 @@ namespace Rs.MotionPlat.Commom
|
|
|
|
|
|
|
|
|
|
HOperatorSet.GenRectangle1(out HObject searchRegion, new HTuple(SysConfigParam.GetValue<int>("CodeRow1")), new HTuple(SysConfigParam.GetValue<int>("CodeColumn1")), new HTuple(SysConfigParam.GetValue<int>("CodeRow2")), new HTuple(SysConfigParam.GetValue<int>("CodeColumn2")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HOperatorSet.ReduceDomain(images, searchRegion, out HObject imgReduaced);
|
|
|
|
|
HOperatorSet.CropDomain(imgReduaced, out HObject imagePart);
|
|
|
|
|
|
|
|
|
|
HOperatorSet.InvertImage(imagePart, out HObject imageInvert);
|
|
|
|
|
HOperatorSet.ScaleImage(imageInvert, out HObject imageScaled, 2, 0);
|
|
|
|
|
//HOperatorSet.WriteImage(imageScaled, "bmp", 0, "d://images/22");
|
|
|
|
|
//HOperatorSet.ZoomImageFactor(imageScaled, out HObject imageZoomed, new HTuple(10), new HTuple(10), "constant");
|
|
|
|
|
HTuple decodedDataStrings = "";
|
|
|
|
|
HObject xlds = new HObject();
|
|
|
|
|
|
|
|
|
@ -220,7 +224,7 @@ namespace Rs.MotionPlat.Commom
|
|
|
|
|
foreach (string mode in modes)
|
|
|
|
|
{
|
|
|
|
|
HOperatorSet.CreateDataCode2dModel("Data Matrix ECC 200", "default_parameters", mode, out HTuple dataCodeHandle);
|
|
|
|
|
HOperatorSet.FindDataCode2d(imgReduaced, out xlds, dataCodeHandle, new HTuple(), new HTuple(), out HTuple resultHandles, out decodedDataStrings);
|
|
|
|
|
HOperatorSet.FindDataCode2d(imageScaled, out xlds, dataCodeHandle, new HTuple(), new HTuple(), out HTuple resultHandles, out decodedDataStrings);
|
|
|
|
|
|
|
|
|
|
if (decodedDataStrings.Length > 0)
|
|
|
|
|
{
|
|
|
|
@ -238,6 +242,52 @@ namespace Rs.MotionPlat.Commom
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//HOperatorSet.WriteImage(imagePart, "bmp", 0, "d://images/11");
|
|
|
|
|
//HOperatorSet.Threshold(imagePart, out HObject region, new HTuple(180), new HTuple(255));
|
|
|
|
|
//HOperatorSet.Connection(region, out HObject connectedRegion);
|
|
|
|
|
//HOperatorSet.FillUp(connectedRegion, out HObject regionFillUp);
|
|
|
|
|
//HOperatorSet.ClosingRectangle1(regionFillUp, out HObject regionClosing, new HTuple(70), new HTuple(70));
|
|
|
|
|
//HOperatorSet.SelectShape(regionClosing, out HObject selectedRegions, "area", "and", new HTuple(6000), new HTuple(8000));
|
|
|
|
|
//if (selectedRegions.IsInitialized() && selectedRegions.CountObj()==1)
|
|
|
|
|
//{
|
|
|
|
|
// HOperatorSet.DilationRectangle1(selectedRegions, out HObject regionDilation, new HTuple(20), new HTuple(20));
|
|
|
|
|
// HOperatorSet.ReduceDomain(imagePart, regionDilation, out HObject imageScan);
|
|
|
|
|
// HOperatorSet.InvertImage(imageScan, out HObject imageInvert);
|
|
|
|
|
// HOperatorSet.ScaleImage(imageInvert, out HObject imageScaled, 2, 0);
|
|
|
|
|
// //HOperatorSet.WriteImage(imageScaled, "bmp", 0, "d://images/22");
|
|
|
|
|
// //HOperatorSet.ZoomImageFactor(imageScaled, out HObject imageZoomed, new HTuple(10), new HTuple(10), "constant");
|
|
|
|
|
// HTuple decodedDataStrings = "";
|
|
|
|
|
// HObject xlds = new HObject();
|
|
|
|
|
|
|
|
|
|
// string[] modes = new string[] { "maximum_recognition" };
|
|
|
|
|
// foreach (string mode in modes)
|
|
|
|
|
// {
|
|
|
|
|
// HOperatorSet.CreateDataCode2dModel("Data Matrix ECC 200", "default_parameters", mode, out HTuple dataCodeHandle);
|
|
|
|
|
// HOperatorSet.FindDataCode2d(imageScaled, out xlds, dataCodeHandle, new HTuple(), new HTuple(), out HTuple resultHandles, out decodedDataStrings);
|
|
|
|
|
|
|
|
|
|
// if (decodedDataStrings.Length > 0)
|
|
|
|
|
// {
|
|
|
|
|
// mr.SN = decodedDataStrings.ToString().Replace("\"", "");
|
|
|
|
|
// mr.ScanOK = true;
|
|
|
|
|
// HOperatorSet.ClearDataCode2dModel(dataCodeHandle);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if (mode == "maximum_recognition")
|
|
|
|
|
// {
|
|
|
|
|
// mr.ScanOK = false;
|
|
|
|
|
// HOperatorSet.ClearDataCode2dModel(dataCodeHandle);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// mr.ScanOK = false;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|