New for Android and OpenCV. It was an attempt to implement the code from the new book "Mastering OpenCV with practical computer vision projects." The application basically transfers cartoon images to the camera preview using OpenCV. You can touch the screen to save a cartoon image.
I made a small modification (see below) in the CartoonifierApp.java file so that I could statically load the cartoon library using the OpenCV Manager application (the source code threw UnsatisfiedLinkError).
The problem I am facing is that when I download the application to my Galaxy Nexus (Android 4.1.1), I get a blank black screen. My LogCat says:
I think this is a memory problem. I know that cpp code works because it works fine on my computer itself - although rendering is slow on a relatively new laptop (Asus U46E).
what happens, the camera is working fine, and I can save cartoon images by touching the screen. Please note that this is not quite the desired result, since I want to constantly caronize the image when previewing the camera. The camera only works because I am not writing to the surface (at least this is my understanding). The answer on the previous site has some workaround, but I have no idea what it is talking about.
BTW I have tried all OpenCV4Android sample applications and they work great. I also use OpenCV version 2.4.3. The goal of the API level is 15.
12-22 15: 33: 07.966: I / CartoonifierApp (5999): created a new class com.Cartoonifier.CartoonifierApp 12-22 15: 33: 07.966: I / CartoonifierApp (5999): called onCreate 12-22 15: 33: 07.966 : I / CartoonifierApp (5999): attempt to load the OpenCV library 12-22 15: 33: 07.982: I / Cartoonifier :: SurfaceView (5999): created a new class com.Cartoonifier.CartoonifierView 12-22 15: 33: 07.990: I / CartoonifierApp (5999): onResume 12-22 15: 33: 07.990: I / Cartoonifier :: SurfaceView (5999): openCamera 12-22 15: 33: 07.990: I / Cartoonifier :: SurfaceView (5999): releaseCamera 12-22 15 : 33: 08.099: D / OpenCVManager / Helper (5999): service connection created 12-22 15: 33: 08.099: D / OpenCVManager / Helper (5999): attempt to get the library path 12-22 15: 33: 08.138: D / OpenCVManager / Helper (5999): Attempting to get the List of Libraries 12-22 15: 33: 08.16 9: D / OpenCVManager / Helper (5999): Library list: "12-22 15: 33: 08.169: D / OpenCVManager / Helper (5999): first attempt to load libraries 12-22 15: 33: 08.169: D / OpenCVManager / Helper (5999): Attempt to initialize the OpenCV libraries 12-22 15: 33: 08.169: D / OpenCVManager / Helper (5999): attempt to load the library /data/data/org.opencv.engine/lib/libopencv_java.so 12-22 15 : 33: 08.169:
D / dalvikvm (5999): attempt to load lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15: 33: 08.193: D / dalvikvm (5999): Added shared library lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15: 33: 08.193: D / OpenCVManager / Helper (5999): OpenCV libs init was fine!
12-22 15: 33: 08.193: D / OpenCVManager / Helper (5999): first attempt to load libs in order 12-22 15: 33: 08.193: D / OpenCVManager / Helper (5999): Init with status 0 12-22 15 : 33: 08.193: D / OpenCVManager / Helper (5999): Unbind from the service 12-22 15: 33: 08.200: D / OpenCVManager / Helper (5999): call using the callback 12-22 15: 33: 08.200: I / CartoonifierApp (5999): OpenCV loaded successfully
12-22 15: 33: 08.200: D / dalvikvm (5999): attempt to load lib /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40 12-22
15: 33: 08.200: D / dalvikvm (5999): added the general library /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40 12-22
15: 33: 08.200: D / dalvikvm (5999): none JNI_OnLoad found in /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40, skipping init 12-22 15: 33: 08.200: D / OpenCVManager / Helper ( 5999): Service connection 12-22 created 15: 33: 08.200: D / OpenCVManager / Helper (5999): attempt to get library path 12-22
15: 33: 08.232: D / OpenCVManager / Helper (5999): attempt to get a list of libraries 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): List of libraries: ""
12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): first attempt load libs 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): Try
init OpenCV libs 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): Attempting to load the library /data/data/org.opencv.engine/lib/libopencv_java.so 12-22 15: 33: 08.271: D / dalvikvm (5999): attempt to load lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15: 33: 08.271: D / dalvikvm (5999): the shared library '/data/data/org.opencv.engine/lib/libopencv_java.so' is already loaded in the same CL 0x41936a40 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): OpenCV libs init was fine! 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): first attempt to load libs in order
12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): Initialization completed with status 0 12-22 15: 33: 08.271: D / OpenCVManager / Helper (5999): unbind from service 12-22 15: 33 : 08.271: D / OpenCVManager / Helper (5999): call using a callback 12-22 15: 33: 08.271: I / CartoonifierApp (5999): OpenCV loaded successfully 12-22 15: 33: 08.279: D / dalvikvm (5999 ): Attempting to load lib / data / data / com.Cartoonifier / lib / libcartoonifier.so 0x41936a40 12-22 15: 33: 08.279: D / dalvikvm (5999): general lib '/data/data/com.Cartoonifier/lib/ libcartoonifier.so 'is already loaded in the same CL 0x41936a40 12-22 15: 33: 08.302: I / Cartoonifier :: SurfaceView (5999): surfaceCreated 12-22 15: 33: 08.302: I / Cartoonifier :: SurfaceView (5999): surfaceChanged (). Window size: 1196x670 12-22 15: 33: 08.302: I / Cartoonifier :: SurfaceView (5999): setupCamera (1196x670) 12-22 15: 33: 08.302: I / Cartoonifier :: SurfaceView (5999): starting the processing thread 12 -22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 1920x1080 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 1280x720 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 960x720 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 800x480 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 720x576 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 720x480 12-22 15: 33: 08.310: I / Cartoonifier: : SurfaceView (5999): found p camera resolution 768x576 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 640x480 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 320x240 12 -22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 352x288 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 240x160 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 176x144 12-22 15: 33: 08.310: I / Cartoonifier :: SurfaceView (5999): found camera resolution 128x96 12-22 15: 33: 08.318: I / Cartoonifier :: SurfaceView (5999): selected camera preview size: 1280x720 12-22 15: 33: 08.333: D / dalvikvm (5999): GC_FOR_ALLOC released 131K, 2% free 10807K / 11011K, paused 13 ms, only 13 ms
12-22 15: 33: 08.333: I / dalvikvm-heap (5999): grow a bunch (fragment) to 11.902MB to allocate 1382416 bytes
12-22 15: 33: 08.357: D / dalvikvm (5999): GC_CONCURRENT released 1K, 3% free 12156K / 12423K, suspended 12 ms + 1 ms, only 24 ms
12-22 15: 33: 08.357: D / dalvikvm (5999): WAIT_FOR_CONCURRENT_GC blocked 11 ms
12-22 15: 33: 08.365: D / dalvikvm (5999): GC_FOR_ALLOC released 0K, 3% free 12156K / 12423K, suspended 9 ms, only 9 ms
12-22 15: 33: 08.372: I / dalvikvm-heap (5999): Increase the heap (fragment) to 13.219 MB to allocate 1382416 bytes
12-22 15: 33: 08.388: D / dalvikvm (5999): GC_CONCURRENT released 0K, 3% free 13506K / 13831K, suspended 11 ms + 1 ms, only 21 ms
12-22 15: 33: 08.388: D / dalvikvm (5999): WAIT_FOR_CONCURRENT_GC blocked 7 ms
12-22 15: 33: 08.404: D / dalvikvm (5999): GC_FOR_ALLOC released <1K, 3% free 13506K / 13831K, suspended 9 ms, only 10 ms
12-22 15: 33: 08.411: I / dalvikvm-heap (5999): grow a heap (fragment) to 16.735MB for a distribution of 3686416 bytes
12-22 15: 33: 08.427: D / dalvikvm (5999): GC_CONCURRENT released <1K, 3% free 17106K / 17479K, suspended 12 ms + 1 ms, only 22 ms
12-22 15: 33: 08.427: D / dalvikvm (5999): WAIT_FOR_CONCURRENT_GC blocked 10 ms
12-22 15: 33: 08.443: D / dalvikvm (5999): GC_FOR_ALLOC released <1K, 3% free 17106K / 17479K, suspended for 10 ms, only 10 ms
12-22 15: 33: 08.450: I / dalvikvm-heap (5999): Increase the heap (fragment) to 20.250 MB to accommodate 3686416 bytes
12-22 15: 33: 08.466: D / dalvikvm (5999): GC_CONCURRENT released 0K, 2% free 20706K / 21127K, suspended 12 ms + 2 ms, only 22 ms
12-22 15: 33: 08.466: D / dalvikvm (5999): WAIT_FOR_CONCURRENT_GC blocked 5 ms
12-22 15: 33: 08.466: I / Cartoonifier :: SurfaceView (5999): preview
12-22 15: 33: 08.497: E / BufferQueue (5999): [unnamed-5999-0] setBufferCount: SurfaceTexture has been abandoned!
12-22 15: 33: 08.505: E / Cartoonifier :: SurfaceView (5999): mCamera.startPreview () failed