Handy CV2¶
-
handypy.hcv2.
imread
(*args, **kwargs) → numpy.ndarray[source]¶ Fail-safe image read
- Parameters
args – Pass to
cv2.imread()
. filename is required.kwargs – Pass to
cv2.imread()
.
- Returns
image numpy array
-
handypy.hcv2.
imwrite
(*args, **kwargs) → int[source]¶ Fail-safe and convenient image write. Put image and image filename in any order.
- Parameters
args – Pass to
cv2.imwrite()
. filename and img are required as arguments (order-free) or keywords.kwargs – Pass to
cv2.imwrite()
.
- Returns
0,1
- Raise
RuntimeError
-
handypy.hcv2.
putChineseText
(image: numpy.ndarray, text: str, org=(0, 0), font=None, fontScale=1, color=(0, 0, 255), thickness=1, lineType=None, bottomLeftOrigin=False) → numpy.ndarray[source]¶ Add CJK text to image
- Parameters
image – image array
text – text to be added
org – origin of text, from top left by default
font – font name if in the system, or font file path
fontScale – font size. Size 1 corresponds to 12 pixel.
color – BGR color, default red.
thickness – no effect, place holder.
lineType – no effect, place holder.
bottomLeftOrigin – True to start from bottom left, default False
- Returns
image with text added
-
handypy.hcv2.
putText
(image: numpy.ndarray, text: str, org=(0, 0), font=1, fontScale=1, color=(0, 0, 255), thickness=1, lineType=16, bottomLeftOrigin=False) → numpy.ndarray[source]¶ Add text to cv2 image, with default values.
- Parameters
image – image array
text – text to be added
org – origin of text, from top left by default
font – font choice
fontScale – font size
color – BGR color, red by default
thickness – font thickness
lineType – line type of text
bottomLeftOrigin – True to start from bottom left, default False
- Returns
image with text added