feat : added the poc and the venv
This commit is contained in:
46
test_text_cv.py
Executable file
46
test_text_cv.py
Executable file
@ -0,0 +1,46 @@
|
||||
# Python program to explain cv2.putText() method
|
||||
|
||||
# importing cv2
|
||||
import cv2
|
||||
|
||||
# text to display
|
||||
text = 'OpenCV'
|
||||
|
||||
# path
|
||||
path = r'./car.jpg'
|
||||
|
||||
# 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, text, org, font,
|
||||
fontScale, color, thickness, cv2.LINE_AA)
|
||||
|
||||
# you can also get the size of the text if needed to fix it in a box
|
||||
text_width, text_height = cv2.getTextSize(text, font, fontScale, thickness)[0]
|
||||
print(f"this text has size {text_width} {text_height}")
|
||||
|
||||
# Displaying the image
|
||||
while True:
|
||||
cv2.imshow(window_name, image)
|
||||
key = cv2.waitKey(1)
|
||||
if key == ord("q"):
|
||||
break
|
||||
Reference in New Issue
Block a user