Deeplearning4j / TensorFlow / OpenCV on Jetson TX2

Ahoy guys 

Regarding Deeplearning4j / Nixie / Jetson TX2

Is is "just" Openblas and libnd4j  that needs to compile on the tx2 (arm64 / aarch64 / CUDA version: release 9.0 V9.0.252), or is it more to it than that ?

Current error:

[ERROR] Failed to execute goal on project mrl: Could not resolve dependencies for project org.myrobotlab:mrl:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.bytedeco.javacpp-presets:ffmpeg:jar:linux-aarch64:2.8.1-1.1, org.nd4j:nd4j-native:jar:linux-aarch64:1.0.0-alpha, org.bytedeco.javacpp-presets:openblas:jar:linux-aarch64:0.2.20-1.4.1, jdk.tools:jdk.tools:jar:1.8: Failure to find org.bytedeco.javacpp-presets:ffmpeg:jar:linux-aarch64:2.8.1-1.1 in https://repo.maven.apache.org/maven2was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

 

I compiled TensorFlow and that whent ok, but i understand it wil take some work from you gurus to

implement it to Nixie, and there is probaly more urgen matters than this...

 

For anyone else looking for info on Nixie / TensorFlow progress:

https://github.com/MyRobotLab/myrobotlab/issues/209

 

Last question, i would be nice just to test out Nixie a bit on the TX2, is there some way in Maven to "disable"

the bits that dosent currently compile so i could compile a Nixie jar without them?

 

And if there is anything i can do to help, please let me know 

kwatters's picture

JavaCPP presets

Hi Spawn32.. Awesome that you're able to build libnd4j, that's a big step.

It sounds like you're on the right path.  Reality is though, you also need the javacpp-presets with compilation for openblas, and ffmpeg.  

https://github.com/bytedeco/javacpp-presets

Also., when you check out the source code, make sure you check out the tag/branch for the specific release that you're trying to build.  For example. if you want to build Deeplearning4j, it's the 1.0.0-alpha release.  If you compile it from "master" you'll end up with the wrong version to satisfy the dependencies.

Of note, there's a slightly newer version of deeplearning4j that's out 1.0.0-beta.   We're still linking and depending on the 1.0.0-alpha branch.. We'll probably wait for the official 1.0 release to come out before upgrading MRL again.

So to build Deeplearning4j for version 1.0.0-alpha you'll specifically want to check out the following branch/commit:

https://github.com/deeplearning4j/deeplearning4j/tree/70e63018a65ae4a182...

That was the commit where the version number was bumped to 1.0.0-alpha 

Spawn32's picture

Follow Up question ;)

@Grog / @Kwatters, as i mentioned last week, i cloned the javacpp-presets and tensoreflow to my TX2 and it compiled just fine (mvn clean package .. install etc..) i ended up with tensorflow.jar, tesnsorflow-javadox.jar, tesnsorflow-linux-aarc64.jar and tensorflow-sources.jar
 
Dosent that mean it would work ok in MRL now that kwatters has implemented it ? if not, anything i can help with ? :)
 
Spawn32's picture

So had a go at OpenCV

So had a go at OpenCV tonight:

@kwatters and @ GroG, it made it to 92% compiled / linked and failed on boostdesc.cpp, this might just be a cmake problem or a file it coulden't download, will fix that tomorrow hopefully.. what i did was to copy paste the linux-arm64 section in cppbuild.sh and renamed the second one to linux-aarch64, they are very similar but i need to go over the compiler directives to be 100% sure,

Do any of you know about a javacpp project that has aarch64 support, would be the easyest way to checking them..

almoste workey ;)

Spawn32's picture

@kwatters, got the OpenCV

@kwatters, got the OpenCV thingy compiled :)

But since there are other parts of nixie that dosent compile on the tx2 yet, could you be so nice and surgicaly inject the neede file from my onedrive linke here, and compile me a nixie jar ? pretty please :)

 

https://1drv.ms/u/s!Asf9doI7WS5djfYkTysFXAKvJt412A

 

included the 4 jar files it buildt , not sure witch of them you need...

Spawn32's picture

renamed the jar

renamed the jar to:  opencv-3.4.1-1.4.1-linux-aarch64.jar
and placed it in /libraries/jar
this was the output:
 
 
02:43:28.387 [AWT-EventQueue-0] INFO  c.myrobotlab.swing.RuntimeGui - ******************popUpTrigger*********************
02:43:33.848 [runtime] INFO  class org.myrobotlab.service.Runtime - Runtime.createService opencv
02:43:33.850 [runtime] INFO  c.myrobotlab.framework.Service - getMessageSet loading 227 non-sub-routable methods
02:43:33.850 [runtime] INFO  c.myrobotlab.framework.Service - cfg file /media/nvidia/970EVO/Nixie/Nixi Pre_comp/.myrobotlab/opencv.json does not exist
02:43:33.851 [runtime] INFO  c.myrobotlab.framework.Service - no such method Runtime.registered(OpenCV) :  - attempting upcasting
02:43:33.852 [runtime] INFO  c.myrobotlab.framework.Service - searching through 275 methods
02:43:33.853 [python] INFO  c.myrobotlab.framework.Service - no such method Python.onRegistered(OpenCV) :  - attempting upcasting
02:43:33.853 [SwingGui] INFO  c.myrobotlab.framework.Service - no such method SwingGui.addTab(OpenCV) :  - attempting upcasting
02:43:33.853 [python] INFO  c.myrobotlab.framework.Service - searching through 182 methods
02:43:33.854 [SwingGui] INFO  c.myrobotlab.framework.Service - searching through 211 methods
02:43:33.854 [SwingGui] INFO  c.myrobotlab.framework.Service - no such method RuntimeGui.onRegistered(OpenCV) :  - attempting upcasting
02:43:33.855 [SwingGui] INFO  c.myrobotlab.framework.Service - searching through 76 methods
02:43:33.856 [python] INFO  class org.myrobotlab.service.Python - exec(String) 
from org.myrobotlab.service import OpenCV
opencv = Runtime.getService("opencv")
 
02:43:33.874 [webgui] INFO  c.myrobotlab.framework.Service - no such method WebGui.onRegistered(OpenCV) :  - attempting upcasting
02:43:33.875 [webgui] INFO  c.myrobotlab.framework.Service - searching through 206 methods
02:43:33.875 [webgui] INFO  c.myrobotlab.framework.Service - subscribe [opencv/publishStatus ---> webgui/onStatus]
02:43:33.876 [webgui] INFO  c.myrobotlab.framework.Service - subscribe [opencv/publishState ---> webgui/onState]
02:43:33.884 [AWT-EventQueue-0] INFO  c.myrobotlab.service.SwingGui - createTab opencv org.myrobotlab.swing.OpenCVGui
02:43:35.291 [runtime] ERROR c.myrobotlab.framework.Instantiator - getNewInstance failed
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_171]
at org.myrobotlab.framework.Instantiator.getThrowableNewInstance(Instantiator.java:55) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Instantiator.getNewInstance(Instantiator.java:19) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Instantiator.getNewInstance(Instantiator.java:33) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.createService(Runtime.java:345) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.create(Runtime.java:236) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.createAndStart(Runtime.java:249) [myrobotlab.jar:1.1.184]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.myrobotlab.framework.Service.invokeOn(Service.java:1360) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Service.invoke(Service.java:1296) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Service.run(Service.java:1693) [myrobotlab.jar:1.1.184]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_171]
at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_171]
at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_171]
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1220) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:980) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:879) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10) ~[opencv-3.4.1-1.4.1.jar:3.4.1-1.4.1]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_171]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_171]
at org.bytedeco.javacpp.Loader.load(Loader.java:938) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:879) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.opencv_imgproc$CvFont.<clinit>(opencv_imgproc.java:2318) ~[opencv-3.4.1-1.4.1.jar:3.4.1-1.4.1]
at org.myrobotlab.opencv.VideoProcessor.<init>(VideoProcessor.java:78) ~[myrobotlab.jar:1.1.184]
at org.myrobotlab.service.OpenCV.<init>(OpenCV.java:159) ~[myrobotlab.jar:1.1.184]
... 18 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: no opencv_cudev in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_171]
at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_171]
at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_171]
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1220) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:965) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
... 27 common frames omitted
02:43:35.298 [runtime] ERROR c.myrobotlab.framework.Service - runtime error createAndStart(opencv, org.myrobotlab.service.OpenCV) error
02:43:35.293 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [opencv/publishStatus ---> SwingGui/onStatus]
02:43:35.302 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [opencv/publishState ---> SwingGui/onState]
02:43:35.304 [runtime] ERROR class org.myrobotlab.logging.Logging - ------
java.lang.NullPointerException
at org.myrobotlab.service.Runtime.createAndStart(Runtime.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.myrobotlab.framework.Service.invokeOn(Service.java:1360)
at org.myrobotlab.framework.Service.invoke(Service.java:1296)
at org.myrobotlab.framework.Service.run(Service.java:1693)
at java.lang.Thread.run(Thread.java:748)
 
 
 
 
 
 
Spawn32's picture

I can compile the opencv with and without cuda now, without cuda

@Kwatters @GroG or anyone else :)
 
I can compile the opencv with and without cuda now, without cuda the file is 18.1mb with cuda 45mb.
 
But mrl always throws this two errors:
Caused by: java.lang.UnsatisfiedLinkError: no opencv_cudev in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path (what is this one ? )
 
This starts to lead me to think ther is something else that also needs "adjustmen" in mrl, getting pretty sure
the opencv i compile should be good.
 
Is there anyway for you ore @GroG to figure out what in mrl that throw this erros / wher this checks are done?
 
And do you stil have your opencv source directories you used to compile you raspi opencv, if so, could you send / upload this two files for me, so i can check what options are on and off in you "working" compile ?
 
I would need:
javacpp-presets-master\opencv\cppbuild\linux-arm64\opencv-3.4.1\CMakeCache.txt
javacpp-presets-master\opencv\cppbuild\linux-arm64\opencv-3.4.1\CMakeVars.txt
 
I have also noticed in the original javacpp-presets-master directory there is a /CUDA but there is no cuda jar in mrl, could this be the problem ? does it need to be added ?
 
 
from org.myrobotlab.service import OpenCV
opencv_cuda = Runtime.getService("opencv_cuda")
 
00:36:47.696 [SwingGui] INFO  c.myrobotlab.framework.Service - no such method SwingGui.addTab(OpenCV) :  - attempting upcasting
00:36:47.697 [SwingGui] INFO  c.myrobotlab.framework.Service - searching through 211 methods
00:36:47.697 [webgui] INFO  c.myrobotlab.framework.Service - no such method WebGui.onRegistered(OpenCV) :  - attempting upcasting
00:36:47.697 [SwingGui] INFO  c.myrobotlab.framework.Service - no such method RuntimeGui.onRegistered(OpenCV) :  - attempting upcasting
00:36:47.697 [webgui] INFO  c.myrobotlab.framework.Service - searching through 206 methods
00:36:47.697 [SwingGui] INFO  c.myrobotlab.framework.Service - searching through 76 methods
00:36:47.699 [webgui] INFO  c.myrobotlab.framework.Service - subscribe [opencv_cuda/publishStatus ---> webgui/onStatus]
00:36:47.699 [webgui] INFO  c.myrobotlab.framework.Service - subscribe [opencv_cuda/publishState ---> webgui/onState]
00:36:47.751 [AWT-EventQueue-0] INFO  c.myrobotlab.service.SwingGui - createTab opencv_cuda org.myrobotlab.swing.OpenCVGui
00:36:47.951 [runtime] ERROR c.myrobotlab.framework.Instantiator - getNewInstance failed
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_171]
at org.myrobotlab.framework.Instantiator.getThrowableNewInstance(Instantiator.java:55) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Instantiator.getNewInstance(Instantiator.java:19) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Instantiator.getNewInstance(Instantiator.java:33) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.createService(Runtime.java:345) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.create(Runtime.java:236) [myrobotlab.jar:1.1.184]
at org.myrobotlab.service.Runtime.createAndStart(Runtime.java:249) [myrobotlab.jar:1.1.184]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.myrobotlab.framework.Service.invokeOn(Service.java:1360) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Service.invoke(Service.java:1296) [myrobotlab.jar:1.1.184]
at org.myrobotlab.framework.Service.run(Service.java:1693) [myrobotlab.jar:1.1.184]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_171]
at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_171]
at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_171]
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1220) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:980) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:879) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10) ~[opencv-3.4.1-1.4.1.jar:3.4.1-1.4.1]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_171]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_171]
at org.bytedeco.javacpp.Loader.load(Loader.java:938) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.Loader.load(Loader.java:879) ~[javacpp-1.4.1.jar:3.4.1-1.4.1]
at org.bytedeco.javacpp.opencv_imgproc$CvFont.<clinit>(opencv_imgproc.java:2318) ~[opencv-3.4.1-1.4.1.jar:3.4.1-1.4.1]
at org.myrobotlab.opencv.VideoProcessor.<init>(VideoProcessor.java:78) ~[myrobotlab.jar:1.1.184]
at org.myrobotlab.service.OpenCV.<init>(OpenCV.java:159) ~[myrobotlab.jar:1.1.184]
... 18 common frames omitted
Caused by: java.lang.UnsatisfiedLinkError: no opencv_cudev in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_171]
at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_171]
at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_171]
kwatters's picture

jniopencv_core is key

When you built the opencv-linux-aarch64.jar file and added it to the libraries/jar folder, did the jniopencv_core link error go away?  It should have..  

That's the key one, I'm pretty sure the opencv_cudev stuff is just cuda related, and I think for the purposes of this task you should get native cpu working first.  Keep it simple.  Then once that's working, try to enable the cuda support.  (which seems difficult due to the TX2 requiring Cuda9.2 where as OpenCV is still with Cuda9.1)

The goal here is to get it to work at all on the aarch64 arcitecture.

 

Spawn32's picture

opencv_bigguns

@Kwatters, @Grog

Did a test on my windows machine, deleted the opencv x86_64 file and go the exact same jniopencv_core link error as expexcted.

Then copyed it back and renamed it to opencv_bigguns, and guess what it worked again :/ ,so mrl doesn pic the arcitecture from the file name, it scans for something inside all opencv jar's util if finds a match and i have no clue what it could be.... ???? 

Or acctaly, it can look like it scans all availibal jar's in libraries until it finds a match..

kwatters's picture

filename matters not

Spawn32, you're absolutely right, the file name has absolutely nothing to do with MRL finding the library.  You can name the file  foo.jar if you like.  It doesn't matter.

The important thing is that the library that is contained within the jar is there and valid for your platform... 

All the jar files in the libraries/jar are in the classpath.  That means, so long as the jar file is in that directory, the JVM can find it.

Ok.. so now the question is, why is the jniopencv_core not being loaded as expected.

I would recommend opening up the jar file and checking the libraries inside of them.  A "jar" file is basically like a zip file.  You can un"jar" it.  

(

I'd recommend copying your custom jar file into a temp directory and run:

"/opt/jdk1.8.0_40/bin/jar xvf opencv-3.4.0-1.4-linux-x86_64.jar"    (replace with your jar filename)

this will extract the contents of the jar file into the current directory.  Once that is done, you should be able to see the ".so" files.  These are the native libraries  (for a linux system.. on windows they would be .dll)  

The output should look something like the following:

 inflated: META-INF/MANIFEST.MF
  created: META-INF/
  created: org/
  created: org/bytedeco/
  created: org/bytedeco/javacpp/
  created: org/bytedeco/javacpp/linux-x86_64/
  created: META-INF/maven/
  created: META-INF/maven/org.bytedeco.javacpp-presets/
  created: META-INF/maven/org.bytedeco.javacpp-presets/opencv/
 inflated: org/bytedeco/javacpp/linux-x86_64/libjnicvkernels.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_imgproc.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_shape.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_shape.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_superres.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_text.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_xfeatures2d.so
 inflated: META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml
 inflated: META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_bioinspired.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_dnn.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_features2d.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_flann.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_highgui.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_imgcodecs.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_bioinspired.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_dnn.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_text.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_ximgproc.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_calib3d.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_flann.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_highgui.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_imgcodecs.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_ml.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_ml.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_stitching.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_videoio.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_videostab.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_calib3d.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_face.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_features2d.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_imgproc.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_photo.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_stitching.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_videostab.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_core.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_objdetect.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_optflow.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_optflow.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_superres.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_video.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_video.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_core.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_ximgproc.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libgomp.so.1
 inflated: org/bytedeco/javacpp/linux-x86_64/libjniopencv_face.so
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_plot.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_tracking.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_objdetect.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_photo.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_videoio.so.3.4
 inflated: org/bytedeco/javacpp/linux-x86_64/libopencv_xfeatures2d.so.3.4
 
In particular you're intested in the file :  org/bytedeco/javacpp/linux-x86_64/libjniopencv_core.so
 

These are dynamically linked libraries, which means they likely depend on other things already being installed on the system.

 

One of the best tools for doing this is the "ldd" command.

The operating system will look in the LD_LIBRARY_PATH to find the operating system dependencies.  (On windows, I think it's just PATH )

when you have a dynamic library you can run the command  (change into directory that this file is in)

"ldd libjniopencv_core.so"
 
The output should look something like the following"
 
        linux-vdso.so.1 =>  (0x00007fffd85ff000)
        libopencv_imgproc.so.3.4 => /home/kwatters/nixie/libraries/jar/tmp/org/bytedeco/javacpp/linux-x86_64/./libopencv_imgproc.so.3.4 (0x00007fe0a6f3e000)
        libopencv_core.so.3.4 => /home/kwatters/nixie/libraries/jar/tmp/org/bytedeco/javacpp/linux-x86_64/./libopencv_core.so.3.4 (0x00007fe0a6a6c000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fe0a674e000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fe0a64ca000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fe0a62b3000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fe0a5f1f000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fe0a5d1b000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe0a5afd000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fe0a58f5000)
        libgomp.so.1 => /home/kwatters/nixie/libraries/jar/tmp/org/bytedeco/javacpp/linux-x86_64/./libgomp.so.1 (0x00007fe0a56e0000)
        /lib64/ld-linux-x86-64.so.2 (0x000000367ec00000)
 
In particular you want to make sure you don't see anything like  "file not found"  ... if you do, it means that there is some missing dependency..

There might be some missing dependency on the operating system...

 

If you see a  "file not found" for one of those listed linked depenencies for the native library.. that is what's missing and likely the reason it's not working.  I suspect it's going to be the file  libopencv_cudev.so .. but you will have to test and let us know what you find.

 

Good Luck!

 

NOTE: "jar" is part of the  JDK  (not part of the JRE) ...  For my redhat linux that means the location of the "jar" command is in "/opt/jdk1.8.0_40/bin"

 
Spawn32's picture

Wow, thank you Kwatters, this

Wow, thank you Kwatters, this was really good info, and as usual i learned a lot:)

 

Will dissect the jar tonight, i am stubborn, i never give up before it works...

Spawn32's picture

nvidia@tegra-ubuntu:~/jar

nvidia@tegra-ubuntu:~/jar temp/org/bytedeco/javacpp/linux-aarch64$ ldd libjniopencv_core.so
linux-vdso.so.1 =>  (0x0000007fab6f3000)
libopencv_imgproc.so.3.4 => /media/nvidia/970EVO/Nixie_tmp/javacpp-presets/opencv/cppbuild/linux-aarch64/lib/libopencv_imgproc.so.3.4 (0x0000007faaeed000)
libopencv_core.so.3.4 => /media/nvidia/970EVO/Nixie_tmp/javacpp-presets/opencv/cppbuild/linux-aarch64/lib/libopencv_core.so.3.4 (0x0000007faab7e000)
libstdc++.so.6 => /usr/lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007faa9cb000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007faa91e000)
libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007faa8fd000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007faa7b5000)
/lib/ld-linux-aarch64.so.1 (0x000000556e5dc000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007faa7a2000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007faa776000)
libgomp.so.1 (0x0000007faa747000)
 
Seems to be fine, or do you see somthing i am missing Kwatters ?
have also check some of the other so's, seems normal :/
 
regarding cuda:
If i compile with -DWITH_CUDA=OFF i get UnsatisfiedLinkError: no opencv_cudev in java.library.path
 
If i compile with -DWITH_CUDA=ON i get UnsatisfiedLinkError: no opencv_cudev in java.library.path but the jar grows to twice the size. (as it should)
 
 
 
Have also done a asci search for CUDEV in all files of the jar compiled with -DWITH_CUDA=OFF,
and in libjniopencv_core.so.3.4 i find it listed as Unavailable, that should be correct ?
 
Disabled: ccalib datasets dnn_objdetect dpm freetype fuzzy hfs js line_descriptor python2 python3 reg rgbd saliency stereo surface_matching world xobjdetect
    
Disabled by dependency:      -
  
Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv dnn_modern hdf matlab ovis sfm ts viz
   
 
 
 
Re compiling with cuda to do the same check on that file....
Edit:
Seems it builds with cuda when -DWITH_CUDA=ON
 
 OpenCV modules:
    To be built: aruco bgsegm bioinspired calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn face features2d flann highgui img_hash imgcodecs imgproc java java_bindings_generator ml objdetect optflow phase_unwrapping photo plot python_bindings_generator shape stitching structured_light superres text tracking video videoio videostab xfeatures2d ximgproc xphoto
   
 Disabled:  ccalib datasets dnn_objdetect dpm freetype fuzzy hfs js line_descriptor python2 python3 reg rgbd saliency stereo surface_matching world xobjdetect
    Disabled by dependency:      -
 
But shouldent at least the UnsatisfiedLinkError: no jniopencv_core in java.library.path disapear if it found the right file,
or could i throw that error as well becuse of the opencv_cudev in java.library.path
 
 
 
 
 
 
 
 
 
 
kwatters's picture

the ldd output looked good..

Ok, so that output looked good.  Clearly those library files are compiled correctly and have all the dependencies needed to make sure ldd is happy.

Now that you have extracted the jar file..  try copying all of the *.so* files into the MRL/libraries/native directory ...  

In MyRobotLab, native libraries that are no packaged into a jar file will be loaded from the libraries/native directory...  you might be able to trick MRL into picking those libraries up from that location.. 

Beyond that, i'm starting to run out of tricks to try...

Spawn32's picture

@kwatters. Haven't started

@kwatters.

Haven't started to do more debugging yet, but just for fun i opened another terminal windows and did a dmesg -wH, and once i press capture in opencv i can see that it powers up / looks for my cameras, so at least i now know the opencv module is compiled correctly :)

EDIT:

Got a tip from Saudet that i should compile with linux-arm64 and not linux-aarch64 (but stil as aarch64 code), that WORKEY :)

mvn install -Djavacpp.platform=linux-arm64

I can now just copy the new jar and into libraries and Nixie / Mrl finds it, left to do, get picture :D

Spawn32's picture

Results from todays test's:A

Results from todays test's:

A normal logitech 922 works with my opencv txt jar.

And if i set up a gstream server on the tx2 (using my csi cam's) and connect to the stream with opencv it works, but gives bad face recon, etc, since the tx2 also then needs to encode a h265 stream at the same time it does the face recon...

So my problem is:

I have only eralyer tested the nvcamerasrc (Nvidia thingy) and gstreamer to capure / display video on my TX2, i did do a v4l2 compliance test and it passed (for some strange reason) , it was now that i suddenly needed v4l i realy tested it and it's not worky like it should, nvidia has deprecated a parameter "pixel_T" that i need to fix in my camera drivers, this kills v4l :/

when i get v4l fixed we can direct connect to the cam and want eat up cpu / gpu cycles doing h265encode / decode...

@Alexinator:

if you want to test streming follow this guide, but using a face recon filer makes it useless at the moment since all frames are buffered somewher, so if you move or do a chnge in the picture you will see it a few minuttes after :)

but her you go:  (remember to turn op clocks and fan  from home dir sudo./jetson_clocks.sh)

wget https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.8.3.tar.xz

tar -xvf gst-rtsp-server-1.8.3.tar.xz

cd gst-rtsp-server-1.8.3

./configure --libdir=/usr/lib/arm-linux-gnueabihf/

make

cd examples

 

start stream with :  

./test-launch "( nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=820, height=616, framerate=30/1, format=NV12 ! omxh265enc ! rtph265pay name=pay0 pt=96 )"

fire up mrl and opencv, choose opencv , press file, and chnage whats in the file box with:

rtsp://127.0.0.1:8554/test

Press capture and you should have live video :)

new jar for you in this OneDrive link:  https://1drv.ms/u/s!Asf9doI7WS5djfYo2qjcDPKYmgsbCg

to big for email..

 

Spawn32's picture

@kwatters, Found this

@kwatters,

Found this example on how the tx2 access the cam directly from native opencv, it might even make sense to you, i don't know python, if you see that "nvcamerasrc" thats the clue i think, and raspi probably has its own "broadcom" version of it !

https://github.com/jetsonhacks/buildOpenCVTX2/blob/master/Examples/canny...

and:

https://github.com/jetsonhacks/buildOpenCVTX2/blob/master/Examples/gstre...

 

would this be enough info to write a new grabber ? this should be possible in mrl ?

seem like the equivalent to "nvcamerasrc" is "raspivid" on the raspi :

https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspivid.md

kwatters's picture

libnd4j compile on the raspi3

Here's the contents of my pi.cmake file.  (you'll see it's used to point to the gcc / g++ compilers and sets a few other properties like the root file system so it can find all of the includes for c/c++ compilation)

 

ubuntu@bdiqa:/mnt/kwtest$ cat pi.cmake
 
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER /mnt/kwtest/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /mnt/kwtest/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_FIND_ROOT_PATH /mnt/kwtest/rootfs)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)