fixing broken Mat::dump() in Java

This commit is contained in:
Andrey Pavlenko 2013-06-05 11:46:06 +04:00
parent d81d3fc830
commit c7873dd03d

View File

@ -2545,32 +2545,12 @@ JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
try { try {
LOGD("Mat::nDump()"); LOGD("Mat::nDump()");
const int BUFSZ = 4096 - 32;
char buf[BUFSZ + 32];
String s; String s;
Ptr<Formatted> fmtd = Formatter::get()->format(*me); Ptr<Formatted> fmtd = Formatter::get()->format(*me);
char* pos = buf;
for(const char* str = fmtd->next(); str; str = fmtd->next()) for(const char* str = fmtd->next(); str; str = fmtd->next())
{ {
pos = strcpy(pos, str); s = s + String(str);
if(pos > buf + BUFSZ)
{
s = s + String(buf, pos - buf);
pos = buf;
}
} }
if (pos > buf)
{
if (s.empty())
return env->NewStringUTF(buf);
s = s + String(buf, pos - buf);
}
return env->NewStringUTF(s.c_str()); return env->NewStringUTF(s.c_str());
} catch(cv::Exception e) { } catch(cv::Exception e) {
LOGE("Mat::nDump() catched cv::Exception: %s", e.what()); LOGE("Mat::nDump() catched cv::Exception: %s", e.what());