alnaseh
Posts: 69
Joined: Thu Jun 23, 2016 5:12 am

Segmentation fault with Java and OpenCV 3.3.1

Fri Nov 17, 2017 3:02 am

Hi,

I'm facing issues with installing OpenCV on raspberry:

Versions:
- Latest Raspbian stretch
- OpenCV 3.3.1
- Java: tried multiple versions (openjdk-9, openjdk-8, Oracle jdk-8)

configuration:

Code: Select all

$ cmake -DWITH_QT=OFF \
 -DWITH_GTK=OFF \
 -D CMAKE_BUILD_TYPE=RELEASE \
 -D WITH_OPENCL=OFF \
 -D BUILD_PERF_TESTS=OFF \
 -D BUILD_SHARED_LIBS=OFF \
 -DWITH_FFMPEG=ON \
 -D CMAKE_INSTALL_PREFIX=/usr/local ..
the code compiles fine but it crashes immediately when calling:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

after troubleshooting with OpenCV team, it turns out it will work if ffmpeg is disabled but i need ffmpeg to capture the video.
case:
https://github.com/opencv/opencv/issues/10080

OoenCV people concludes that this is not related to OpenCV

i was thinking it might be related to missing library so i tried to install all libraries i can think of, but no luck. i tried to install ffmpeg from src as well, but the same result. the OpenCV native tests running just fine so the issue is certainly with the java wrapper.

in many cases java will not create crash report. I got the crash report only once and im attaching it here:
hs_err_pid12030.zip
(10.77 KiB) Downloaded 124 times
the report seems to pinpoint the issue with libopenmpt.so.0, i tried to compile ffmpeg from src with --disable-libopenmpt but no luck also.

until now i couldn't manage to get the latest OpenCV works with java on stretch.

any support is appreciated

fruitoftheloom
Posts: 23426
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Segmentation fault with Java and OpenCV 3.3.1

Fri Nov 17, 2017 9:26 am

alnaseh wrote:
Fri Nov 17, 2017 3:02 am
Hi,

I'm facing issues with installing OpenCV on raspberry:

Versions:
- Latest Raspbian stretch
- OpenCV 3.3.1
- Java: tried multiple versions (openjdk-9, openjdk-8, Oracle jdk-8)

Did you follow any Blogs like this one ??

https://www.pyimagesearch.com/2017/09/0 ... pberry-pi/
Rather than negativity think outside the box !
RPi 4B 4GB (SSD Boot) RaspiOS64 ARM64
Asus ChromeBox 3 Celeron is my other computer...

alnaseh
Posts: 69
Joined: Thu Jun 23, 2016 5:12 am

Re: Segmentation fault with Java and OpenCV 3.3.1

Fri Nov 17, 2017 9:32 am

fruitoftheloom wrote:
Fri Nov 17, 2017 9:26 am

Did you follow any Blogs like this one ??

https://www.pyimagesearch.com/2017/09/0 ... pberry-pi/
yes, many of them. most of them is dealing with python examples not java. in addition, the compilation is OK.
i tried even raspbian lite with java-headless but again no luck

Merl1n
Posts: 6
Joined: Sun Jul 03, 2016 5:33 am
Contact: Website

Re: Segmentation fault with Java and OpenCV 3.3.1

Tue Nov 21, 2017 8:27 am

I have the same issue and I'm afraid the issue is in Java.

I have created a small test program:
LD_DEBUG=files java -cp ./jar/core.jar Test

and what I see:
...
/usr/lib/jvm/java-8-oracle/jre/lib/arm/libzip.so: error: symbol lookup error: undefined symbol: ZIP_ReadMappedEntry (fatal)
1119: /usr/lib/jvm/java-8-oracle/jre/lib/arm/libjava.so: error: symbol lookup error: undefined symbol: Java_java_security_AccessController_doPrivileged (fatal)
1119: /usr/lib/jvm/java-8-oracle/jre/lib/arm/libjava.so: error: symbol lookup error: undefined symbol: Java_sun_reflect_Reflection_getCallerClass (fatal)
....


I was able to run using
https://downloads.raspberrypi.org/raspb ... 017-07-05/

squierts
Posts: 2
Joined: Thu Nov 23, 2017 6:47 pm

Re: Segmentation fault with Java and OpenCV 3.3.1

Thu Nov 23, 2017 6:49 pm

I'm having the same problem. BTW it occurs on other Linux (ARM) systems, not just the PI.


petr2
Posts: 14
Joined: Mon Apr 17, 2017 11:05 am

Re: Segmentation fault with Java and OpenCV 3.3.1

Fri Jun 28, 2019 11:57 am

Okay I have been having trouble with this as well (for months) and decided to use opencv (3.3.0) from c++ and JNI to wrap it. Still got the segmentation fault !
Many days later I had learnt to write C++ code and narrowed it down to the loadLibrary(...) command. Finally learnt to use gdb to debug c++ and how to run java from gdb (see http://www2.sys-con.com/itsg/virtualcd/ ... index.html) That very quickly told me that the problem was caused by libopenmpt.so.0 and a quick ddg of "openmpt segmentation fault" told me it was probably an out of memory error.

The solution for me is to run java with the option "-Xss256m"

I hate computers...
P

Return to “Java”