Converting DCT on C++ to Android : java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 thrown
I am trying to convert a C++ DCT code to Android. Below is the code that I have tried to convert from C++ to OpenCV on Android. However, I obtain this error:
Java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
I found out that the "outplanes" is 0. Is it possible to set ArrayList size or am I missing something? To be honest, I am not particularly sure this code will work or not. Please advise me on what I should do. Thank you so much!
Mat secondImage = new Mat(); secondImage = image.clone();
List<mat> planes = new ArrayList<mat>();
Core.split(secondImage, planes); List<mat> outplanes = new ArrayList<mat>(planes.size());
Mat trans = new Mat(CvType.CV_32FC1);
Log.d("Planes", Integer.toString(planes.size())); //3 Log.d("Outplanes", Integer.toString(outplanes.size()));for (int k = 0; k < planes.size(); k++) { planes.get(k).convertTo(planes.get(k),CvType.CV_32FC1); Core.dct(planes.get(k), outplanes.get(k)); outplanes.get(k).convertTo(outplanes.get(k),CvType.CV_8UC1); }
Core.merge(outplanes, trans);