Example usage for java.lang System loadLibrary

List of usage examples for java.lang System loadLibrary

Introduction

In this page you can find the example usage for java.lang System loadLibrary.

Prototype

@CallerSensitive
public static void loadLibrary(String libname) 

Source Link

Document

Loads the native library specified by the libname argument.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    System.loadLibrary("libraryName");
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    System.loadLibrary("Abc.dll");
}

From source file:webcamcapture.WebCamCapture.java

/**
 * @param args the command line arguments
 *///from   w  ww  .ja  v  a 2 s . c  om
public static void main(String[] args) throws IOException {
    // TODO code application logic here

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    httpRequestSend request = new httpRequestSend();
    VideoCapture camera = new VideoCapture(0);
    int x = 0;
    if (!camera.isOpened()) {
        System.out.println("Error");
    } else {
        Mat frame = new Mat();
        while (true) {
            if (camera.read(frame)) {
                System.out.println("Frame Obtained");
                System.out.println("Captured Frame Width " + frame.width() + " Height " + frame.height());
                Highgui.imwrite("camera" + x + ".jpg", frame);
                //System.out.println("OK");
                // break;

                request.request("https://fireacc.herokuapp.com/dash", "camera" + x + ".jpg");
                x++;
            }
            try {
                //}
                Thread.sleep(5000);
            } catch (InterruptedException ex) {
                System.out.println("stuck");
            }
        }
    }
    camera.release();

}

From source file:org.pooledtimeseries.PoT.java

public static void main(String[] args) {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Option fileOpt = OptionBuilder.withArgName("file").hasArg().withLongOpt("file")
            .withDescription("Path to a single file").create('f');

    Option dirOpt = OptionBuilder.withArgName("directory").hasArg().withLongOpt("dir")
            .withDescription("A directory with image files in it").create('d');

    Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h');

    Option pathFileOpt = OptionBuilder.withArgName("path file").hasArg().withLongOpt("pathfile")
            .withDescription(//from www.  j a  v a 2 s . c  o m
                    "A file containing full absolute paths to videos. Previous default was memex-index_temp.txt")
            .create('p');

    Option outputFileOpt = OptionBuilder.withArgName("output file").withLongOpt("outputfile").hasArg()
            .withDescription("File containing similarity results. Defaults to ./similarity.txt").create('o');

    Option jsonOutputFlag = OptionBuilder.withArgName("json output").withLongOpt("json")
            .withDescription("Set similarity output format to JSON. Defaults to .txt").create('j');

    Option similarityFromFeatureVectorsOpt = OptionBuilder
            .withArgName("similarity from FeatureVectors directory")
            .withLongOpt("similarityFromFeatureVectorsDirectory").hasArg()
            .withDescription("calculate similarity matrix from given directory of feature vectors").create('s');

    Options options = new Options();
    options.addOption(dirOpt);
    options.addOption(pathFileOpt);
    options.addOption(fileOpt);
    options.addOption(helpOpt);
    options.addOption(outputFileOpt);
    options.addOption(jsonOutputFlag);
    options.addOption(similarityFromFeatureVectorsOpt);

    // create the parser
    CommandLineParser parser = new GnuParser();

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);
        String directoryPath = null;
        String pathFile = null;
        String singleFilePath = null;
        String similarityFromFeatureVectorsDirectory = null;
        ArrayList<Path> videoFiles = null;

        if (line.hasOption("dir")) {
            directoryPath = line.getOptionValue("dir");
        }

        if (line.hasOption("pathfile")) {
            pathFile = line.getOptionValue("pathfile");
        }

        if (line.hasOption("file")) {
            singleFilePath = line.getOptionValue("file");
        }

        if (line.hasOption("outputfile")) {
            outputFile = line.getOptionValue("outputfile");
        }

        if (line.hasOption("json")) {
            outputFormat = OUTPUT_FORMATS.JSON;
        }

        if (line.hasOption("similarityFromFeatureVectorsDirectory")) {
            similarityFromFeatureVectorsDirectory = line
                    .getOptionValue("similarityFromFeatureVectorsDirectory");
        }

        if (line.hasOption("help")
                || (line.getOptions() == null || (line.getOptions() != null && line.getOptions().length == 0))
                || (directoryPath != null && pathFile != null && !directoryPath.equals("")
                        && !pathFile.equals(""))) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("pooled_time_series", options);
            System.exit(1);
        }

        if (directoryPath != null) {
            File dir = new File(directoryPath);
            List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE,
                    TrueFileFilter.INSTANCE);
            videoFiles = new ArrayList<Path>(files.size());

            for (File file : files) {
                String filePath = file.toString();

                // When given a directory to load videos from we need to ensure that we
                // don't try to load the of.txt and hog.txt intermediate result files
                // that results from previous processing runs.
                if (!filePath.contains(".txt")) {
                    videoFiles.add(file.toPath());
                }
            }

            LOG.info("Added " + videoFiles.size() + " video files from " + directoryPath);

        }

        if (pathFile != null) {
            Path list_file = Paths.get(pathFile);
            videoFiles = loadFiles(list_file);
            LOG.info("Loaded " + videoFiles.size() + " video files from " + pathFile);
        }

        if (singleFilePath != null) {
            Path singleFile = Paths.get(singleFilePath);
            LOG.info("Loaded file: " + singleFile);
            videoFiles = new ArrayList<Path>(1);
            videoFiles.add(singleFile);
        }

        if (similarityFromFeatureVectorsDirectory != null) {
            File dir = new File(similarityFromFeatureVectorsDirectory);
            List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE,
                    TrueFileFilter.INSTANCE);
            videoFiles = new ArrayList<Path>(files.size());

            for (File file : files) {
                String filePath = file.toString();

                // We need to load only the *.of.txt and *.hog.txt values
                if (filePath.endsWith(".of.txt")) {
                    videoFiles.add(file.toPath());
                }

                if (filePath.endsWith(".hog.txt")) {
                    videoFiles.add(file.toPath());
                }
            }

            LOG.info("Added " + videoFiles.size() + " feature vectors from "
                    + similarityFromFeatureVectorsDirectory);
            evaluateSimilarity(videoFiles, 1);
        } else {
            evaluateSimilarity(videoFiles, 0);
        }
        LOG.info("done.");

    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
    }

}

From source file:gov.nasa.jpl.memex.pooledtimeseries.PoT.java

public static void main(String[] args) {
      System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
      Option fileOpt = OptionBuilder.withArgName("file").hasArg().withLongOpt("file")
              .withDescription("Path to a single file").create('f');

      Option dirOpt = OptionBuilder.withArgName("directory").hasArg().withLongOpt("dir")
              .withDescription("A directory with image files in it").create('d');

      Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h');

      Option pathFileOpt = OptionBuilder.withArgName("path file").hasArg().withLongOpt("pathfile")
              .withDescription(/*from ww w  .j av a2s  .c  o m*/
                      "A file containing full absolute paths to videos. Previous default was memex-index_temp.txt")
              .create('p');

      Option outputFileOpt = OptionBuilder.withArgName("output file").withLongOpt("outputfile").hasArg()
              .withDescription("File containing similarity results. Defaults to ./similarity.txt").create('o');

      Option jsonOutputFlag = OptionBuilder.withArgName("json output").withLongOpt("json")
              .withDescription("Set similarity output format to JSON. Defaults to .txt").create('j');

      Option similarityFromFeatureVectorsOpt = OptionBuilder
              .withArgName("similarity from FeatureVectors directory")
              .withLongOpt("similarityFromFeatureVectorsDirectory").hasArg()
              .withDescription("calculate similarity matrix from given directory of feature vectors").create('s');

      Options options = new Options();
      options.addOption(dirOpt);
      options.addOption(pathFileOpt);
      options.addOption(fileOpt);
      options.addOption(helpOpt);
      options.addOption(outputFileOpt);
      options.addOption(jsonOutputFlag);
      options.addOption(similarityFromFeatureVectorsOpt);

      // create the parser
      CommandLineParser parser = new GnuParser();

      try {
          // parse the command line arguments
          CommandLine line = parser.parse(options, args);
          String directoryPath = null;
          String pathFile = null;
          String singleFilePath = null;
          String similarityFromFeatureVectorsDirectory = null;
          ArrayList<Path> videoFiles = null;

          if (line.hasOption("dir")) {
              directoryPath = line.getOptionValue("dir");
          }

          if (line.hasOption("pathfile")) {
              pathFile = line.getOptionValue("pathfile");
          }

          if (line.hasOption("file")) {
              singleFilePath = line.getOptionValue("file");
          }

          if (line.hasOption("outputfile")) {
              outputFile = line.getOptionValue("outputfile");
          }

          if (line.hasOption("json")) {
              outputFormat = OUTPUT_FORMATS.JSON;
          }

          if (line.hasOption("similarityFromFeatureVectorsDirectory")) {
              similarityFromFeatureVectorsDirectory = line
                      .getOptionValue("similarityFromFeatureVectorsDirectory");
          }

          if (line.hasOption("help")
                  || (line.getOptions() == null || (line.getOptions() != null && line.getOptions().length == 0))
                  || (directoryPath != null && pathFile != null && !directoryPath.equals("")
                          && !pathFile.equals(""))) {
              HelpFormatter formatter = new HelpFormatter();
              formatter.printHelp("pooled_time_series", options);
              System.exit(1);
          }

          if (directoryPath != null) {
              File dir = new File(directoryPath);
              List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE,
                      TrueFileFilter.INSTANCE);
              videoFiles = new ArrayList<Path>(files.size());

              for (File file : files) {
                  String filePath = file.toString();

                  // When given a directory to load videos from we need to ensure that we
                  // don't try to load the of.txt and hog.txt intermediate result files
                  // that results from previous processing runs.
                  if (!filePath.contains(".txt")) {
                      videoFiles.add(file.toPath());
                  }
              }

              LOG.info("Added " + videoFiles.size() + " video files from " + directoryPath);

          }

          if (pathFile != null) {
              Path list_file = Paths.get(pathFile);
              videoFiles = loadFiles(list_file);
              LOG.info("Loaded " + videoFiles.size() + " video files from " + pathFile);
          }

          if (singleFilePath != null) {
              Path singleFile = Paths.get(singleFilePath);
              LOG.info("Loaded file: " + singleFile);
              videoFiles = new ArrayList<Path>(1);
              videoFiles.add(singleFile);
          }

          if (similarityFromFeatureVectorsDirectory != null) {
              File dir = new File(similarityFromFeatureVectorsDirectory);
              List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE,
                      TrueFileFilter.INSTANCE);
              videoFiles = new ArrayList<Path>(files.size());

              for (File file : files) {
                  String filePath = file.toString();

                  // We need to load only the *.of.txt and *.hog.txt values
                  if (filePath.endsWith(".of.txt")) {
                      videoFiles.add(file.toPath());
                  }

                  if (filePath.endsWith(".hog.txt")) {
                      videoFiles.add(file.toPath());
                  }
              }

              LOG.info("Added " + videoFiles.size() + " feature vectors from "
                      + similarityFromFeatureVectorsDirectory);
              evaluateSimilarity(videoFiles, 1);
          } else {
              evaluateSimilarity(videoFiles, 1);
          }
          LOG.info("done.");

      } catch (ParseException exp) {
          // oops, something went wrong
          System.err.println("Parsing failed.  Reason: " + exp.getMessage());
      }

  }

From source file:gov.nasa.jpl.memex.pooledtimeseries.SimilarityCalculation.java

public static void main(String[] args) throws Exception {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Configuration baseConf = new Configuration();
    baseConf.set("mapred.reduce.tasks", "0");
    baseConf.set("meanDistsFilePath", args[2]);

    Job job = Job.getInstance(baseConf);
    job.setJarByClass(SimilarityCalculation.class);

    job.setJobName("similarity_calc");

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    job.setInputFormatClass(TextInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);

    FileInputFormat.setInputPaths(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));

    job.setMapperClass(Map.class);

    job.waitForCompletion(true);/*w  ww . ja va  2  s . c  o m*/
}

From source file:gov.nasa.jpl.memex.pooledtimeseries.MeanChiSquareDistanceCalculation.java

public static void main(String[] args) throws Exception {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

    Configuration baseConf = new Configuration();

    Job job = Job.getInstance(baseConf);
    job.setJarByClass(MeanChiSquareDistanceCalculation.class);

    job.setJobName("mean_chi_square_calculation");

    job.setMapOutputKeyClass(IntWritable.class);
    job.setMapOutputValueClass(DoubleWritable.class);
    job.setOutputKeyClass(IntWritable.class);
    job.setOutputValueClass(DoubleWritable.class);

    job.setInputFormatClass(TextInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);

    FileInputFormat.setInputPaths(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));

    job.setMapperClass(Map.class);
    job.setReducerClass(Reduce.class);

    job.waitForCompletion(true);/*w  ww  .  j  a  v a 2 s .  c om*/
}

From source file:xored.vpn.fixer.TokenDetector.java

public static void main(String[] args) throws InterruptedException, IOException {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    username = System.getProperty(USERNAME_KEY);
    pin = System.getProperty(PIN_KEY);
    nclauncher = System.getProperty(NCLAUNCHER_KEY);
    tokenUrl = System.getProperty(TOKEN_URL_KEY);

    if (username == null || username.trim().isEmpty() || pin == null || pin.trim().length() != 4) {
        logError("Username or pin is not set, exiting...");
        return;/*from  w w  w  . j  ava2  s.  c o m*/
    }
    if (nclauncher == null) {
        logError("Path to nclauncher.exe is not set, exiting...");
        return;
    }
    if (tokenUrl == null) {
        logError("Url to token is not set, exiting...");
        return;
    }
    int tryNumber = 0;
    TokenDetector td = new TokenDetector();
    while (true) {
        if (isVpnDown()) {
            if (tryNumber == 1) {
                logError("Last try was unsuccessful. Will try one more time...");
            } else if (tryNumber == 2) {
                logError("Last two attempts to restore VPN connection were unsuccessful. Have to stop..");
                return;
            } else {
                log("VPN is down! Trying to restore...");
            }
            log("Killing Network Connect ...");
            log(execCmd("taskkill /F /IM dsNetworkConnect.exe"));

            try {
                if (td.run()) {
                    Thread.sleep(60000);
                }
            } catch (Throwable e) {
                // ignore
            }
            tryNumber++;
            Thread.sleep(10000);
        } else {
            tryNumber = 0;
        }
    }

}

From source file:Main.java

static void loadLibrary() {
    if (loaded)/* w w  w.ja  va2  s. c o  m*/
        return;

    try {
        System.loadLibrary("openal");
        loaded = true;
    } catch (UnsatisfiedLinkError e) {
        System.err.println("Native code library failed to load.");
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:Main.java

private static boolean loadLibrary(String Name) {
    boolean result = true;

    Log.d(TAG, "Trying to load library " + Name);
    try {/*from   w  w w. j ava2  s  . co m*/
        System.loadLibrary(Name);
        Log.d(TAG, "Library " + Name + " loaded");
    } catch (UnsatisfiedLinkError e) {
        Log.d(TAG, "Cannot load library \"" + Name + "\"");
        e.printStackTrace();
        result &= false;
    }

    return result;
}