I have been working with the OpenCV library (version 3.30) with Android, and occasionally there has been a crash when trying to retrieve the color information from a HSV image Mat. I've copied the logcat log below:
/data/app/com.example.administrator.grapeyield-2/lib/arm64/libopencv_java3.so (Java_org_opencv_core_Mat_nGet+2904)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #01 pc 0000000000aa1220 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (double[] org.opencv.core.Mat.nGet(long, int, int)+148)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #02 pc 0000000000aaa544 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (double[] org.opencv.core.Mat.get(int, int)+88)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #03 pc 000000000094565c /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (java.util.List com.example.administrator.grapeyield.utilities.CSVContentFormatter.getHueListOfBerry(org.opencv.core.Mat, org.opencv.core.Mat, int, int)+1232)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #04 pc 0000000000917888 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (void com.example.administrator.grapeyield.activities.White_wine_analysis_Activity.houghcircle_fiveranges(android.graphics.Bitmap)+45276)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #05 pc 0000000000926528 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (void com.example.administrator.grapeyield.activities.White_wine_analysis_Activity.volumedistPressed()+412)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #06 pc 00000000008fb118 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (void com.example.administrator.grapeyield.activities.White_wine_analysis_Activity$volumeDistTask.onPostExecute(java.lang.Void)+76)
03-08 09:44:04.359 3165-3165/? A/DEBUG: #07 pc 00000000008fb068 /data/app/com.example.administrator.grapeyield-2/oat/arm64/base.odex (offset 0x62f000) (void com.example.administrator.grapeyield.activities.White_wine_analysis_Activity$volumeDistTask.onPostExecute(java.lang.Object)+108)
My understanding of the log is that the error is occurring in the "getHueListOfBerry" method, which is below:
public static List getHueListOfBerry(Mat circles, Mat oriImage, int row, int col){
List hueList = new ArrayList();
try {
Mat hsvImage = new Mat();
Imgproc.cvtColor(oriImage, hsvImage, Imgproc.COLOR_BGR2HSV);
int radius = MatUtils.getRadius(circles, row, col);
Point point = MatUtils.getPoint(circles, row, col);
int jStart = (int) (point.x - radius);
int kStart = (int) (point.y - radius);
int jEnd = (int) (point.x + radius);
int kEnd = (int) (point.y + radius);
if (jStart < 0) {
kStart = 0;
}
if (kStart < 0) {
jStart = 0;
}
if (jEnd > oriImage.rows()) {
jEnd = oriImage.rows() - 1;
}
if (kEnd > oriImage.cols()) {
kEnd = oriImage.cols() - 1;
}
for (int j = jStart; j < jEnd; j++) {
for (int k = kStart; k < kEnd; k++) {
if (hsvImage.get(j, k) != null) {
double pixel_h = oriImage.get(j, k)[0];
double pixel_s = oriImage.get(j, k)[1];
double pixel_v = oriImage.get(j, k)[2];
if ((pixel_h != 0) || (pixel_s != 0) || pixel_v != 0) {
if (ColourUtils.isPointInCircle(point.x, point.y, radius, j, k)) {
if ((pixel_h != 0)) {
int pixIndex = (int) pixel_h;
hueList.add(pixIndex);
}
}
}
}
}
}
} catch(Exception e){
Log.e("errorCSVhuelist", e.toString());
}
return hueList;
}
For the life of me I haven't been able to find out what's been going on with this error, it only happens on rare occasions. Any ideas about what's going on here?
↧