Configure OpenCV for Android with Visual Studio(NVIDIA Nsight )

asked 2017-01-22 04:35:38 -0500

Dashu gravatar image

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-\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-\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.

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

  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-\sdk\java\src\org\opencv\android\,18): warning : Error: can not find symbol
C:\NVPACK\OpenCV-\sdk\java\src\org\opencv\android\,18): warning :   symbol:   class R
C:\NVPACK\OpenCV-\sdk\java\src\org\opencv\android\,18): warning :   location: package org.opencv
C:\NVPACK\OpenCV-\sdk ...
edit retag flag offensive close merge delete