opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.31k stars 5.74k forks source link

create Charucoboard crashes on android #1948

Closed Andyjk1406 closed 5 years ago

Andyjk1406 commented 5 years ago
System information (version)
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

Andyjk1406 commented 5 years ago

My bad. It was an opencv assertion failing on the call, but java doesn't handle them so it just crashes