Closed kigkrazy closed 5 years ago
1-07 21:10:08.162 20176-20176/com.reizx.jcv W/linker: libopencv_core.so: unused DT entry: type 0x6ffffffe arg 0x22184 libopencv_core.so: unused DT entry: type 0x6fffffff arg 0x3 11-07 21:10:08.175 20176-20176/com.reizx.jcv W/linker: libopencv_imgproc.so: unused DT entry: type 0x6ffffffe arg 0xc624 libopencv_imgproc.so: unused DT entry: type 0x6fffffff arg 0x2 11-07 21:10:08.201 20176-20176/com.reizx.jcv W/linker: libjniopencv_core.so: unused DT entry: type 0xf arg 0x8d6d1 libjniopencv_core.so: unused DT entry: type 0x6ffffffe arg 0xb5ad8 libjniopencv_core.so: unused DT entry: type 0x6fffffff arg 0x3 11-07 21:10:08.415 20176-20176/com.reizx.jcv W/linker: libjniopencv_imgproc.so: unused DT entry: type 0xf arg 0x43a8c libjniopencv_imgproc.so: unused DT entry: type 0x6ffffffe arg 0x4f3dc libjniopencv_imgproc.so: unused DT entry: type 0x6fffffff arg 0x3 11-07 21:10:08.459 20176-20176/com.reizx.jcv W/linker: libopencv_imgcodecs.so: unused DT entry: type 0x6ffffffe arg 0x3c34 libopencv_imgcodecs.so: unused DT entry: type 0x6fffffff arg 0x2 11-07 21:10:08.474 20176-20176/com.reizx.jcv W/linker: libjniopencv_imgcodecs.so: unused DT entry: type 0xf arg 0x5c36 libjniopencv_imgcodecs.so: unused DT entry: type 0x6ffffffe arg 0x8004 libjniopencv_imgcodecs.so: unused DT entry: type 0x6fffffff arg 0x2 11-07 21:10:08.607 20176-20176/com.reizx.jcv E/cv::error(): OpenCV(3.4.3) Error: Assertion failed (!_src.empty()) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /home/travis/build/javacpp-presets/opencv/cppbuild/android-arm/opencv-3.4.3/modules/imgproc/src/color.cpp, line 181 11-07 21:10:08.607 20176-20176/com.reizx.jcv D/AndroidRuntime: Shutting down VM --------- beginning of crash 11-07 21:10:08.608 20176-20176/com.reizx.jcv E/AndroidRuntime: FATAL EXCEPTION: main Process: com.reizx.jcv, PID: 20176 java.lang.RuntimeException: OpenCV(3.4.3) /home/travis/build/javacpp-presets/opencv/cppbuild/android-arm/opencv-3.4.3/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int)' at org.bytedeco.javacpp.opencv_imgproc.cvtColor(Native Method) at com.reizx.jcv.component.cv.ImageRecognitionUtil.match(ImageRecognitionUtil.java:47) at com.reizx.jcv.component.cv.ImageRecognitionUtil.match(ImageRecognitionUtil.java:32) at com.reizx.jcv.view.fragment.HomeFragment.imageRecognition(HomeFragment.java:70) at com.reizx.jcv.view.fragment.HomeFragment_ViewBinding$5.doClick(HomeFragment_ViewBinding.java:73) at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22) at android.view.View.performClick(View.java:4789) at android.view.View$PerformClick.run(View.java:19881) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5294) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107) --------- beginning of system
public static MatchResult match(String source, String target, double precision) { //read in image default colors opencv_core.Mat sourceColor = imread(source); opencv_core.Mat sourceGrey = new opencv_core.Mat(sourceColor.size(), CV_8UC1); cvtColor(sourceColor, sourceGrey, COLOR_BGR2GRAY);//crash //load in template in grey opencv_core.Mat template = imread(target, CV_LOAD_IMAGE_GRAYSCALE);//int = 0 //Size for the result image opencv_core.Size size = new opencv_core.Size(sourceGrey.cols() - template.cols() + 1, sourceGrey.rows() - template.rows() + 1); opencv_core.Mat result = new opencv_core.Mat(size, CV_32FC1); matchTemplate(sourceGrey, template, result, TM_CCORR_NORMED); DoublePointer minVal = new DoublePointer(); DoublePointer maxVal = new DoublePointer(2); opencv_core.Point min = new opencv_core.Point(); opencv_core.Point max = new opencv_core.Point(); minMaxLoc(result, minVal, maxVal, min, max, null);//寻找最佳匹配 if (maxVal.get(0) >= precision) { MatchResult matchResult = new MatchResult(); matchResult.setMatch(true); matchResult.setX(max.x()); matchResult.setY(max.y()); matchResult.setWidth(template.cols()); matchResult.setHeight(template.rows()); matchResult.setMiddleX(max.x() + (template.cols() / 2)); matchResult.setMiddleX(max.y() + (template.rows() / 2)); } return new MatchResult(); } @Data public static class MatchResult { private boolean isMatch = false;//是否匹配 private int x = 0;//X坐标 private int y = 0;//Y坐标 private int middleX = 0;//图像中间中心点X坐标 private int middleY = 0;//图像中间中心点Y坐标 private int width = 0;//宽 private int height = 0;//高 }
//JAVACV ---- 图像识别相关 api group: 'org.bytedeco', name: 'javacv', version: '1.4.3' api group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3', classifier: 'android-arm' api group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.3-1.4.3', classifier: 'android-x86' api group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.0.2-1.4.3', classifier: 'android-arm' api group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '4.0.2-1.4.3', classifier: 'android-x86'
You'll need to provide a non-empty image to cvtColor(). My guess is the image file is missing or you don't have permission to read it.
cvtColor()
I'm sorry. this problem is caused by Andoird-permission.
environment
crash info
code
dependencies