gt:             CvPipeline pipeline = new CvPipeline();
context: /*
   * Copyright (C) 2021 Tony Luken <tonyluken@att.net>
   * 
   * This file is part of OpenPnP.
   * 
   * OpenPnP is free software: you can redistribute it and/or modify it under the terms of the GNU
   * General Public License as published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   * 
   * OpenPnP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
   * Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License along with OpenPnP. If not, see
   * <http://www.gnu.org/licenses/>.
   * 
   * For more information about OpenPnP visit http://openpnp.org
   */
  
  import static org.junit.jupiter.api.Assertions.assertEquals;
  
  import java.io.File;
  
  import org.junit.jupiter.api.Test;
  import org.openpnp.model.Area;
  import org.openpnp.model.AreaUnit;
  import org.openpnp.model.Configuration;
  import org.openpnp.model.Length;
  import org.openpnp.model.LengthUnit;
  import org.openpnp.model.Location;
  import org.openpnp.spi.Camera;
  import org.openpnp.vision.pipeline.CvPipeline;
  import org.openpnp.vision.pipeline.CvStage;
  
  import com.google.common.io.Files;
  
  
  public class CvStageTest {
  	
  	/**
  	 * Tests the following pipeline overrides with conversion:
  	 * <pre>
       * Parameter Type               Overriding Pipeline Property Type(s)
       * -----------------------      --------------------------------------------------------
       * Boolean                  <-  Boolean
       * Double                   <-  Double, Integer, Long, Area, Length
       * Integer                  <-  Double, Integer, Long, Area, Length
       * Long                     <-  Double, Integer, Long, Area, Length
       * String                   <-  String
       * org.opencv.core.Point    <-  org.opencv.core.Point, org.openpnp.model.Point, Location 
       * org.openpnp.model.Point  <-  org.opencv.core.Point, org.openpnp.model.Point, Location
       * Area                     <-  Area
       * Length                   <-  Length
       * Location                 <-  Location
       * </pre>
  	 */
      @Test
      public void testPipelinePropertyOverrides() throws Exception {
          File workingDirectory = Files.createTempDir();
          workingDirectory = new File(workingDirectory, ".openpnp");
          System.out.println("Configuration directory: " + workingDirectory);
  
          Configuration.initialize(workingDirectory);
          Configuration.get().load();
  
          Camera camera = new VisionUtilsTest.TestCamera();
          
          String propName = "propName";
          
          //To Boolean conversion
          {
              //From Boolean
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              boolean originalParameter = true;
              boolean overridingParameter = false;
              boolean overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName);
              assertEquals(overridingParameter, overriddenParameter);
          }
  
          //To String conversion
          {
              //From String
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              String originalParameter = "true";
              String overridingParameter = "false";
              String overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName);
              assertEquals(overridingParameter, overriddenParameter);
          }
  
          //To Double conversions
          {
              //From Double
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Double originalParameter = 39.5;
              Double overridingParameter = -87.4;
              Double overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter, overriddenParameter);
          }
  
          {
              //From Integer
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Double originalParameter = 39.5;
              Integer overridingParameter = -87;
              Double overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter.doubleValue(), overriddenParameter);
          }
  
          {
              //From Long
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Double originalParameter = 39.5;
              Long overridingParameter = -87L;
              Double overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter.doubleValue(), overriddenParameter);
          }
  
          {
              //From Area
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Double originalParameter = 39.5;
              Area overridingParameter = new Area(-87.4, AreaUnit.SquareMillimeters);
              Double overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter.getValue(), overriddenParameter);
          }
  
          {
              //From Length
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Double originalParameter = 39.5;
              Length overridingParameter = new Length(-87.4, LengthUnit.Millimeters);
              Double overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter.getValue(), overriddenParameter);
          }
  
          //To Integer conversions
          {
              //From Double
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Integer originalParameter = 39;
              Double overridingParameter = -87.4;
              Integer overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(((Long) Math.round(overridingParameter)).intValue(), overriddenParameter);
          }
  
          {
              //From Integer
              CvPipeline pipeline = new CvPipeline();
              pipeline.setProperty("camera", camera);
              Integer originalParameter = 39;
              Integer overridingParameter = -87;
              Integer overriddenParameter;
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(originalParameter, overriddenParameter);
              pipeline.setProperty(propName, overridingParameter);
              overriddenParameter = CvStage.getPossiblePipelinePropertyOverride(originalParameter, 
                      pipeline, propName, Double.class, Integer.class, Long.class, Area.class, Length.class);
              assertEquals(overridingParameter, overriddenParameter);
          }
  
          {
              //From Long
  