关于python 和C++使用cv画矩形并填充颜色同时填充文字
2017-06-16 15:24
531 查看
python:
font = cv2.FONT_HERSHEY_SIMPLEX # 使用默认字体
cv2.rectangle(im, (10, 10), (110, 110), (0, 0, 255), thickness=2)
# cv2.floodFill()
cv2.rectangle(im, (113), int(110)), (int(300), int(135),
(255, 0, 0), thickness=-1)
cv2.putText(im, class_name + ' ' + str(score), (int(113, int(126)), font, 0.6,
(255, 255, 255), 1)
c++:
//显示通用通用模板
int fontface = cv::FONT_HERSHEY_SIMPLEX;
double scale = 0.5;
int thickness = 1.5;
int baseline = 0;
char buff[50]="hello";
cv::Size text = cv::getTextSize(buff, fontface, scale, thickness,
&baseline);
Mat dd=Mat(pair_p, false);
cv::rectangle(dd, cv::Point(0, 0),
cv::Point(text.width, (text.height + baseline)*3),
CV_RGB(255, 255, 255), CV_FILLED);
cv::putText(dd, buff, cv::Point(0, text.height + baseline / 2.),
fontface, scale, CV_RGB(0, 0, 0), thickness, 8);
cv::imshow("detections", dd);
font = cv2.FONT_HERSHEY_SIMPLEX # 使用默认字体
cv2.rectangle(im, (10, 10), (110, 110), (0, 0, 255), thickness=2)
# cv2.floodFill()
cv2.rectangle(im, (113), int(110)), (int(300), int(135),
(255, 0, 0), thickness=-1)
cv2.putText(im, class_name + ' ' + str(score), (int(113, int(126)), font, 0.6,
(255, 255, 255), 1)
c++:
//显示通用通用模板
int fontface = cv::FONT_HERSHEY_SIMPLEX;
double scale = 0.5;
int thickness = 1.5;
int baseline = 0;
char buff[50]="hello";
cv::Size text = cv::getTextSize(buff, fontface, scale, thickness,
&baseline);
Mat dd=Mat(pair_p, false);
cv::rectangle(dd, cv::Point(0, 0),
cv::Point(text.width, (text.height + baseline)*3),
CV_RGB(255, 255, 255), CV_FILLED);
cv::putText(dd, buff, cv::Point(0, text.height + baseline / 2.),
fontface, scale, CV_RGB(0, 0, 0), thickness, 8);
cv::imshow("detections", dd);
相关文章推荐
- 关于python使用cv画矩形并填充颜色同时填充文字
- 使用python在linux中输出带颜色的文字
- 使用线性渐变颜色填充矩形
- Python3 Tkinter基础 Canvas 使用coords移动一条直线,itemconfig设置矩形的颜色,delete删除一条直线
- python下使用cv2.drawContours填充轮廓颜色
- android 同意协议、服务等,一行文字中掺杂关于其他颜色字体。同时实现超链接点击跳转等功能.
- C++之父元旦专访(8+13个问题,关于C++的学习&使用和未来)
- 关于使用了透明文字背景后,文字不能刷新而重叠在一起的问题
- 关于C++中函数指针的使用(包含对typedef用法的讨论)
- 关于C++中函数指针的使用(包含对typedef用法的讨论)
- C++之父元旦专访(8+13个问题,关于C++的学习&使用和未来)
- 关于C++中函数指针的使用(包含对typedef用法的讨论)
- 关于在c++的类中使用线程的问题
- 关于 python 中使用 lambda 表达式的问题
- [C++]关于内联函数的使用
- C++之父元旦专访(8+13个问题,关于C++的学习&使用和未来)
- 让C++和Python使用同一个枚举
- C++ 为什么要同时使用*和&符号?以及什么场合使用这种声明方式?
- 关于在组件GIS开发中使用Python的一点补充说明
- 关于C++中函数指针的使用(包含对typedef用法的讨论)