Skip to content

Commit

Permalink
fix bug in rect calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiasibo committed May 10, 2017
1 parent a1dcf4a commit b7e493e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cvUniText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ cv::Rect Impl::_cvPutUniTextUCS2(cv::Mat& img, const std::u16string& text,
rect.width = pt1.x - pt0.x;
rect.height = ascender - descender;
rect.x = pt0.x;
rect.y = pt0.y - descender;
rect.y = pt0.y - ascender;
return rect;
}

Expand Down
2 changes: 1 addition & 1 deletion cvUniText.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace uni_text {
/// Useful e.g. when you want to draw a rectangle under the text
/// \return The precise bounding box of the text in the image
cv::Rect PutText(cv::Mat &img, const std::string &utf8_text, const cv::Point &org,
const cv::Scalar &color, bool calc_size);
const cv::Scalar &color, bool calc_size = false);

private:
/// Hide implementations
Expand Down
2 changes: 1 addition & 1 deletion install/cvUniText.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace uni_text {
/// Useful e.g. when you want to draw a rectangle under the text
/// \return The precise bounding box of the text in the image
cv::Rect PutText(cv::Mat &img, const std::string &utf8_text, const cv::Point &org,
const cv::Scalar &color, bool calc_size);
const cv::Scalar &color, bool calc_size = false);

private:
/// Hide implementations
Expand Down
Binary file modified install/libcvunitext.so
Binary file not shown.
6 changes: 3 additions & 3 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include "cvUniText.hpp"
#include <iostream>

int main() {
cv::Mat img = cv::imread("/home/jiasibo/1.jpg");
uni_text::UniText uniText("/usr/share/fonts/wqy-microhei/wqy-microhei.ttc", 80);
int main(int argc, char** argv) {
cv::Mat img = cv::imread(argv[1]);
uni_text::UniText uniText("/usr/share/fonts/wqy-microhei/wqy-microhei.ttc", 22);
cv::Rect rect = uniText.PutText(img, "Hello, 哈哈哈哈哈嗝", cv::Point(100, 100), cv::Scalar(0,255,0), false);
std::cout << rect << std::endl;
cv::imwrite("1.jpg", img);
Expand Down

0 comments on commit b7e493e

Please sign in to comment.