OpenCV-Android-Object-Detection
OpenCV-Android-Object-Detection copied to clipboard
Crashing
FATAL EXCEPTION: Thread-1216 Process: com.example.akshika.opencvtest, PID: 30000 CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/stat.cpp:3749: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool) ] at org.opencv.features2d.DescriptorMatcher.match_1(Native Method) at org.opencv.features2d.DescriptorMatcher.match(DescriptorMatcher.java:206) at com.example.akshika.opencvtest.MainActivity.recognize(MainActivity.java:167) at com.example.akshika.opencvtest.MainActivity.onCameraFrame(MainActivity.java:204) at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391) at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350) at java.lang.Thread.run(Thread.java:841)
Yes i also get same error.
Process: com.example.akshika.opencvtest, PID: 10088 CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/stat.cpp:3749: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool) ] at org.opencv.features2d.DescriptorMatcher.match_1(Native Method) at org.opencv.features2d.DescriptorMatcher.match(DescriptorMatcher.java:206) at com.example.akshika.opencvtest.MainActivity.recognize(MainActivity.java:167) at com.example.akshika.opencvtest.MainActivity.onCameraFrame(MainActivity.java:204) at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391) at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350) at java.lang.Thread.run(Thread.java:818)
you must refer to something you want to detect before the app is run
i solved it open cv error just update all the things like libraries and natives and make sure your studio version support native. Thanks
@mksantoki @irshadsparky Most probably you have no "a.jpeg" in assets folder, so when "initializeOpenCVDependencies()" ends, descriptors1 still null, which causes the NullPointerException when we are trying to match out images
@irshadsparky How does one go about doing this? As far as I can tell all my libraries are up to date and I am supporting Native.....
08-09 14:02:04.864 27829-27929/jcom.example E/cv::error(): OpenCV(3.4.1) Error: Assertion failed (type == src2.type() && src1.cols == src2.cols && (type == 5 || type == 0)) in void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool), file /build/master_pack-android/opencv/modules/core/src/batch_distance.cpp, line 238
08-09 14:02:04.866 27829-27929/jcom.example E/org.opencv.features2d: features2d::match_11() caught cv::Exception: OpenCV(3.4.1) /build/master_pack-android/opencv/modules/core/src/batch_distance.cpp:238: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == 5 || type == 0) in function void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool)
08-09 14:02:04.867 27829-27929/jcom.example E/AndroidRuntime: FATAL EXCEPTION: Thread-4955
Process: jcom.example, PID: 27829
CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.1) /build/master_pack-android/opencv/modules/core/src/batch_distance.cpp:238: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == 5 || type == 0) in function void cv::batchDistance(cv::InputArray, cv::InputArray, cv::OutputArray, int, cv::OutputArray, int, int, cv::InputArray, int, bool)
]
at org.opencv.features2d.DescriptorMatcher.match_1(Native Method)
at org.opencv.features2d.DescriptorMatcher.match(DescriptorMatcher.java:223)
at org.opencv.samples.facedetect.ObjectDetectActivity.recognize(ObjectDetectActivity.java:160)
at org.opencv.samples.facedetect.ObjectDetectActivity.onCameraFrame(ObjectDetectActivity.java:198)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:392)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:373)
at java.lang.Thread.run(Thread.java:818)
Try to run this application, after getting the phone into your hand pointing some object, because while the phone is laying on the table and you want to run the application, the first object is a black or something like this, I believe that way you can fix the error.
Maybe I was wrong, just guessing ;) give it a try.
Just changed line in code MainActivity.java line 177 from
if (img1.type() == aInputFrame.type()) {
to:
if (img1.type() == aInputFrame.type() && !descriptors2.empty()) {
and Object detection app continues to run even if object to detect from camera is black or anything else.