| 175 | |
| 176 | This builds a single shared object file (libopencv_java320.so), a jar file (opencv-320.jar) and a ton of static libraries (*.a)[[BR]] |
| 177 | It copies the shared object file and the jar file to the install directory: {{{/usr/local/share/OpenCV/java/...}}}[[BR]] |
| 178 | |
| 179 | NOTE: we could not get the java wrapper to work with ffmpeg enabled (we ran into a Segmentation fault with opencv libs 3.2.0, 3.3.0, and 3.3.1). We gave up and disabled it.[[BR]] |
| 180 | |
| 181 | If you do not want to git clone the master opencv repository, download a zipped version: |
| 182 | [https://github.com/opencv/opencv/archive/3.2.0.zip opencv-3.2.0.zip][[BR]] |
| 183 | |
| 184 | ==== Java Projects with OpenCV ==== |
| 185 | ===== Enable VideoCapture ===== |
| 186 | First, to allow OpenCV VideoCapture to access the ribbon cable camera, run the following command: |
| 187 | {{{ |
| 188 | sudo modprobe bcm2835-v4l2 |
| 189 | }}} |
| 190 | |
| 191 | ===== Compiling ===== |
| 192 | {{{ |
| 193 | javac -d <build_path> -classpath <external_jars> <source_path>/*.java |
| 194 | }}} |
| 195 | |
| 196 | where: |
| 197 | * {{{build_path = directory to store class files}}} |
| 198 | * {{{external_jars = string specifying individual jar dependencies (such as OpenCV and Pi4J) with delimiters as follows:}}} |
| 199 | * {{{:/path_to_jars/jar1.jar:/path_to_jars/jar2.jar}}} |
| 200 | * {{{souce_path = directory containing all of your java files to be compiled}}} |
| 201 | |
| 202 | We recommend creating a {{{libs}}} folder in which you store all of your external jars such as the {{{opencv-320.jar}}} and all the Pi4J jars rather than having your libraries scattered all over your machine. |
| 203 | |
| 204 | ===== Running ===== |
| 205 | {{{ |
| 206 | sudo java -Djava.library.path=<opencv_install_path> -Dpi4j.debug -Dpi4j.linking=dynamic -classpath <external_jars> <Main_class> |
| 207 | }}} |
| 208 | |
| 209 | where: |
| 210 | * {{{external_jars = same string that you used in the Compilation step}}} |
| 211 | * {{{Main_class = name of the class file with main method}}} |
| 212 | * For example, where {{{Vision.class}}} is the class file, {{{Main_class = Vision}}} |