Java Code Examples for org.bytedeco.javacpp.Loader#load()
The following examples show how to use
org.bytedeco.javacpp.Loader#load() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FFmpegFrameFilter.java From VideoAndroid with Apache License 2.0 | 6 votes |
public static void tryLoad() throws Exception { if (loadingException != null) { throw loadingException; } else { try { Loader.load(org.bytedeco.javacpp.avutil.class); Loader.load(org.bytedeco.javacpp.avcodec.class); Loader.load(org.bytedeco.javacpp.avformat.class); Loader.load(org.bytedeco.javacpp.postproc.class); Loader.load(org.bytedeco.javacpp.swresample.class); Loader.load(org.bytedeco.javacpp.swscale.class); Loader.load(org.bytedeco.javacpp.avfilter.class); av_register_all(); avfilter_register_all(); } catch (Throwable t) { if (t instanceof Exception) { throw loadingException = (Exception)t; } else { throw loadingException = new Exception("Failed to load " + FFmpegFrameRecorder.class, t); } } } }
Example 2
Source File: FFmpegFrameRecorder.java From VideoAndroid with Apache License 2.0 | 6 votes |
public static void tryLoad() throws Exception { if (loadingException != null) { throw loadingException; } else { try { Loader.load(org.bytedeco.javacpp.avutil.class); Loader.load(org.bytedeco.javacpp.swresample.class); Loader.load(org.bytedeco.javacpp.avcodec.class); Loader.load(org.bytedeco.javacpp.avformat.class); Loader.load(org.bytedeco.javacpp.swscale.class); /* initialize libavcodec, and register all codecs and formats */ av_register_all(); avformat_network_init(); } catch (Throwable t) { if (t instanceof Exception) { throw loadingException = (Exception)t; } else { throw loadingException = new Exception("Failed to load " + FFmpegFrameRecorder.class, t); } } } }
Example 3
Source File: LivePlayTest3.java From oim-fx with MIT License | 6 votes |
public void run() { Loader.load(opencv_objdetect.class); try { grabber = FFmpegFrameGrabber.createDefault(url); grabber.start(); } catch (Exception e) { try { grabber.restart(); } catch (Exception e1) { } } while (true) { // try { getBufferedImage(); // sleep(1); // } catch (InterruptedException e) { // e.printStackTrace(); // } } }
Example 4
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierFullBody(String name) { try { setClassiferName(name); classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierFullBody = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 5
Source File: JCublasBackend.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public boolean canRun() { int[] count = { 0 }; org.bytedeco.cuda.global.cudart.cudaGetDeviceCount(count); if (count[0] <= 0) { throw new RuntimeException("No CUDA devices were found in system"); } Loader.load(org.bytedeco.cuda.global.cublas.class); return true; }
Example 6
Source File: TestNativeImageLoader.java From deeplearning4j with Apache License 2.0 | 5 votes |
org.opencv.core.Mat makeRandomOrgOpenCvCoreMatImage(int height, int width, int channels) { Mat img = makeRandomImage(height, width, channels); Loader.load(org.bytedeco.opencv.opencv_java.class); OpenCVFrameConverter.ToOrgOpenCvCoreMat c = new OpenCVFrameConverter.ToOrgOpenCvCoreMat(); return c.convert(c.convert(img)); }
Example 7
Source File: JCublasBackend.java From nd4j with Apache License 2.0 | 5 votes |
@Override public boolean canRun() { int[] count = { 0 }; cuda.cudaGetDeviceCount(count); if (count[0] <= 0) { throw new RuntimeException("No CUDA devices were found in system"); } Loader.load(cublas.class); return true; }
Example 8
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierUpperBody(String name) { try { classiferName = name; classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierUpperBody = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 9
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierEyeGlass(String name) { try { setClassiferName(name); classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierEyeglass = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 10
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierSideFace(String name) { try { classiferName = name; classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierSideFace = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 11
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierSmile(String name) { try { setClassiferName(name); classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierSmile = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 12
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifierEye(String name) { try { classiferName = name; classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifierEye = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 13
Source File: FaceDetector.java From ExoVisix with MIT License | 5 votes |
public void setClassifier(String name) { try { setClassiferName(name); classifierFile = Loader.extractResource(classiferName, null, "classifier", ".xml"); if (classifierFile == null || classifierFile.length() <= 0) { throw new IOException("Could not extract \"" + classiferName + "\" from Java resources."); } // Preload the opencv_objdetect module to work around a known bug. Loader.load(opencv_objdetect.class); classifier = new CvHaarClassifierCascade(cvLoad(classifierFile.getAbsolutePath())); classifierFile.delete(); if (classifier.isNull()) { throw new IOException("Could not load the classifier file."); } } catch (Exception e) { if (exception == null) { exception = e; } } }
Example 14
Source File: FFmpegFrameRecorderPlus.java From easyCV with Apache License 2.0 | 5 votes |
public static void tryLoad() throws Exception { if (loadingException != null) { throw loadingException; } else { try { Loader.load(org.bytedeco.javacpp.avutil.class); Loader.load(org.bytedeco.javacpp.swresample.class); Loader.load(org.bytedeco.javacpp.avcodec.class); Loader.load(org.bytedeco.javacpp.avformat.class); Loader.load(org.bytedeco.javacpp.swscale.class); /* initialize libavcodec, and register all codecs and formats */ av_jni_set_java_vm(Loader.getJavaVM(), null); avcodec_register_all(); av_register_all(); avformat_network_init(); Loader.load(org.bytedeco.javacpp.avdevice.class); avdevice_register_all(); } catch (Throwable t) { if (t instanceof Exception) { throw loadingException = (Exception)t; } else { throw loadingException = new Exception("Failed to load " + FFmpegFrameRecorder.class, t); } } } }
Example 15
Source File: AtariDQN.java From burlap_caffe with Apache License 2.0 | 4 votes |
public static void main(String[] args) { // Learning constants defined in the DeepMind Nature paper // (http://www.nature.com/nature/journal/v518/n7540/full/nature14236.html) int experienceMemoryLength = 1000000; int maxHistoryLength = 4; int staleUpdateFreq = 10000; double gamma = 0.99; int frameSkip = 4; int updateFreq = 4; double rewardClip = 1.0; float gradientClip = 1.0f; double epsilonStart = 1; double epsilonEnd = 0.1; int epsilonAnnealDuration = 1000000; int replayStartSize = 50000; int noopMax = 30; int totalTrainingSteps = 50000000; double testEpsilon = 0.05; // Testing and recording constants int testInterval = 250000; int totalTestSteps = 125000; int maxEpisodeSteps = 100000; int snapshotInterval = 1000000; String snapshotPrefix = "snapshots/experiment1"; String resultsDirectory = "results/experiment1"; // ALE Paths // TODO: Set to appropriate paths for your machine String alePath = "/path/to/atari/executable"; String romPath = "/path/to/atari/rom/file"; // Caffe solver file String solverFile = "example_models/atari_dqn_solver.prototxt"; // Load Caffe Loader.load(Caffe.class); // Create the domain ALEDomainGenerator domGen = new ALEDomainGenerator(ALEDomainGenerator.saActionSet()); SADomain domain = domGen.generateDomain(); // Create the ALEEnvironment and visualizer ALEEnvironment env = new ALEEnvironment(alePath, romPath, frameSkip, PoolingMethod.POOLING_METHOD_MAX); env.setRandomNoopMax(noopMax); ALEVisualExplorer exp = new ALEVisualExplorer(domain, env, ALEVisualizer.create()); exp.initGUI(); exp.startLiveStatePolling(1000/60); // Setup the ActionSet from the ALEDomain to use the ALEActions ActionSet actionSet = new ActionSet(domain); // Setup the training and test memory FrameExperienceMemory trainingExperienceMemory = new FrameExperienceMemory(experienceMemoryLength, maxHistoryLength, new ALEPreProcessor(), actionSet); // The size of the test memory is arbitrary but should be significantly greater than 1 to minimize copying FrameExperienceMemory testExperienceMemory = new FrameExperienceMemory(10000, maxHistoryLength, new ALEPreProcessor(), actionSet); // Initialize the DQN with the solver file. // NOTE: this Caffe architecture is made for 3 actions (the number of actions in Pong) DQN dqn = new DQN(solverFile, actionSet, trainingExperienceMemory, gamma); dqn.setRewardClip(rewardClip); dqn.setGradientClip(gradientClip); // Create the policies SolverDerivedPolicy learningPolicy = new AnnealedEpsilonGreedy(dqn, epsilonStart, epsilonEnd, epsilonAnnealDuration); SolverDerivedPolicy testPolicy = new EpsilonGreedy(dqn, testEpsilon); // Setup the learner DeepQLearner deepQLearner = new DeepQLearner(domain, gamma, replayStartSize, learningPolicy, dqn, trainingExperienceMemory); deepQLearner.setExperienceReplay(trainingExperienceMemory, dqn.batchSize); deepQLearner.useStaleTarget(staleUpdateFreq); deepQLearner.setUpdateFreq(updateFreq); // Setup the tester DeepQTester tester = new DeepQTester(testPolicy, testExperienceMemory, testExperienceMemory); // Setup helper TrainingHelper helper = new AtariDQN(deepQLearner, tester, dqn, actionSet, env, trainingExperienceMemory, testExperienceMemory); helper.setTotalTrainingSteps(totalTrainingSteps); helper.setTestInterval(testInterval); helper.setTotalTestSteps(totalTestSteps); helper.setMaxEpisodeSteps(maxEpisodeSteps); helper.enableSnapshots(snapshotPrefix, snapshotInterval); helper.recordResultsTo(resultsDirectory); //helper.verbose = true; // Uncomment this line to load learning state if resuming //helper.loadLearningState(snapshotDirectory); // Run helper helper.run(); }
Example 16
Source File: GridWorldDQN.java From burlap_caffe with Apache License 2.0 | 4 votes |
public static void main(String args[]) { // Learning constants double gamma = 0.99; int replayStartSize = 50000; int memorySize = 1000000; double epsilonStart = 1; double epsilonEnd = 0.1; double testEpsilon = 0.05; int epsilonAnnealDuration = 1000000; int staleUpdateFreq = 10000; // Caffe solver file String solverFile = "example_models/grid_world_dqn_solver.prototxt"; // Load Caffe Loader.load(caffe.Caffe.class); // Setup the network GridWorldDQN gridWorldDQN = new GridWorldDQN(solverFile, gamma); // Create the policies SolverDerivedPolicy learningPolicy = new AnnealedEpsilonGreedy(epsilonStart, epsilonEnd, epsilonAnnealDuration); SolverDerivedPolicy testPolicy = new EpsilonGreedy(testEpsilon); // Setup the learner DeepQLearner deepQLearner = new DeepQLearner(gridWorldDQN.domain, gamma, replayStartSize, learningPolicy, gridWorldDQN.dqn); deepQLearner.setExperienceReplay(new FixedSizeMemory(memorySize), gridWorldDQN.dqn.batchSize); deepQLearner.useStaleTarget(staleUpdateFreq); // Setup the tester Tester tester = new SimpleTester(testPolicy); // Set the QProvider for the policies learningPolicy.setSolver(deepQLearner); testPolicy.setSolver(deepQLearner); // Setup the visualizer VisualExplorer exp = new VisualExplorer( gridWorldDQN.domain, gridWorldDQN.env, GridWorldVisualizer.getVisualizer(gridWorldDQN.gwdg.getMap())); exp.initGUI(); exp.startLiveStatePolling(33); // Setup helper TrainingHelper helper = new TrainingHelper( deepQLearner, tester, gridWorldDQN.dqn, actionSet, gridWorldDQN.env); helper.setTotalTrainingSteps(50000000); helper.setTestInterval(500000); helper.setTotalTestSteps(125000); helper.setMaxEpisodeSteps(10000); // Run helper helper.run(); }
Example 17
Source File: TestFrameExperienceMemory.java From burlap_caffe with Apache License 2.0 | 4 votes |
@Before public void setup() { Loader.load(opencv_core.class); }
Example 18
Source File: LivePlayTest2.java From oim-fx with MIT License | 4 votes |
/** * 转流器 * * @param inputFile * @param outputFile * @throws Exception * @throws org.bytedeco.javacv.FrameRecorder.Exception * @throws InterruptedException */ public static void recordPush(String inputFile, int v_rs) throws Exception, org.bytedeco.javacv.FrameRecorder.Exception, InterruptedException { Loader.load(opencv_objdetect.class); long startTime = 0; FrameGrabber grabber = FFmpegFrameGrabber.createDefault(inputFile); try { grabber.start(); } catch (Exception e) { try { grabber.restart(); } catch (Exception e1) { throw e; } } OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); Frame grabframe = grabber.grab(); IplImage grabbedImage = null; if (grabframe != null) { System.out.println("取到第一帧"); grabbedImage = converter.convert(grabframe); } else { System.out.println("没有取到第一帧"); } System.out.println("开始推流"); CanvasFrame frame = new CanvasFrame("camera", CanvasFrame.getDefaultGamma() / grabber.getGamma()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setAlwaysOnTop(true); while (frame.isVisible() && (grabframe = grabber.grab()) != null) { System.out.println("推流..."); frame.showImage(grabframe); grabbedImage = converter.convert(grabframe); Frame rotatedFrame = converter.convert(grabbedImage); if (startTime == 0) { startTime = System.currentTimeMillis(); } Thread.sleep(40); } frame.dispose(); grabber.stop(); System.exit(2); }