diff --git a/app/src/main/cpp/CvText.cpp b/app/src/main/cpp/CvText.cpp index 3af23325..a805926c 100644 --- a/app/src/main/cpp/CvText.cpp +++ b/app/src/main/cpp/CvText.cpp @@ -552,7 +552,8 @@ namespace cv { { continue; } - mat.at(row, col) = outlineColor; + // mat.at(row, col) = outlineColor; + putPixel_8UC3_blend(mat, row, col, &(outlineColor[0]), s->coverage); } } @@ -573,7 +574,8 @@ namespace cv { { continue; } - mat.at(row, col) = fontColor; + // mat.at(row, col) = fontColor; + putPixel_8UC3_blend(mat, row, col, &(fontColor[0]), s->coverage); #if 0 Pixel32 &dst = pxl[(int)( @@ -732,7 +734,7 @@ namespace cv { // Calcurate width/height/baseline ( in OpenCV coordinates ) int width = xMax - xMin; - int height = -yMin; + int height = yMax; if (_thickness > 0) { width = cvRound(width + _thickness * 2); @@ -744,10 +746,10 @@ namespace cv { } if (_baseLine) { - *_baseLine = yMax; + *_baseLine = -yMin; } - return Size(width, height + yMax); + return Size(width, height); } diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 1fc57e50..43d352f8 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -939,7 +939,7 @@ void DrawOutlineText(cv::Ptr ft2, cv::Mat& mat, const std::st for (std::vector::const_iterator it = lines.cbegin(); it != lines.cend(); ++it ) { textSize = ft2->getTextSize(*it, fontSize, thickness, &baseline); - lineHeight = std::max(fontSize, textSize.height); + lineHeight = std::max(fontSize, textSize.height + baseline); ft2->putText(mat, *it, pt, fontSize, clr, thickness, cv::LINE_AA, false, true); @@ -952,7 +952,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) { if (mCamera == NULL) { - int aa = 0; + // int aa = 0; return false; } @@ -1060,7 +1060,6 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) captureResult.hdrMode); // cv::putText(mat, str, cv::Point(0, mat.rows - 20), cv::FONT_HERSHEY_COMPLEX, fontScale, scalar, thickness1, cv::LINE_AA); - textSize = ft2->getTextSize(str, fontSize, -1, &baseline); ft2->putText(mat, str, cv::Point(0, mat.rows - fontSize - 20 * ratio), fontSize, scalarRed, -1, cv::LINE_AA, false); @@ -1105,12 +1104,12 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) else if (it->alignment == OSD_ALIGNMENT_BOTTOM_RIGHT) { pt.x = width - textSize.width - it->x * ratio; - pt.y = height - it->y * ratio - textSize.height; + pt.y = height - it->y * ratio - textSize.height - baseline; } else if (it->alignment == OSD_ALIGNMENT_BOTTOM_LEFT) { pt.x = it->x * ratio; - pt.y = height - it->y * ratio - textSize.height; + pt.y = height - it->y * ratio - textSize.height - baseline; } // cv::Rect rc(pt.x, pt.y, textSize.width, textSize.height);