Created
September 10, 2017 11:08
-
-
Save mitallast/bee3a2e9663a4dfd863b9deaa6960dac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.mitallast.queue; | |
| import org.bytedeco.javacpp.Loader; | |
| import org.bytedeco.javacpp.opencv_core.Mat; | |
| import org.bytedeco.javacpp.opencv_core.Size; | |
| import static org.bytedeco.javacpp.opencv_imgcodecs.imread; | |
| import static org.bytedeco.javacpp.opencv_imgcodecs.imwrite; | |
| import static org.bytedeco.javacpp.opencv_imgproc.CV_INTER_AREA; | |
| import static org.bytedeco.javacpp.opencv_imgproc.resize; | |
| public class OpenCVTest { | |
| static { | |
| Loader.load(org.bytedeco.javacpp.opencv_core.class); | |
| Loader.load(org.bytedeco.javacpp.opencv_imgcodecs.class); | |
| Loader.load(org.bytedeco.javacpp.opencv_imgproc.class); | |
| } | |
| public static void main(String... args) throws Exception { | |
| long start = System.currentTimeMillis(); | |
| for (int i = 0; i < 1000; i++) { | |
| Mat source = imread("cats.jpg"); | |
| Mat dest = new Mat(); | |
| Size sz = new Size(100, 100); | |
| resize(source, dest, sz, 0.0, 0.0, CV_INTER_AREA); | |
| imwrite("cats.resized.jpg", dest); | |
| } | |
| long end = System.currentTimeMillis(); | |
| printQps("opencv", 1000, start, end); | |
| } | |
| private static void printQps(String metric, long total, long start, long end) { | |
| long qps = (long) (total / (double) (end - start) * 1000.); | |
| System.out.println(metric + ": " + total + " at " + (end - start) + "ms"); | |
| System.out.println(metric + ": " + qps + " qps"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment