javacpp | The missing bridge between Java and native C++

 by   bytedeco Java Version: 1.5.9 License: Non-SPDX

kandi X-RAY | javacpp Summary

kandi X-RAY | javacpp Summary

javacpp is a Java library. javacpp has no bugs, it has no vulnerabilities, it has build file available and it has high support. However javacpp has a Non-SPDX License. You can download it from GitHub, Maven.

JavaCPP provides efficient access to native C inside Java, not unlike the way some C/C compilers interact with assembly language. No need to invent new languages such as with [SWIG] [SIP] [C/CLI] [Cython] or [RPython] Instead, similar to what [cppyy] strives to do for Python, it exploits the syntactic and semantic similarities between Java and C. Under the hood, it uses JNI, so it works with all implementations of Java SE, in addition to [Android] [Avian] and [RoboVM] ([instructions] #instructions-for-android-avian-and-robovm)). More specifically, when compared to the approaches above or elsewhere ([CableSwig] [JNIGeneratorApp] [cxxwrap] [JNIWrapper] [Platform Invoke] [GlueGen] [LWJGL Generator] [JNIDirect] [ctypes] [JNA] [JNIEasy] [JniMarshall] [JNative] [J/Invoke] [HawtJNI] [JNR] [BridJ] [CFFI] [fficxx] [CppSharp] [cgo] [pybind11] [rust-bindgen] [Panama Native] etc.), it maps naturally and efficiently many common features afforded by the C language and often considered problematic, including overloaded operators, class and function templates, callbacks through function pointers, function objects (aka functors), virtual functions and member function pointers, nested struct definitions, variable length arguments, nested namespaces, large data structures containing arbitrary cycles, virtual and multiple inheritance, passing/returning by value/reference/string/vector, anonymous unions, bit fields, exceptions, destructors and shared or unique pointers (via either try-with-resources or garbage collection), and documentation comments. Obviously, neatly supporting the whole of C would require more work (although one could argue about the intrinsic neatness of C++), but we are releasing it here as a proof of concept. As a case in point, we have already used it to produce complete interfaces to OpenCV, FFmpeg, libdc1394, PGR FlyCapture, OpenKinect, videoInput, ARToolKitPlus, Leptonica, Tesseract, GSL, LLVM, HDF5, MKL, CUDA, Caffe, MXNet, TensorFlow, System APIs, and others as part of the [JavaCPP Presets] subproject, also demonstrating early parsing capabilities of C/C++ header files that show promising and useful results. Please feel free to ask questions on [the mailing list] or [the discussion forum] if you encounter any problems with the software! I am sure it is far from perfect…​.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              javacpp has a highly active ecosystem.
              It has 4098 star(s) with 559 fork(s). There are 175 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 71 open issues and 387 have been closed. On average issues are closed in 26 days. There are 14 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of javacpp is 1.5.9

            kandi-Quality Quality

              javacpp has 0 bugs and 0 code smells.

            kandi-Security Security

              javacpp has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              javacpp code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              javacpp has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              javacpp releases are available to install and integrate.
              Deployable package is available in Maven.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              javacpp saves you 12994 person hours of effort in developing the same functionality from scratch.
              It has 27406 lines of code, 2671 functions and 179 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed javacpp and discovered the below as its top functions. This is intended to give you an instant insight into javacpp implemented functionality, and help decide if they suit your requirements.
            • Put string array
            • Sets the index of the first byte in the array
            • Sets the index of the last byte in the array
            • Returns the contents of this index with the given indices
            • Sets the value in the index to the given array
            • Sets the index of the specified long
            • Returns the contents of the given short array in the given short array
            • Reads the contents of the short array into the given short array
            • Sets the contents of this short array into the given array
            • Inserts zero bytes into the array at the given indices
            • Put a string array into the buffer
            • Put string in buffer
            • Writes the contents of the short array to the given array
            • Writes the contents of a short to the given array
            • Returns the elements of the short array at the given indices
            • Puts a sorted short array into the index
            • Puts a range of shorts into the buffer
            • Puts an array of shorts into the index
            • Inserts a sorted short array
            • Puts a short array into the index
            • Puts a short array into the buffer
            • Main entry point
            • Puts a string into this buffer
            • Initialize this object
            • Add a property
            • Compares this object to another
            • Returns a temporary directory
            • Puts a pointer into this buffer
            • Parses the given string into a long
            • Initialize this class
            • Returns a string representation of this matrix
            Get all kandi verified functions for this library.

            javacpp Key Features

            No Key Features are available at this moment for javacpp.

            javacpp Examples and Code Snippets

            No Code Snippets are available at this moment for javacpp.

            Community Discussions

            QUESTION

            Problems building using gradle with nd4j
            Asked 2022-Feb-02 at 22:49

            I'm trying to build a module using nd4j.
            It builds fine with maven but not with gradle.
            I did an auto-conversion of the pom, I added the javacpp dependency by hand and
            it builds but the tests fail with link error no jniopenblas_nolapack in java.library.path.
            I've done a lot of net-searching to no avail.
            This is my dependencies section:

            ...

            ANSWER

            Answered 2022-Feb-02 at 22:49

            in the comments I would appreciate comments on our docs to help improve the site. We cover this scenario explicitly. I'll summarize it below then comment with a link. If you see anything missing please do help us improve the website for the future.

            Nd4j uses javacpp which relies on classifiers to determine how to include native binaries. The way it works is the core classes are put in a standalone library/artifactId (nd4j-native) and it needs an accompanying classifier dependency to go with it. This will be an artifact id with the same name and version plus an additional classifier. This will usually be the OS and architecture name for your platform. This could be linux-x86_64 (linux on 64 bit intel) or android-arm64 (android on 64 bit ARM devices)

            These also usually have accompanying dependencies such as openblas (which we also use the javacpp bindings for) to enable us to access fast 3rd party math routines.

            With that in mind a dependency block like this is usually what you're looking for:

            Source https://stackoverflow.com/questions/70958433

            QUESTION

            Is Nd4j (Deeplearning4J) too large to actually use in an android mobile app?
            Asked 2021-Apr-09 at 16:43

            After several weeks of development, I have finally created an AI in an Android App that works using the matrix manipulation API provided by the Nd4j library. These were imported into the project with gradle, following this documentation.

            Unfortunately, I'm finding out that Nd4j depends on some release-killingly large run time libraries, especially libnd4jcpu.so, which is about 150mb per abi platform, leading to apk sizes upwards of half a gigabyte! The average app size you'll find on the Google Play store is about 11.5MB.

            The compressed download size limit of Android App Bundles on Google Play is 150MB.

            The problem of how to reduce the size of the Dl4j dependencies was raised in a previous StackOverflow question. No solution could be offered however, except just to be more selective about what platforms you support. Again, per abi platform, that still means a minimum APK size of at minimum ~200MB.

            One has to wonder why the Deeplearning4J community has gone to the effort of supporting Android mobile development in the first place, and why the inevitable problem of runtime library dependency sizes isn't so much as mentioned anywhere in the documentation.

            Surely I am missing something here?

            ...

            ANSWER

            Answered 2021-Mar-02 at 13:17

            "Nd4j" is actually libraries + self contained c++ library compiled to native binaries per platform bundled in to the jar for fast performance. You typically want to strip down those dependencies in your build. You can see how to do that here:

            https://github.com/bytedeco/javacpp-presets/wiki/Reducing-the-Number-of-Dependencies

            Nd4j relies on javacpp for packaging. In short, you can either specify -Dplatform=android-x86_64 or android-arm64 (depending on the architecture) in your maven/gradle build if you use nd4j-native-platform or you can just use the nd4j-native dependency (no classifier) + the classifier for your platform.

            Editing my response a bit sorry I didn't get the time to fully read your question this morning. Let me respond point by point.

            First of all this: "One has to wonder why the Deeplearning4J community has gone to the effort of supporting Android mobile development in the first place.."

            1. First of all fair point and I want to work on this. Please be open minded when working with us here a bit. Generally people have specific requirements and work with us on their specific circumstances. Sometimes we help them minimize binary size via #2.

            2. Regarding this: "especially libnd4jcpu.so, which is about 150mb per abi platform, " as it stands generally folks come with different spins of their apps. We've admittedly focused more on op coverage than binary size. There's a minifier we have that could help: https://github.com/eclipse/deeplearning4j/tree/master/libnd4j/minifier I'm happy to help with your use case if you can be more specific, but it's not quite a "just read the docs and go about it on your own" experience.

            Surely I am missing something here?

            Source https://stackoverflow.com/questions/66426007

            QUESTION

            Can i select the only packages I used within my maven dependecies to export a runnable jar in eclipse?
            Asked 2021-Feb-11 at 02:07

            I'm using Javacpp in a Java application. Inside my pom I have:

            org.bytedeco javacv-platform 1.5.1

            and the only imports I have in the project are related with ffmpeg and opencv. However, when I create the runnable Jar, it is huge (hundreds of megabytes) because it has a lot of jars from other packages that come with javacv-platform that are useless for me (I can see them inside maven dependecies). Is there anyway to remove the packages I never used inside this dependency? Beacause I can see all of them inside the runnable jar I create.

            ...

            ANSWER

            Answered 2021-Feb-11 at 02:07

            Yes, you can just exclude what you don't need, like this:

            Source https://stackoverflow.com/questions/66147604

            QUESTION

            LLVM IR with JAVA-API
            Asked 2021-Jan-13 at 23:21

            I'm using ANTLR4 as Frontend and want to create my IR with LLVM. I'm using the JAVA-Api for LLVM from JavaCPP.

            Because I hate the docu...How can I add a Variable with this Api? Accordingly, I need a solution for local and global variables. If someone has a corresponding documentation or a good example, I would be very grateful.

            Many thanks

            ...

            ANSWER

            Answered 2021-Jan-13 at 23:21

            Well, as far as documentation goes, there is close to none for the LLVM C API. The C++ API on the other hand has some documentation for most of its methods which is why the "documentation" or "learning path" to using LLVM is usually just reading through relevant bits of its source code. I'm sure you've seen it before, but I'll link the offical C Doxygen index here as well. https://llvm.org/doxygen/group__LLVMC.html

            The offical language reference manual is also good at describing certain topics like metadata, attributes and so on. https://llvm.org/docs/LangRef.html

            As user arnt mentioned, for global variables, we use what is in the C++ API, known as GlobalVariable. In the C API we have functions for the LLVMModuleRef type which does what the C++ API does. For the most part, this is just attaching a new name (variable name) to the module with a type and optionally a value.

            Using the JavaCPP presets for Java, we can use the following snippet to declare a global variable in our module named "my_global" which is an 8-bit integer with an initializer value of 42.

            Source https://stackoverflow.com/questions/65634369

            QUESTION

            Cannot install rJava on Big Sur
            Asked 2020-Dec-14 at 22:01

            In the following environment:

            • Mac OS: Big Sur
            • R: version 4.0.3
            • Java: java version "1.8.0_271"

            I am trying to run:

            ...

            ANSWER

            Answered 2020-Dec-14 at 22:01

            JRI is currently not supported on Big Sur, because Apple has removed the last traces of Java support - here the JavaVM framework, so you have two options:

            1. use --disable-jri when installing rJava from sources (e.g. via install.packages("rJava", configure.args="--disable-jri"))

            2. use rJava from CRAN (i.e., install the binary version of rJava - not source)

            The issue tracking this is #248

            Source https://stackoverflow.com/questions/65278552

            QUESTION

            "Pointer being freed was not allocated" error using cython in parallel with an external c library based on FFTW
            Asked 2020-Nov-28 at 17:13
            What I'm attempting

            I have a code which was previously parallelised in python using multiprocess and it worked okay (although slow and memory hungry). I've decided to try to convert it to cython. I'm new to cython and not much experience in c. The below example is as simplified as I can get it, and it worked serially, but as soon as I parallelised it, it no longer works. Due to the nature of running in parallel I've gone through all my code and turned off gil.

            The code relies on an external C library https://github.com/astro-informatics/ssht/ (compilation instructions in the README) which uses fftw under the hood. This library has its own cython file which calls the same c function that I'm using (ssht_core_mw_inverse_sov_sym_ss). The function which closely resembles mine (in the cython file in that repo) looks like this

            ...

            ANSWER

            Answered 2020-Nov-28 at 17:13

            So as @DavidW pointed out that I'm running issues due to the fact that FFTW can't be run multithreaded (but works in python with multiprocessing). The problem is related to the external code I'm using which relies on FFTW. I've raised an issue to see if we can force the FFTW bits to be single threaded https://github.com/astro-informatics/ssht/issues/44

            Source https://stackoverflow.com/questions/65044164

            QUESTION

            Run C++ code in Java Android app using JavaCPP
            Asked 2020-Nov-27 at 04:04

            I a beginner when it comes to development for Android and I am trying to understand JavaCPP. I want to execute a C++ function from Java inside an Android application. In my example I just use a simple TextView widget that prints what I receive from C++. Following the documentation, inside the app's build.gradle I have included my javacpp library dependencies

            ...

            ANSWER

            Answered 2020-Nov-27 at 03:11

            I've posted a complete working example here:
            https://github.com/bytedeco/sample-projects/tree/master/gradle-javacpp-android

            For reference, we can reproduce this project with these steps by:

            1. Following the instructions at https://developer.android.com/studio/projects/add-native-code ,
            2. Adding something like below to the app/build.gradle file (after applying in the usual manner the org.bytedeco.gradle-javacpp-build plugin), and

            Source https://stackoverflow.com/questions/64847061

            QUESTION

            SQL syntax error in unit tests, after upgrade from Spring Boot 1.5.21 to 2.3.4
            Asked 2020-Oct-05 at 09:31

            There is an application written with Spring Boot 1.5.21. I'm asked to upgrade it to Spring Boot 2.3.4, and fix the errors the upgrade brings. Apparently, this didn't go well since I'm merely a beginner on many things. I've been able to solve some errors due to dependency changes, by googling. But the one I'm going to ask took me hours yet I didn't even see a clue of it.

            Directly this is the error message shown by IntelliJ:

            ...

            ANSWER

            Answered 2020-Oct-05 at 09:31

            The solution is simple and also really silly IMHO.

            In src/test/resources/application.yml, previously it was

            Source https://stackoverflow.com/questions/64150745

            QUESTION

            Java open CV hangs on VideoCapture for file if openCV is loaded with nu.pattern.OpenCV.loadShared();
            Asked 2020-Sep-30 at 08:26

            I have a sample code from https://ratiler.wordpress.com/2014/09/08/detection-de-mouvement-avec-javacv/ with small difference in loading the open cv library in the static block using nu.pattern.OpenCV.loadShared(); :

            ...

            ANSWER

            Answered 2020-Sep-30 at 08:26

            It was a licensing issue that made impossible to include ffmpeg to

            Source https://stackoverflow.com/questions/64128337

            QUESTION

            How to get rid of skewness in scanned form?
            Asked 2020-Sep-27 at 00:01

            I have to build a program that takes in skewed forms (images that have been scanned) for image processing. The first step is to get rid of the skeweness. I'm successfully getting the contours of the image, and I'm attempting to do a four_point_transform as presented in this post Remove top section of image above border line to detect text document . However, my code is failing due to:

            Error

            ...

            ANSWER

            Answered 2020-Sep-26 at 23:23

            getPerspectiveTransform() is working some other way (see my comment). However, I found minAreaRect() as more suitable method here. I have no prepared java enviroment so here is python code. I hope you will have no difficulties while converting it.

            Source https://stackoverflow.com/questions/64082909

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install javacpp

            To understand how JavaCPP is meant to be used, one should first take a look at the [Mapping Recipes for C/C++ Libraries](https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes), but a high-level overview of the [Basic Architecture](https://github.com/bytedeco/javacpp/wiki/Basic-Architecture) is also available to understand the bigger picture. The repository of the [JavaCPP Presets](https://github.com/bytedeco/javacpp-presets) further provides complex examples that we can use as templates, but it also includes a wiki page on how to [Create New Presets](https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets) that explains their structure in detail along with a small but complete sample project from which one can start experimenting with.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
            Maven
            Gradle
            CLONE
          • HTTPS

            https://github.com/bytedeco/javacpp.git

          • CLI

            gh repo clone bytedeco/javacpp

          • sshUrl

            git@github.com:bytedeco/javacpp.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Java Libraries

            CS-Notes

            by CyC2018

            JavaGuide

            by Snailclimb

            LeetCodeAnimation

            by MisterBooo

            spring-boot

            by spring-projects

            Try Top Libraries by bytedeco

            javacv

            by bytedecoJava

            javacpp-presets

            by bytedecoJava

            javacv-examples

            by bytedecoScala

            sample-projects

            by bytedecoJava

            sbt-javacv

            by bytedecoJava