Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 1117

dnn::net forward in native C++ Android Studio

$
0
0
Hallo, I want entwickelt native c++ App in Android studio but I come cross undefined reference to 'cv::dnn.Net::forward(out, layerNames)". I need help how can I use net.forward(out, layerNames) in native c++. thanks hier ist my Code #include #include #include #include #include using namespace std; using namespace cv; using namespace cv::dnn; extern "C" JNIEXPORT jstring JNICALL Java_com_example_mats86_myapplication_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; float confThreshold = 0.5; float nmsThreshold = 0.4; int newW = 320; int newH = 320; String model = "/storage/emulated/0/DCIM/ImageProcessing/tessdata/frozen_east_text_detection.pb"; string imPath = "/storage/emulated/0/DCIM/ImageProcessing/test.jpg"; Mat im = imread(imPath, IMREAD_COLOR); Mat orig; im.copyTo(im); int origH = im.rows; int origW = im.cols; int rW = (int) (origW / float(newW)); int rH = (int) (origH / float(newH)); resize(im, im, Size(newW, newH)); int H = im.rows; int W = im.cols; vector outs; vector layerNames(2); layerNames[0] = "feature_fusion/Conv_7/Sigmoid"; layerNames[1] = "feature_fusion/concat_3"; Net net = readNet(model); // construct a blob from the image and then perform a forward pass of // the model to obtain the two output layer sets Mat frame, blob; blobFromImage(frame, blob, 1.0, Size(newW, newH), Scalar(123.68, 116.78, 103.94), true, false); net.setInput(blob); net.forward(outs, layerNames); return env->NewStringUTF(hello.c_str()); } error undefined reference to `cv::dnn::experimental_dnn_34_v7::Net::forward(cv::_OutputArray const&, std::__ndk1::vector> const&)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. hier is my Cmakelist cmake_minimum_required(VERSION 3.4.1) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. # Gradle automatically packages shared libraries with your APK. set(CMAKE_VERBOSE_MAKEFILE on) set(libs "${CMAKE_SOURCE_DIR}/src/main/jniLibs") include_directories(/Users/mats86/androidTools/opencv-3.4.3-android-sdk/sdk/native/jni/include) add_library(libopencv_java3 SHARED IMPORTED) set_target_properties(libopencv_java3 PROPERTIES IMPORTED_LOCATION "${libs}/${ANDROID_ABI}/libopencv_java3.so") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -frtti -fexceptions") add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). src/main/cpp/native-lib.cpp) # Searches for a specified prebuilt library and stores the path as a # variable. Because CMake includes system libraries in the search path by # default, you only need to specify the name of the public NDK library # you want to add. CMake verifies that the library exists before # completing its build. find_library( # Sets the name of the path variable. log-lib # Specifies the name of the NDK library that # you want CMake to locate. log) # Specifies libraries CMake should link to your target library. You # can link multiple libraries, such as libraries you define in this # build script, prebuilt third-party libraries, or system libraries. target_link_libraries( # Specifies the target library. native-lib libopencv_java3 # Links the target library to the log library # included in the NDK. ${log-lib})

Viewing all articles
Browse latest Browse all 1117

Trending Articles