Ask Your Question

glicanear's profile - activity

2016-07-01 09:09:02 -0600 received badge  Notable Question (source)
2015-12-28 22:01:41 -0600 received badge  Popular Question (source)
2014-05-27 22:46:59 -0600 asked a question How to update android QtActivity.java in Qt for android?

After compiling project I'm encountering errors(W- Warnings, E- errors, D- debug?):

W/IInputConnectionWrapper(15989): showStatusIcon on inactive InputConnection
D/OpenCV::camera(15989): CvCapture_Android::CvCapture_Android(0)
D/OpenCV::camera(15989): Library name: libopencv_java.so
D/OpenCV::camera(15989): Library base address: 0x5275b000
D/OpenCV::camera(15989): Libraries folder found: /mnt/asec/org.qtproject.example.ARExample-1/lib/
D/OpenCV::camera(15989): CameraWrapperConnector::connectToLib: folderPath=/mnt/asec/org.qtproject.example.ARExample-1/lib/
E/OpenCV::camera(15989): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
E/OpenCV::camera(15989): Native_camera returned opening error: 4
E/cv::error()(15989): OpenCV Error: Assertion failed (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/color.cpp, line 3648
F/libc    (15989): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 16026 (QSGRenderThread)

After reading through all the similar cases, it seems, that it comes down to modifying QtActivity.java to something like this:

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i(TAG, "OpenCV loaded successfully");
                    System.loadLibrary("native_activity");
                    Intent intent = new Intent(CvNativeActivity.this, android.app.NativeActivity.class);
                    CvNativeActivity.this.startActivity(intent);
                    CvNativeActivity.this.finish();
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };
    @Override
    protected void onResume()
    {
        super.onResume();
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback);
        QtApplication.invokeDelegate();        
    }

Fully modified QtActivity.java is included under android_copy folder. I just copied everything from OpenCv example.

The problem there is that android project regenerates all java code and erases any changes there under folder build-ARExample-Android_for_armeabi_v7a_GCC_4_8_Qt_5_3_0-Debug I recall that at some earlier Qt versions these java files were generated under project folder. Now, how to deal with this? Anyone has any clue? I would really appreciate it.

I've looked into these, but apparently it seems, that java source is generated into project. I have copied mentioned libraries under Qt/lib folder: http://answers.opencv.org/question/25892/qt-android-opencv-is-possible/ http://stackoverflow.com/questions/12842439/camera-not-open-static-initialization-on-opencv-android

Included project source.

PS examples where I'm using OpenCV without camera are working. Also QtQuick camera is working. The problem is with setting up OpenCV camera.

2014-05-27 01:40:12 -0600 asked a question Qt android collect2.exe:-1: error: error: ld returned 1 exit status

Source of project - works on desktop version

C:/Dev/OpenCV-2.4.9-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(parallel.cpp.o):parallel.cpp:function tbb::interface6::internal::start_for<tbb::blocked_range<int>, (anonymous namespace)::ProxyLoopBody, tbb::auto_partitioner const>::~start_for(): error: undefined reference to 'vtable for tbb::task' C:/Dev/OpenCV-2.4.9-android-sdk/sdk/native/libs/armeabi-v7a/libopencv_core.a(parallel.cpp.o):parallel.cpp:function tbb::interface6::internal::flag_task::~flag_task(): error: undefined reference to 'vtable for tbb::task'

...

hundred or so more

...

Is it linking or something extra needed done? No use of other android related questions - some of them are without answers.

2014-05-25 01:09:06 -0600 commented question after reboot undefined reference to `cv::imread(std::string const&, int)'

I ended up with just adding these libraries:

win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_core249.dll.a win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_highgui249.dll.a win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_imgproc249.dll.a win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_features2d249.dll.a win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_calib3d249.dll.a

2014-05-24 23:55:52 -0600 commented question after reboot undefined reference to `cv::imread(std::string const&, int)'

For android you have to link against opencv android sdk My configuration for LIBS was: c:\Dev\OpenCV-2.4.9-android-sdk\sdk\native\libs\armeabi-v7a*.* and include was c:\Dev\OpenCV-2.4.9-android-sdk\sdk\native\jni\include\

Actually I have the same problem there - it compiled and installed, but now can't to do again. I mean - it installed with some errors, but now I can' t even get past that - it doesn't compile and give same error. So, same problem.

Well, under bin folder there are .dll files... anyway - there are conflicting and outdated tutorials out there and tried both versions. It doesn't compile right now at all, but it compiled in first place with bin - I think that I stick to bin folder, because before clean system reinstallation I switched to lib and it didn' t worked.

2014-05-24 23:29:28 -0600 received badge  Editor (source)
2014-05-24 23:28:03 -0600 asked a question after reboot undefined reference to `cv::imread(std::string const&, int)'

I have Qt 5.3.0 for Android (Windows 32-bit, 813 MB) on Windows x64

Compiled opencv with cmake - both release and debug versions

PATH

c:\Dev\opencv\debug\install\x64\mingw\bin\;
c:\Dev\opencv\release\install\x64\mingw\bin\;
C:\Qt\Qt5.3.0\5.3\mingw482_32\bin;
C:\Qt\Qt5.3.0\Tools\mingw482_32\bin\;
C:\Dev\CMake\bin;

.pro project file has only these lines added:

INCLUDEPATH += C:\\Dev\\opencv\\release\\install\\include
LIBS += -LC:\\Dev\\opencv\\release\\install\\x64\\mingw\\bin\\*.*

main.cpp simple test example

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
        // read an image
        cv::Mat image= cv::imread("img.jpg");
        // create image window named "My Image"
        cv::namedWindow("My Image");
        // show the image on window
        cv::imshow("My Image", image);
        // wait key for 5000 ms
        cv::waitKey(5000);
        return 1;
}

This example was running. Now when I try to do the same after reboot - getting these results: C:\workspace\untitled7\main.cpp:9: error: undefined reference to `cv::imread(std::string const&, int)'

No clue at all what should be done. Apparently it doesn't link, but why it did in first run? Exactly the same result I'm getting in linux environment. Why?

...

SOLUTION:

I ended up with just adding libraries in this manner(different project, but tested and it worked for this example):

win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_core249.dll.a 
win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_highgui249.dll.a 
win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_imgproc249.dll.a 
win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_features2d249.dll.a 
win32:LIBS += c:\Dev\opencv\release\install\x64\mingw\lib\libopencv_calib3d249.dll.a

No idea why it was working with initial settings. It was fresh System with new Qt install and compiled opencv. Since there has been many similar posts and none of them have explained, that libraries can be linked to a .dll.a files, let's hope that it will help others, who will have similar Qt setup problems.

Also I'm curious why opencv is not shipping with prebuilt Qt libraries - it is not rare C/C++ tool and probably by now as widespread as Visual Studio. I was using Visual Studio for years and moved(run away) to Qt, because it offered the same - GUI without the need to delve into configuration of command lines and also possibility to use it on multiple operational systems. Visual Studio is just bound with one - MS and it is conflicting idea to call opencv open if it is so bound to MS.

I think, I've found answer. It was really lib directory, not bin.

PS Haha, I can' t close my own question or just don't know how to set it as answered.