Good morning to everyone.
I am developing an application in Android environment that captures frames from a video stream, in order to process them, and then shows the processed frames on screen. This application, if the device has two cameras, allows the switch between front camera and back camera.
The switching between cameras worked until I created the background processing thread (asynktask). The program works correctly with the introduction and execution of the thread, but if I try to change the camera, it crashes. In the asynktask I do only the following operations: resizing the frame, calculating some points on the resized frame, scaling the points basing on the size of the original frame, showing the original frame on screen with recalculated points printed on it.
If I try to do the switching, the error I get in logcat is:
07-02 11:14:41.649: ERROR/AndroidRuntime(16778): FATAL EXCEPTION: pool-1-thread-3
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/imgwarp.cpp:1723: error: (-215) ssize.area() > 0 in function void cv::resize(cv::InputArray, cv::OutputArray, cv::Size, double, double, int)
]
at org.opencv.imgproc.Imgproc.resize_0(Native Method)
at org.opencv.imgproc.Imgproc.resize(Imgproc.java:8461)
at com.micaela.myapp.MainActivity$ExtractFeaturesTask.scaleImage(MainActivity.java:764)
at com.micaela.myapp.MainActivity$ExtractFeaturesTask$1.handleMessage(MainActivity.java:678)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at com.micaela.myapp.MainActivity$ExtractFeaturesTask.doInBackground(MainActivity.java:736)
at com.micaela.myapp.MainActivity$ExtractFeaturesTask.doInBackground(MainActivity.java:649)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)