Last active
June 3, 2016 21:42
-
-
Save vrunoa/f3b39aae10dafe30a8ed7930862834ba to your computer and use it in GitHub Desktop.
cv::cvtColor fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// trying to convert Luv image to BGR | |
JNIEXPORT jboolean JNICALL Java_com_test_run(JNIEnv* env, jobject thiz, jlong data) { | |
__android_log_write(ANDROID_LOG_INFO, "TEST", "run"); | |
if(data == 0) { | |
__android_log_write(ANDROID_LOG_ERROR, "TEST", "empty jlong mat"); | |
return false; | |
} | |
cv::Mat frame = *((cv::Mat*)data); | |
if(frame.empty()) { | |
return false; | |
} | |
cv::Mat bgr = cv::Mat(frame.rows, frame.cols); | |
cv::cvtColor(frame, bgr, cv::COLOR_Luv2BGR); | |
cv::Mat rotated; | |
cv::Point2f center(frame.cols/2.0F, frame.rows/2.0F); | |
cv::Mat rot = getRotationMatrix2D(center, 90, 1.0); | |
cv::warpAffine(frame, rotated, rot, frame.size()); | |
return doCollStuff(rotated.data); | |
} | |
/* throws this error | |
* 05-31 21:02:23.021 22356-22854/? E/cv::error(): OpenCV Error: Assertion failed (scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F)) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /builds/master_pack-android/opencv/modules/imgproc/src/color.cpp, line 8291 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mshabunin thanks for your reply. Actually the image provided by android opencv wasn't Luv, was actually RGBA, I thought it was Luv since it looks "violet" when I saved it. I fixed changing
cv::cvtColor(frame, bgr, CV_RGBA2BGR);