Ask Your Question

supersmash's profile - activity

2015-06-09 04:41:08 -0600 asked a question VideoCapture.open not working on .so library for unity-android application using opencv

Hi everyone,

I'm new in the community, hope my question will find an answer here !


I'm trying to build a .so library for an android application made with Unity.

Unity loads the library, which contains openCV functions.

I'm working on Visual Studio 2013, using Nvidia GameWorks to build a Dynamic Library For Android Application with OpenCV-2.4.11-android-sdk


The build seems to work, except one detail : I'm unable to find any camera on the android device... I tryed on a Nexus 5 and a Kurio7s tablet.

Here is the code :

#ifdef TEST_TRACKING_DLL_EXPORTS
#define TEST_TRACKING_DLL_API __declspec(dllexport) 
#else
#define TEST_TRACKING_DLL_API
#endif

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

TEST_TRACKING_DLL_API int InitCameraCapture(int channel)
    {
        cv::VideoCapture* camera_capture = new cv::VideoCapture();

        camera_capture->open(CV_CAP_ANY);

        if (!camera_capture->isOpened())
        {
            return -1;
        }


        return 1;
    }

this code always returns -1...

I tried all the possible values in VideoCapture::open(). from 0 to 1000 ! :p

Note1: When I'm building this code as a Win32 DLL, it is working smoothly in the Unity Editor

Note2: Unity can access the android camera with his own functions without erros.


What is wrong with my method ??

Thanks ! :)

2015-06-09 03:49:19 -0600 received badge  Supporter (source)
2015-06-09 03:49:17 -0600 received badge  Critic (source)