Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Configure OpenCV for Android with Visual Studio(NVIDIA Nsight )

I want to develop the Android app using opencv4android SDK with Visual Studio(not C# Android), I can not use Eclipse or Android studio with some reasons.

I have installed VS 2015 professional, I set up the environment use NVIDIA Codeworks for Android version 1R4 (TADP) , it includes JDK SDK NDK ANT Gradle Eclipse CDT opencv4tegra and Nsight Tegra Visual Studio Edition, I use Eclipse to test OpenCV samples(OpenCV-2.4.8.2-Tegra-sdk\samples), all samples can compile and work, so that I assumed that the installation is ok.

image description

I create Android Application under Nsight Tegra, write a simple helloworld(pure java without native code c/c++), the program can compile and work. I import opencv module in .java file, " import org.opencv..* ;" it surely compile with error, error says that it can not find org.opencv.* , Next, I want to include opencv4android SDK(it's a challenge for me), I click Properties of project, Ant Build -> Java -> Java Source Directories, I add opencv java source dir "C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src" to it, it compile with a different error, now it can find the org.opencv folder, error is "Package R not exist", the R is org.opencv.R.

-compile:
      [javac] Compiling 93 source files to C:\Users\linzi\Desktop\kk\Android1\Android1\Tegra-Android\Debug\bin\classes
      [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:5: Error: can not find symbol
      [javac] import org.opencv.R;
      [javac]                  ^
      [javac]   symbol:   class R
      [javac]   location: package org.opencv
      [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:72: error: package R not exist
      [javac]         TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
      [javac]                                                                              ^
      [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:73: error: package R not exist
      [javac]         if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
      [javac]                                     ^
      [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:76: error: package R not exist
      [javac]         mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
      [javac]                                            ^
      [javac] 4 errors

  BUILD FAILED
  C:\NVPACK\android-sdk-windows\tools\ant\build.xml:716: The following error occurred while executing this line:
  C:\NVPACK\android-sdk-windows\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.

  Total time: 3 seconds
  Picked up _JAVA_OPTIONS:  -Xms256m -Xmx1024m
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Tegra-Android\Nvidia.AndroidBuild.targets(253,5): error : No errors were parsed from the Ant log. See the Output window for the build messages.
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning : Error: can not find symbol
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning :   symbol:   class R
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning :   location: package org.opencv
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(72,78): warning : error: package R not exist
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(73,37): warning : error: package R not exist
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(76,44): warning : error: package R not exist
C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(76,44): warning : 4 errors

this link answer says: org.opencv.R and org.opencv.engine.OpenCVEngineInterface are auto generated classes. But I still don't know I to configure...

how to solve this problem?