internal static int calcExactVersion(Point[] centers, int[] angle, int[] moduleSize, bool[][] image) { bool[] versionInformation = new bool[18]; Point[] points = new Point[18]; Axis axis = new Axis(angle, moduleSize[1]); axis.Origin = centers[1]; for (int y = 0; y < 6; y++) { for (int x = 0; x < 3; x++) { Point target = axis.translate(x - 7, y - 3); versionInformation[x + y * 3] = image[target.X][target.Y]; points[x + y * 3] = target; } } FinderPattern.canvas.drawPoints(points, Color_Fields.RED); int exactVersion = 0; try { exactVersion = FinderPattern.checkVersionInfo(versionInformation); } catch (InvalidVersionInfoException e_A9) { FinderPattern.canvas.println("Version info error. now retry with other place one."); axis.Origin = centers[2]; axis.ModulePitch = moduleSize[2]; for (int x = 0; x < 6; x++) { for (int y = 0; y < 3; y++) { Point target = axis.translate(x - 3, y - 7); versionInformation[y + x * 3] = image[target.X][target.Y]; points[x + y * 3] = target; } } FinderPattern.canvas.drawPoints(points, Color_Fields.RED); try { exactVersion = FinderPattern.checkVersionInfo(versionInformation); } catch (VersionInformationException e2) { throw e2; } } return(exactVersion); }
internal static int calcExactVersion(Point[] centers, int[] angle, int[] moduleSize, bool[][] image) { bool[] target = new bool[18]; Point[] points = new Point[18]; Axis axis = new Axis(angle, moduleSize[1]); axis.Origin = centers[1]; for (int index1 = 0; index1 < 6; ++index1) { for (int index2 = 0; index2 < 3; ++index2) { Point point = axis.translate(index2 - 7, index1 - 3); target[index2 + index1 * 3] = image[point.X][point.Y]; points[index2 + index1 * 3] = point; } } FinderPattern.canvas.drawPoints(points, Color_Fields.RED); int num; try { num = FinderPattern.checkVersionInfo(target); } catch (InvalidVersionInfoException ex1) { FinderPattern.canvas.println("Version info error. now retry with other place one."); axis.Origin = centers[2]; axis.ModulePitch = moduleSize[2]; for (int index1 = 0; index1 < 6; ++index1) { for (int index2 = 0; index2 < 3; ++index2) { Point point = axis.translate(index1 - 3, index2 - 7); target[index2 + index1 * 3] = image[point.X][point.Y]; points[index1 + index2 * 3] = point; } } FinderPattern.canvas.drawPoints(points, Color_Fields.RED); try { num = FinderPattern.checkVersionInfo(target); } catch (VersionInformationException ex2) { throw ex2; } } return(num); }