Exemple #1
0
 internal Phase(Tuple <int, int> inTextPlacement, RegisterMarksCoordinates inRegMarkCoord, ParsingInformation inParsingInfo, DirPaths inDirPaths, int inDPI, Action <string> inLog, MoveFile inMoveFile)
 {
     this.textPlacement = inTextPlacement;
     this.regMarkCoord  = inRegMarkCoord;
     this.parsingInfo   = inParsingInfo;
     this.dirPaths      = inDirPaths;
     this.DPI           = inDPI;
     this.logg          = inLog;
     this.moveFile      = inMoveFile;
 }
Exemple #2
0
        static void Main()
        {
            #region Instantiation of classes, structs and stuff.
            Log        Logg       = new Log();
            ReadConfig readConfig = new ReadConfig();
            DirPaths   dirPaths   = new DirPaths(readConfig);
            MoveFile   fileMove   = new MoveFile();

            ParsingInformation       parsingInfo  = new ParsingInformation();
            Action <string>          logg         = (str) => Logg.Text(str, dirPaths);
            RegisterMarksCoordinates regMarkCoord = new RegisterMarksCoordinates();
            #endregion

            #region Load a bunch of parameters from the config file and instanciate a phase class.
            //Load registermark coordinates from the config file.
            regMarkCoord.lead  = new Tuple <int, int>(readConfig.ReadNumber("leadRegMarkX"), readConfig.ReadNumber("leadRegMarkY"));
            regMarkCoord.trail = new Tuple <int, int>(readConfig.ReadNumber("trailRegMarkX"), readConfig.ReadNumber("trailRegMarkY"));

            //Load the sleepTime from the config file.
            int sleepTime = readConfig.ReadNumber("sleepTime");

            //Load parsing information for the files names from the config file.
            parsingInfo.towerStart  = readConfig.ReadNumber("parseTowerStart");
            parsingInfo.towerStart -= 1;                                                         //C# starts to count at zero.
            parsingInfo.towerLength = readConfig.ReadNumber("parseTowerLength");

            parsingInfo.cylinderStart  = readConfig.ReadNumber("parseCylinderStart");
            parsingInfo.cylinderStart -= 1;
            parsingInfo.cylinderLength = readConfig.ReadNumber("parseCylinderLength");

            parsingInfo.sectionStart  = readConfig.ReadNumber("parseSectionStart");
            parsingInfo.sectionStart -= 1;
            parsingInfo.sectionLength = readConfig.ReadNumber("parseSectionLength");

            parsingInfo.halfStart  = readConfig.ReadNumber("parseHalfStart");
            parsingInfo.halfStart -= 1;
            parsingInfo.halfLength = readConfig.ReadNumber("parseHalfLength");

            int DPI = readConfig.ReadNumber("DPI");

            Tuple <int, int> readTextPlacement = new Tuple <int, int>(readConfig.ReadNumber("textPlacementX"), readConfig.ReadNumber("textPlacementY"));

            Phase phase = new Phase(readTextPlacement, regMarkCoord, parsingInfo, dirPaths, DPI, logg, fileMove);
            #endregion

            //Forever loop for now. Main loop of the program.
            string toExitOrNot = @"Never Exit";
            do
            {
                //Checks that all the folders are present and then moves any file from the source to middle.
                string fileToProcess = phase.Input();

                //If there is a file in the source folder the processing begins.
                if (fileToProcess != null)
                {
                    phase.Process(fileToProcess);
                }

                //Any file in the middle should have by this time undergone processing and so is outputed.
                phase.Output();

                //Let the CPU get some rest. ("sleepTime" is set in OARConfig.txt)
                System.Threading.Thread.Sleep(sleepTime);
            } while (!toExitOrNot.Equals("Exit"));
        }
Exemple #3
0
        /// <summary>
        /// Inserts register marks to their coordinates.
        /// </summary>
        /// <param name="inputImage">Image whose registermarks should be removed.</param>
        /// <param name="dirPaths">Paths of the program.</param>
        /// <param name="regMarkCoord">Coordinates of the register marks.</param>
        /// <returns>An image where the register marks have been inserted into their positions.</returns>
        private BarebonesImage InsertRegisterMarks(BarebonesImage inputImage, DirPaths dirPaths, RegisterMarksCoordinates regMarkCoord)
        {
            BarebonesImage leadRegMark  = new BarebonesImage();
            BarebonesImage trailRegMark = new BarebonesImage();

            string pathAndFile = Path.Combine(dirPaths.regMarks, dirPaths.leadRegMark);

            leadRegMark = leadRegMark.ReadATIFF(pathAndFile);

            pathAndFile  = Path.Combine(dirPaths.regMarks, dirPaths.trailRegMark);
            trailRegMark = trailRegMark.ReadATIFF(pathAndFile);

            //Insert the register mark.
            inputImage.Insert(leadRegMark, regMarkCoord.lead.Item1, regMarkCoord.lead.Item2);
            inputImage.Insert(trailRegMark, regMarkCoord.trail.Item1, regMarkCoord.trail.Item2);

            return(inputImage);
        }
Exemple #4
0
        /// <summary>
        /// Moves the register marks a certain amount up or down the image.
        /// </summary>
        /// <param name="inputImage">Image whose registermarks should be removed.</param>
        /// <param name="dirPaths">Paths of the program.</param>
        /// <param name="regMarkCoord">Coordinates of the register marks.</param>
        /// <returns>An image where the register marks have been removed.</returns>
        private BarebonesImage RemoveRegisterMarks(BarebonesImage inputImage, DirPaths dirPaths, RegisterMarksCoordinates regMarkCoord)
        {
            BarebonesImage blankRegMark = new BarebonesImage();

            string pathAndFile = Path.Combine(dirPaths.regMarks, dirPaths.blankRegMark);

            blankRegMark = blankRegMark.ReadATIFF(pathAndFile);

            //Cover the old register marks with white pixels.
            inputImage.Insert(blankRegMark, regMarkCoord.lead.Item1, regMarkCoord.lead.Item2);
            inputImage.Insert(blankRegMark, regMarkCoord.trail.Item1, regMarkCoord.trail.Item2);

            return(inputImage);
        }