2018-04-17 02:58:34 -0500 received badge ● Notable Question (source) 2016-11-03 15:49:51 -0500 received badge ● Popular Question (source) 2016-02-23 03:55:33 -0500 asked a question Rotation angle of a given affine transformation matrix I'm developing an image stitching algorithm and I'm using affine transformations. One part of the algorithm is to detect whether an affine transform is garbage. To do this, I want to calculate the rotation angle that each affine transform will produce, to discard it if it's too high. So, how can I determine the rotation angle of a given affine transformation matrix? 2016-02-23 03:13:23 -0500 asked a question Correct the image's borders illumination I'm developing an algorithm to stich images of vines. These images were taken at night with artificial illumination, because of this, the image's center is very well illuminated but their borders are almost black. To correct this I have tried the following: 1 - Convert the image to LAB. 2 - Get the channel L. 3 - Increase that channel's pixel values, following this rule: The incrementation value is the highest in the border's pixels, and it decreases as it reaches the image's center. For example, for an image's line:  Left border Center Right border Position of the pixel 0 1 2 3 4 5 6 7 8 Incrementation value 1 0.8 0.5 0.2 0.0 0.2 0.5 0.8 0.1  I think this method is not very good because it's "creating" information. How can I do this in a better way? 2015-03-04 05:19:02 -0500 asked a question Android: Draw contours arround points detected by MSER I'm trying to draw countours to indicate the points detected by MSER in a bitmap. I can detect the points with FeatureDectector.detect() but it returns them as MatOfKeyPoint. Now I want to dray the contour of these points using Imgproc.drawContours(), but this function receives the points as a List. I have tried to convert MatOfKeyPoint to List, then use drawContours(). This is what I have tested: private void processBitmap(Bitmap bmp){ Mat mat = new Mat(bmp.getWidth(), bmp.getHeight(), CvType.CV_16S, new Scalar(4)); Utils.bitmapToMat(bmp, mat); Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY, 4); FeatureDetector fd = FeatureDetector.create(FeatureDetector.MSER); MatOfKeyPoint mokp = new MatOfKeyPoint(); fd.detect(mat, mokp); KeyPoint[] kps = mokp.toArray(); List mops = new ArrayList(kps.length); for(int i = 0; i < kps.length; i++) mops.set(i, new MatOfPoint(kps[i].pt)); Scalar s = new Scalar(0); Imgproc.drawContours(mat, mops, 1, s); Utils.matToBitmap(mat, bmp); }  In this case, there is no exceptions, but drawContours() does nothing. I have tested this too: import org.opencv.core.Point; [...] private void processBitmap(Bitmap bmp){ Mat mat = new Mat(bmp.getWidth(), bmp.getHeight(), CvType.CV_16S, new Scalar(4)); Utils.bitmapToMat(bmp, mat); Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGB2GRAY, 4); FeatureDetector fd = FeatureDetector.create(FeatureDetector.MSER); MatOfKeyPoint mokp = new MatOfKeyPoint(); fd.detect(mat, mokp); KeyPoint[] kps = mokp.toArray(); Scalar s = new Scalar(0); //color black Point[] points = new Point[kps.length]; // for(int i = 0; i < points.length; i++) points[i] = kps[i].pt; MatOfPoint mop = new MatOfPoint(); mop.fromArray(points); List lmop = new ArrayList(); lmop.add(mop); Imgproc.drawContours(mat, lmop, 5, s); Utils.matToBitmap(mat, bmp); }  In this case there is an exception: OpenCV Error: Assertion failed (0 <= contourIdx && contourIdx < (int)last I have read the documentation of OpenCV for java here: http://docs.opencv.org/java/ But the example is only with findContours(). I have read that MatOfPoint is only a way used by OpenCV to avoid to copy points between native part and java part, so that, I assume that the List must have only 1 component due to MatOfPoint contains all points I need, is this correct? How can I convert the MatOfKeyPoint in List properly? 2015-03-03 16:21:43 -0500 answered a question Problem adding function to OpenCV4Android: UnsatisfiedLinkError I have solved the problem. As I thought, the problem was that, despite I compiled well the modified OpenCV4Android library, I was loading the library dinamically, these changes were not applied, then I was using the library that comes with OpenCV manager (for android). The solution is make the load to be static, this is, copy ${OpenCV4Android_folder}\lib\ to ${proyect_folder}\libs. Then make the library loading statically. Here an example: private BaseLoaderCallback mOpenCVCallBack; [...] mOpenCVCallBack = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: //Hacer cosas si se ha cargado bien? break; default: super.onManagerConnected(status); break; } } }; if (!OpenCVLoader.initDebug()){ //Handle error }else{ mOpenCVCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS); }  NOTE: This solutions is only valid for proyects that not use JNI, otherwise you must follow this tutorial: http://docs.opencv.org/trunk/doc/tuto... 2015-02-27 06:22:40 -0500 asked a question Problem adding function to OpenCV4Android: UnsatisfiedLinkError I have to add a function to OpenCV4Android library (it will be a copy of an existing function, but modifed). For now, I'm trying to add a very simple function for testing, its only objective is to return an integer value. I have compiled the library with no errors, but when I try to call this function from java, I have an error: UnsatisfiedLinkError. I don't know what I'm doing wrong. I'm working on windows. What I have tested: In file ${opencv_folder}\modules\java\generator\src\cpp\utils.cpp Add at the end of file the following: extern "C"{ [...] /* * Class: org_opencv_android_Utils * Method: int test() */ JNIEXPORT jint JNICALL Java_org_opencv_android_Utils_test (JNIEnv * env, jclass); JNIEXPORT jint JNICALL Java_org_opencv_android_Utils_test (JNIEnv * env, jclass) { return (jint) 24; } } //extern "C"  In file${opencv_folder}\modules\java\generator\src\java\android+Utils.java add at the end of file the following: public static int test22(){ return test(); //Here the UnsatisfiedLinkError } private static native int test();  Finally, in my java project: import org.opencv.android.Utils; [...] void test_opencv4android(){ int n = Utils.test22(); }  I have no errors in eclipse, it detects the function in the module. What I do to compile: cd ${opencv_folder}\platforms\build_android_arm cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\android\android.toolchain.cmake ..\.. make  What's my error? EDIT: I have tested anotherthing, generate jni signatura via javah command, this is what I've test: Open command line in ${opencv_folder}\platforms\build_android_arm\bin\classes, with android_build_arm the folder where I'm copilingo OpenCV4Android. Then executing the following command: javah -jni -classpath "${opencv_folder}\platforms\build_android_arm\bin\classes" org.opencv.android.Utils But I have this error: Error: Class android.content.Context could not be found. I think it's because android.content.Context is an android library that is not in the OpenCV4Android library. How can I say to javah that have to look for that class in other folder? EDIT2: I have used ndk's objdump to see the real name of the function in the .so file. This is what I've found: [...] 000986d0 : 986d0: 2018 movs r0, #24 986d2: 4770 bx lr [...]  It's the expected name. The command that I have exectued: First I have gone to ${ndk_folder}\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\arm-linux-androideabi\bin There, I have exectued objdump -d \${opencv_folder}\platforms\build_android_arm\lib\armeabi-v7a\libopencv_java.so > pr.txt And then open "pr.txt" and search for Java_org_opencv_android_test. EDIT 3: I think the problem may be that the .so file libopencv_java.so, which is called by java, that I'm seeing in my pc and I have changed and compiled, is not in my android device. I think this may be due to you have to download OpenCV manager in android to execute any application that uses OpenCV, an this manager has its own .so files. Then, how can I replace libopencv_java.so on my device with the library that I have in my computer? 2015-02-27 03:24:49 -0500 commented question Modify OpenCV4Android source code There is a function in mser module that returns values that I no need, I need to add a copy of this function without returning this not necessary information. I have to do it because if this function returns me, for example, (3, 5, 7), then I don't know which numbers are that I need, and which not. And yes, of course I only need to add some function that will be a modified copy of another, there is no problem with that. 2015-02-27 03:12:14 -0500 commented question Modify OpenCV4Android source code Ok, it means that I will have to wait for fewminutes in each compilation. When I start to modify the real function I have to modify, how can I make test with rapid compilations? Should I extract a little part of opencv to modify and test, and the re-add to library? 2015-02-27 03:03:46 -0500 received badge ● Editor (source) 2015-02-27 03:03:42 -0500 asked a question Modify OpenCV4Android source code I have to modify a functiont of OpenCVAandroid and re-build it, but for now, I want to add a new function that does something, for example return some value or print "hello world". This is only for testing. I'm working on windows. I have try to compile a single OpenCV module (core). What I have done is to go to core folder location and run "cmake .", but I have an error: CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.2) should be added at the top of the file. [...] -- Configuring incomplete, errors occurred! See also "E:/Mis documentos/git_repos/opencv_android/opencv-master/modules/core/ CMakeFiles/CMakeOutput.log".  Here my questions: 1 - Is there any way to compile only a part (module) of OpenCV instead of to built all library in each compilation? 2 - If the above is "yes", what are the steps I have to follow? 3 - Finally, the code I have to modify will be used from java. It means that, apart of modify c++ pure code, I have to modify the "jni part", and modify the proper .java file, is correct?