首页 > 其他分享 >OpenCV | cv2.putText() method

OpenCV | cv2.putText() method

时间:2023-01-04 10:01:55浏览次数:42  
标签:putText color text image cv2 OpenCV font method

cv2.putText() method is used to draw a text string on any image.

Syntax: cv2.putText(image, text, org, font, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])

Parameters:
image: It is the image on which text is to be drawn.
text: Text string to be drawn.
org: It is the coordinates of the bottom-left corner of the text string in the image. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
font: It denotes the font type. Some of font types are FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, , etc.
fontScale: Font scale factor that is multiplied by the font-specific base size.
color: It is the color of text string to be drawn. For BGR, we pass a tuple. eg: (255, 0, 0) for blue color.
thickness: It is the thickness of the line in px.
lineType: This is an optional parameter.It gives the type of the line to be used.
bottomLeftOrigin: This is an optional parameter. When it is true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner.

Return Value: It returns an image.

before:

   

# Python program to explain cv2.putText() method
	
# importing cv2
import cv2
	
# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'
	
# Reading an image in default mode
image = cv2.imread(path)
	
# Window name in which image is displayed
window_name = 'Image'

# font
font = cv2.FONT_HERSHEY_SIMPLEX

# org
org = (50, 50)

# fontScale
fontScale = 1

# Blue color in BGR
color = (255, 0, 0)

# Line thickness of 2 px
thickness = 2

# Using cv2.putText() method
image = cv2.putText(image, 'OpenCV', org, font,
				fontScale, color, thickness, cv2.LINE_AA)

# Displaying the image
cv2.imshow(window_name, image)

after:

标签:putText,color,text,image,cv2,OpenCV,font,method
From: https://www.cnblogs.com/yuxiyuxi/p/17024031.html

相关文章

  • Ubuntu下配置opencv环境
    目录​​安装准备​​​​安装cmake​​​​安装依赖环境​​​​下载opencv​​​​安装​​​​解压​​​​cmake​​​​编译​​​​安装​​​​配置环境​​​​检验......
  • Ubuntu配置OpenCV终极解决方案
    安装依赖一定要安装全,避免之后出现各种奇怪的问题sudoapt-getinstallbuild-essentialsudoapt-getinstallcmakegitlibgtk2.0-devpkg-configlibavcodec-devlibavfo......
  • opencv-python同时调用两个摄像头
    importcv2importnumpyasnpcapture=cv2.VideoCapture(0)capture_usb=cv2.VideoCapture(2)#打开自带的摄像头ifcapture.isOpened()andcapture_usb.isOpene......
  • java.lang.Exception: No runnable methods
    java.lang.Exception:Norunnablemethods 1、问题现象1)测试代码packagecom.example.disruptordemo;importcom.example.disruptordemo.service.DisruptorMqSer......
  • OpenCV学习之路(附加资料分享)
    目录​​一、前言​​​​二、学习历程​​​​三、学习资料​​​​书籍​​​​网站​​​​视频教程​​​​四、学习建议​​​​入门​​​​强化​​​​灵通​​一、......
  • Win7X64下,opencv安装折腾
    先说环境:win7X64专业版、python3.6.4pip安装了pillow,正常可使用为了不影响原来的环境,新建了一个python虚拟环境,如下:节选自https://zhuanlan.zhihu.com/p/216157886在......
  • Django-drf-序列化器高级用法之SerializerMethodField
    在Drf框架中的serializers.py序列化中,SerializerMethodField字段是一个只读字段。它通过调用附加到的序列化程序类上的方法来获取其值。它可用于将任何类型的数据添加到对......
  • OpenCV+yolov3实现目标检测(C++,Python)
    OpenCV+yolov3实现目标检测(C++,Python)  目标检测算法主要分为两类:一类是基于RegionProposal(候选区域)的算法,如R-CNN系算法(R-CNN,FastR-CNN,FasterR-CNN),它们是two-st......
  • OpenCV常见的优化方法和技巧总结
    OpenCV常见的优化方法和技巧总结目录​​OpenCV常见的优化方法和技巧总结​​​​ 一、OpenCV常见的优化方法总结​​​​1.1cv::imread()设置reduce模式:​​​​1.2查表......
  • OpenCV调用TensorFlow预训练模型
    OpenCV调用TensorFlow预训练模型   强大OpenCV从自OpenCV3.1版以来,dnn模块一直是opencv_contrib库的一部分,在3.3版中,它被提到了主仓库中。新版OpenCVdnn模块目前支......