undefined reference to 'cv::imwrite with Android SDK [closed]
I'm using CMAKE to build OpenALPR, which uses OpenCV.
My CMakeLists.txt contains, among other, the following statements :
# Discover OpenCV directory automatically
find_path(OpenCV_DIR
NAMES OpenCVConfig.cmake
HINTS ${CMAKE_SOURCE_DIR}/../libraries/opencv/
/storage/projects/alpr/libraries/opencv/
)
# Opencv Package
FIND_PACKAGE( OpenCV REQUIRED )
CMake doesn't complain about anything, so I assume OpenCV is found (plus, loads of things are built using OpenCV before the error I'm about to mention).
The instruction I use to build everything :
cmake \
-DANDROID_TOOLCHAIN=g++ \
-DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=$NDK_ROOT \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_PLATFORM=$ANDROID_PLATFORM \
-DANDROID_ABI="$i" \
-DANDROID_STL=c++_shared \
-DANDROID_CPP_FEATURES="rtti exceptions" \
-DTesseract_INCLUDE_BASEAPI_DIR=$TESSERACT_SRC_DIR/api \
-DTesseract_INCLUDE_CCSTRUCT_DIR=$TESSERACT_SRC_DIR/ccstruct \
-DTesseract_INCLUDE_CCMAIN_DIR=$TESSERACT_SRC_DIR/ccmain \
-DTesseract_INCLUDE_CCUTIL_DIR=$TESSERACT_SRC_DIR/ccutil \
-DTesseract_LIB=$TESSERACT_LIB_DIR/libtess.so \
-DLeptonica_LIB=$TESSERACT_LIB_DIR/liblept.so \
-DOpenCV_DIR=$SCRIPTPATH/../OpenCV-android-sdk/sdk/native/jni \
-DJAVA_AWT_LIBRARY=$JAVA_AWT_LIBRARY \
-DJAVA_JVM_LIBRARY=$JAVA_JVM_LIBRARY \
-DJAVA_INCLUDE_PATH=$JAVA_INCLUDE_PATH \
-DJAVA_INCLUDE_PATH2=$JAVA_INCLUDE_PATH2 \
-DJAVA_AWT_INCLUDE_PATH=$JAVA_AWT_INCLUDE_PATH \
-DPngt_LIB=$TESSERACT_LIB_DIR/libpngt.so \
-DJpgt_LIB=$TESSERACT_LIB_DIR/libjpgt.so \
-DJnigraphics_LIB=$NDK_ROOT/platforms/$ANDROID_PLATFORM/arch-$arch/usr/$lib/libjnigraphics.so \
-DANDROID_ARM_MODE=arm \
../../src/
Notice that I use the Android OpenCV SDK v3.4.3. I have an undefined error :
openalpr/src/misc_utilities/prepcharsfortraining.cpp:224: error: undefined reference to 'cv::imwrite(cv::String const&, cv::_InputArray const&, std::__ndk1::vector<int, std::__ndk1::allocator<int> > const&)'
The incriminating file has the following include statements :
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <sys/stat.h>
#include "support/filesystem.h"
#include "../tclap/CmdLine.h"
#include "support/utf8.h"
using namespace std;
using namespace cv;
using namespace alpr;
I can't figure out why imwrite cannot be found. I've tried with Android NDK 20,16 and 14 with no luck
I don't understand openALPR is it this?
I can't find any android version
Yes, that's it. There is no Android version, you have to build it yourself with the NDK and then import the .SO libraries in an Android project (which is what I'm currently trying to do).
Mmmmh ..Why does
imgproc.hpp
under the Android SDK doesn't contain any definition forimread
,imwrite
, and so on ?Yes I think it's better to delete. About android and opencv may this can help you.
I'm not an expert in android but when i want to save an image in java I use Imgcodecs.imwrite with opencv 4.1.2(not Imgproc)
There's something that's bugging me. This function should exist, it must be somewhere. My .cpp files refer to it everywhere but I can't find it. And unfortunately, the post you linked didn't improve the situation
in imgcodecs.hpp
Yup, when I download the last Android OpenCV SDK, the header at
sdk\native\jni\include\opencv2\imgcodecs\imgcodecs.hpp
is empty, with an info that it's legacy (but no new destination).When i built opencv for android I have got it
Could you show me an import statement that uses this library ?
doc is here
import org.opencv.imgcodecs.Imgcodecs;