Closed Andyjk1406 closed 5 years ago
OpenCV =>3.1 and I've even tried OpenCV 4 from https://pullrequest.opencv.org/buildbot/export/opencv_releases/master-contrib_pack-contrib-android/
Operating System / Platform => Windows 64 Bit for Android
Compiler => Android Studio with C++ support
OpenCV => : C++/Android/Opencv (builds fine using this method https://sriraghu.com/2017/03/11/opencv-in-android-an-introduction-part-1/ )
I can compile the code fine but the call - cv::Ptr<> cboard = cv::aruco::CharucoBoard::create(5, 5, 0.5, 0.5, dict);
causes the app on the phone to crash
create a cpp android project as per https://sriraghu.com/2017/03/11/opencv-in-android-an-introduction-part-1/
in the cpp file native-lib.cpp I simply have 10 lines:
extern "C" JNIEXPORT jstring JNICALL Java_com_example_andy_trycpp_MainActivity_stringFromJNI( JNIEnv env, jobject / this */) { std::string hello = "Hello from C++"; cv::Mat m; cv::Ptr dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_7X7_1000); //cv::Ptr cboard = cv::aruco::CharucoBoard::create(5, 5, 0.5, 0.5, dict); return env->NewStringUTF(hello.c_str()); }
If I leave the charucoboard create line commented out, the app builds and runs fine. If I uncomment, the app builds fine but crashes on running.
Note I have used the contrib library build (20181220-025736--10661/) found here https://pullrequest.opencv.org/buildbot/export/opencv_releases/master-contrib_pack-contrib-android/
and have tried other builds - all crash.
Maybe it is something to do with cv::Ptr<> ? Maybe the pointer(s) are invalid ? But the call to charucoboard::create() requires a cv::Ptr<> for the dictionary, and returns a cv::Ptr<> for the charucoboard.
Any ideas appreciated
My bad. It was an opencv assertion failing on the call, but java doesn't handle them so it just crashes
System information (version)
OpenCV =>3.1 and I've even tried OpenCV 4 from https://pullrequest.opencv.org/buildbot/export/opencv_releases/master-contrib_pack-contrib-android/
Operating System / Platform => Windows 64 Bit for Android
Compiler => Android Studio with C++ support
OpenCV => : C++/Android/Opencv (builds fine using this method https://sriraghu.com/2017/03/11/opencv-in-android-an-introduction-part-1/ )
Detailed description
I can compile the code fine but the call - cv::Ptr<> cboard = cv::aruco::CharucoBoard::create(5, 5, 0.5, 0.5, dict);
causes the app on the phone to crash
Steps to reproduce
create a cpp android project as per https://sriraghu.com/2017/03/11/opencv-in-android-an-introduction-part-1/
in the cpp file native-lib.cpp I simply have 10 lines:
include
include
include <opencv2/aruco/charuco.hpp>
extern "C" JNIEXPORT jstring JNICALL Java_com_example_andy_trycpp_MainActivity_stringFromJNI( JNIEnv env, jobject / this */) { std::string hello = "Hello from C++"; cv::Mat m; cv::Ptr dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_7X7_1000);
//cv::Ptr cboard = cv::aruco::CharucoBoard::create(5, 5, 0.5, 0.5, dict);
return env->NewStringUTF(hello.c_str());
}
If I leave the charucoboard create line commented out, the app builds and runs fine. If I uncomment, the app builds fine but crashes on running.
Note I have used the contrib library build (20181220-025736--10661/) found here https://pullrequest.opencv.org/buildbot/export/opencv_releases/master-contrib_pack-contrib-android/
and have tried other builds - all crash.
Maybe it is something to do with cv::Ptr<> ? Maybe the pointer(s) are invalid ? But the call to charucoboard::create() requires a cv::Ptr<> for the dictionary, and returns a cv::Ptr<> for the charucoboard.
Any ideas appreciated