@Test public void testValidConfig() { Map config = new LinkedHashMap<>(); NoProcessor npProcessor = new NoProcessor(); NoProcessor npProcessor2 = new NoProcessor(); NoProcessor npProcessor3 = new NoProcessor(); config.put("saveImage", "local"); config.put("outputDir", OUTPUT_DIR); config.put("saveRate", SAVE_RATE); npProcessor.setupImageProcessing(config, SOURCE_NAME, MODEL_DIRECTORY, testAuthToken, testVantiqServer); assertTrue("NoProcessor should still setup with empty config", npProcessor.isSetup); config.put("saveImage", "both"); npProcessor2.setupImageProcessing(config, SOURCE_NAME, MODEL_DIRECTORY, testAuthToken, testVantiqServer); assertTrue("NoProcessor should still setup with empty config", npProcessor2.isSetup); config.put("saveImage", "vantiq"); npProcessor3.setupImageProcessing(config, SOURCE_NAME, MODEL_DIRECTORY, testAuthToken, testVantiqServer); assertTrue("NoProcessor should still setup with empty config", npProcessor3.isSetup); }
@Override public void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server) { this.server = server; this.authToken = authToken; this.sourceName = sourceName; imageUtil = new ImageUtil(); if (neuralNetConfig.get(SAVE_IMAGE) instanceof String) { saveImage = (String) neuralNetConfig.get(SAVE_IMAGE); if (!saveImage.equalsIgnoreCase(VANTIQ) && !saveImage.equalsIgnoreCase(BOTH) && !saveImage.equalsIgnoreCase(LOCAL)) { log.error("The config value for saveImage was invalid. Images will not be saved."); } if (!saveImage.equalsIgnoreCase(VANTIQ)) { if (neuralNetConfig.get(OUTPUT_DIR) instanceof String) { outputDir = (String) neuralNetConfig.get(OUTPUT_DIR); } } if (saveImage.equalsIgnoreCase(VANTIQ) || saveImage.equalsIgnoreCase(BOTH)) { vantiq = new io.vantiq.client.Vantiq(server); vantiq.setAccessToken(authToken); if (neuralNetConfig.get(UPLOAD_AS_IMAGE) instanceof Boolean && (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE)) { uploadAsImage = (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE); } } imageUtil.outputDir = outputDir; imageUtil.vantiq = vantiq; imageUtil.saveImage = true; imageUtil.sourceName = sourceName; imageUtil.uploadAsImage = uploadAsImage; if (neuralNetConfig.get(SAVE_RATE) instanceof Integer) { saveRate = (Integer) neuralNetConfig.get(SAVE_RATE); frameCount = saveRate; } } else { imageUtil.saveImage = false; log.info("The Neural Net Config did not specify a method of saving images. No images will be saved when polling. " + "If allowQueries is set, then the user can query the source and save images based on the query options."); } isSetup = true; }
NoProcessor implements NeuralNetInterface { @Override public void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server) { this.server = server; this.authToken = authToken; this.sourceName = sourceName; imageUtil = new ImageUtil(); if (neuralNetConfig.get(SAVE_IMAGE) instanceof String) { saveImage = (String) neuralNetConfig.get(SAVE_IMAGE); if (!saveImage.equalsIgnoreCase(VANTIQ) && !saveImage.equalsIgnoreCase(BOTH) && !saveImage.equalsIgnoreCase(LOCAL)) { log.error("The config value for saveImage was invalid. Images will not be saved."); } if (!saveImage.equalsIgnoreCase(VANTIQ)) { if (neuralNetConfig.get(OUTPUT_DIR) instanceof String) { outputDir = (String) neuralNetConfig.get(OUTPUT_DIR); } } if (saveImage.equalsIgnoreCase(VANTIQ) || saveImage.equalsIgnoreCase(BOTH)) { vantiq = new io.vantiq.client.Vantiq(server); vantiq.setAccessToken(authToken); if (neuralNetConfig.get(UPLOAD_AS_IMAGE) instanceof Boolean && (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE)) { uploadAsImage = (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE); } } imageUtil.outputDir = outputDir; imageUtil.vantiq = vantiq; imageUtil.saveImage = true; imageUtil.sourceName = sourceName; imageUtil.uploadAsImage = uploadAsImage; if (neuralNetConfig.get(SAVE_RATE) instanceof Integer) { saveRate = (Integer) neuralNetConfig.get(SAVE_RATE); frameCount = saveRate; } } else { imageUtil.saveImage = false; log.info("The Neural Net Config did not specify a method of saving images. No images will be saved when polling. " + "If allowQueries is set, then the user can query the source and save images based on the query options."); } isSetup = true; } }
NoProcessor implements NeuralNetInterface { @Override public void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server) { this.server = server; this.authToken = authToken; this.sourceName = sourceName; imageUtil = new ImageUtil(); if (neuralNetConfig.get(SAVE_IMAGE) instanceof String) { saveImage = (String) neuralNetConfig.get(SAVE_IMAGE); if (!saveImage.equalsIgnoreCase(VANTIQ) && !saveImage.equalsIgnoreCase(BOTH) && !saveImage.equalsIgnoreCase(LOCAL)) { log.error("The config value for saveImage was invalid. Images will not be saved."); } if (!saveImage.equalsIgnoreCase(VANTIQ)) { if (neuralNetConfig.get(OUTPUT_DIR) instanceof String) { outputDir = (String) neuralNetConfig.get(OUTPUT_DIR); } } if (saveImage.equalsIgnoreCase(VANTIQ) || saveImage.equalsIgnoreCase(BOTH)) { vantiq = new io.vantiq.client.Vantiq(server); vantiq.setAccessToken(authToken); if (neuralNetConfig.get(UPLOAD_AS_IMAGE) instanceof Boolean && (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE)) { uploadAsImage = (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE); } } imageUtil.outputDir = outputDir; imageUtil.vantiq = vantiq; imageUtil.saveImage = true; imageUtil.sourceName = sourceName; imageUtil.uploadAsImage = uploadAsImage; if (neuralNetConfig.get(SAVE_RATE) instanceof Integer) { saveRate = (Integer) neuralNetConfig.get(SAVE_RATE); frameCount = saveRate; } } else { imageUtil.saveImage = false; log.info("The Neural Net Config did not specify a method of saving images. No images will be saved when polling. " + "If allowQueries is set, then the user can query the source and save images based on the query options."); } isSetup = true; }  }
NoProcessor implements NeuralNetInterface { @Override public void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server) { this.server = server; this.authToken = authToken; this.sourceName = sourceName; imageUtil = new ImageUtil(); if (neuralNetConfig.get(SAVE_IMAGE) instanceof String) { saveImage = (String) neuralNetConfig.get(SAVE_IMAGE); if (!saveImage.equalsIgnoreCase(VANTIQ) && !saveImage.equalsIgnoreCase(BOTH) && !saveImage.equalsIgnoreCase(LOCAL)) { log.error("The config value for saveImage was invalid. Images will not be saved."); } if (!saveImage.equalsIgnoreCase(VANTIQ)) { if (neuralNetConfig.get(OUTPUT_DIR) instanceof String) { outputDir = (String) neuralNetConfig.get(OUTPUT_DIR); } } if (saveImage.equalsIgnoreCase(VANTIQ) || saveImage.equalsIgnoreCase(BOTH)) { vantiq = new io.vantiq.client.Vantiq(server); vantiq.setAccessToken(authToken); if (neuralNetConfig.get(UPLOAD_AS_IMAGE) instanceof Boolean && (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE)) { uploadAsImage = (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE); } } imageUtil.outputDir = outputDir; imageUtil.vantiq = vantiq; imageUtil.saveImage = true; imageUtil.sourceName = sourceName; imageUtil.uploadAsImage = uploadAsImage; if (neuralNetConfig.get(SAVE_RATE) instanceof Integer) { saveRate = (Integer) neuralNetConfig.get(SAVE_RATE); frameCount = saveRate; } } else { imageUtil.saveImage = false; log.info("The Neural Net Config did not specify a method of saving images. No images will be saved when polling. " + "If allowQueries is set, then the user can query the source and save images based on the query options."); } isSetup = true; }  @Override void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server); @Override NeuralNetResults processImage(byte[] image); @Override NeuralNetResults processImage(byte[] image, Map<String, ?> request); @Override void close(); }
NoProcessor implements NeuralNetInterface { @Override public void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server) { this.server = server; this.authToken = authToken; this.sourceName = sourceName; imageUtil = new ImageUtil(); if (neuralNetConfig.get(SAVE_IMAGE) instanceof String) { saveImage = (String) neuralNetConfig.get(SAVE_IMAGE); if (!saveImage.equalsIgnoreCase(VANTIQ) && !saveImage.equalsIgnoreCase(BOTH) && !saveImage.equalsIgnoreCase(LOCAL)) { log.error("The config value for saveImage was invalid. Images will not be saved."); } if (!saveImage.equalsIgnoreCase(VANTIQ)) { if (neuralNetConfig.get(OUTPUT_DIR) instanceof String) { outputDir = (String) neuralNetConfig.get(OUTPUT_DIR); } } if (saveImage.equalsIgnoreCase(VANTIQ) || saveImage.equalsIgnoreCase(BOTH)) { vantiq = new io.vantiq.client.Vantiq(server); vantiq.setAccessToken(authToken); if (neuralNetConfig.get(UPLOAD_AS_IMAGE) instanceof Boolean && (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE)) { uploadAsImage = (Boolean) neuralNetConfig.get(UPLOAD_AS_IMAGE); } } imageUtil.outputDir = outputDir; imageUtil.vantiq = vantiq; imageUtil.saveImage = true; imageUtil.sourceName = sourceName; imageUtil.uploadAsImage = uploadAsImage; if (neuralNetConfig.get(SAVE_RATE) instanceof Integer) { saveRate = (Integer) neuralNetConfig.get(SAVE_RATE); frameCount = saveRate; } } else { imageUtil.saveImage = false; log.info("The Neural Net Config did not specify a method of saving images. No images will be saved when polling. " + "If allowQueries is set, then the user can query the source and save images based on the query options."); } isSetup = true; }  @Override void setupImageProcessing(Map<String, ?> neuralNetConfig, String sourceName, String modelDirectory, String authToken, String server); @Override NeuralNetResults processImage(byte[] image); @Override NeuralNetResults processImage(byte[] image, Map<String, ?> request); @Override void close(); public String lastFilename; public Boolean isSetup; }