//############################################################################################################################################################################################## public Edge(string pieceID, int edgeNumber, LocalDriveBitmap pieceImgColor, VectorOfPoint edgeContour, IProgress <LogEvent> logHandle, CancellationToken cancelToken) { _logHandle = logHandle; _cancelToken = cancelToken; PieceID = pieceID; EdgeNumber = edgeNumber; contour = edgeContour; if (PluginFactory.GetGeneralSettingsPlugin().SolverShowDebugResults) { PieceImgColor = pieceImgColor; ContourImg = new LocalDriveBitmap(System.IO.Path.GetDirectoryName(PieceImgColor.LocalFilePath) + @"\Edges\" + PieceID + "_Edge#" + edgeNumber.ToString() + ".png", null); } NormalizedContour = normalize(contour); //Normalized contours are used for comparisons VectorOfPoint contourCopy = new VectorOfPoint(contour.ToArray().Reverse().ToArray()); ReverseNormalizedContour = normalize(contourCopy); //same as normalized contour, but flipped 180 degrees contourCopy.Dispose(); classify(); }
//############################################################################################################################################################################################## public Piece(Image<Rgba, byte> color, Image<Gray, byte> bw, string pieceSourceFileName, Point pieceSourceFileLocation, IProgress<LogEvent> logHandle, CancellationToken cancelToken) { _logHandle = logHandle; _cancelToken = cancelToken; PieceID = "Piece#" + NextPieceID.ToString(); PieceIndex = NextPieceID; NextPieceID++; PieceImgColor = new LocalDriveBitmap(System.IO.Path.GetDirectoryName(pieceSourceFileName) + @"\Results\" + PieceID + "_Color.png", (PluginFactory.GetGeneralSettingsPlugin().SolverShowDebugResults ? color.Bitmap : color.LimitImageSize(200, 200).Bitmap)); PieceImgBw = new LocalDriveBitmap(System.IO.Path.GetDirectoryName(pieceSourceFileName) + @"\Results\" + PieceID + "_Bw.png", bw.Bitmap); PieceSourceFileName = pieceSourceFileName; PieceSourceFileLocation = pieceSourceFileLocation; PieceSize = bw.Bitmap.Size; if (PluginFactory.GetGeneralSettingsPlugin().SolverShowDebugResults) { _logHandle.Report(new LogEventImage(PieceID + " Color", color.Bitmap)); _logHandle.Report(new LogEventImage(PieceID + " Bw", bw.Bitmap)); } process(); }