-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from Manojkumarmuru/efficientdet
Efficientdet
- Loading branch information
Showing
13 changed files
with
586 additions
and
355 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import cv2 | ||
|
||
FONT = cv2.FONT_HERSHEY_SIMPLEX | ||
LINE = cv2.LINE_AA | ||
|
||
|
||
def put_text(image, text, point, scale, color, thickness): | ||
"""Draws text in image. | ||
# Arguments | ||
image: Numpy array. | ||
text: String. Text to be drawn. | ||
point: Tuple of coordinates indicating the top corner of the text. | ||
scale: Float. Scale of text. | ||
color: Tuple of integers. RGB color coordinates. | ||
thickness: Integer. Thickness of the lines used for drawing text. | ||
# Returns | ||
Numpy array with shape ``[H, W, 3]``. Image with text. | ||
""" | ||
return cv2.putText(image, text, point, FONT, scale, color, thickness, LINE) | ||
|
||
|
||
def get_text_size(text, scale, FONT_THICKNESS, FONT=FONT): | ||
"""Calculates the size of a given text. | ||
# Arguments | ||
text: String. Text whose width and height is to be calculated. | ||
scale: Float. Scale of text. | ||
FONT_THICKNESS: Integer. Thickness of the lines used for drawing text. | ||
FONT: Integer. Style of the text font. | ||
# Returns | ||
Numpy array with shape ``[H, W, 3]``. Image with text. | ||
""" | ||
return cv2.getTextSize(text, FONT, scale, FONT_THICKNESS) | ||
|
||
|
||
def add_box_border(image, corner_A, corner_B, color, thickness): | ||
""" Draws an open rectangle from ``corner_A`` to ``corner_B``. | ||
# Arguments | ||
image: Numpy array of shape ``[H, W, 3]``. | ||
corner_A: List of length two indicating ``(y, x)`` openCV coordinates. | ||
corner_B: List of length two indicating ``(y, x)`` openCV coordinates. | ||
color: List of length three indicating RGB color of point. | ||
thickness: Integer/openCV Flag. Thickness of rectangle line. | ||
or for filled use cv2.FILLED flag. | ||
# Returns | ||
Numpy array with shape ``[H, W, 3]``. Image with rectangle. | ||
""" | ||
return cv2.rectangle( | ||
image, tuple(corner_A), tuple(corner_B), tuple(color), | ||
thickness) | ||
|
||
|
||
def draw_opaque_box(image, corner_A, corner_B, color, thickness=-1): | ||
""" Draws a filled rectangle from ``corner_A`` to ``corner_B``. | ||
# Arguments | ||
image: Numpy array of shape ``[H, W, 3]``. | ||
corner_A: List of length two indicating ``(y, x)`` openCV coordinates. | ||
corner_B: List of length two indicating ``(y, x)`` openCV coordinates. | ||
color: List of length three indicating RGB color of point. | ||
thickness: Integer/openCV Flag. Thickness of rectangle line. | ||
or for filled use cv2.FILLED flag. | ||
# Returns | ||
Numpy array with shape ``[H, W, 3]``. Image with rectangle. | ||
""" | ||
return cv2.rectangle( | ||
image, tuple(corner_A), tuple(corner_B), tuple(color), | ||
thickness) | ||
|
||
|
||
def make_box_transparent(raw_image, image, alpha=0.30): | ||
""" Blends the raw image with bounding box image to add transparency. | ||
# Arguments | ||
raw_image: Numpy array of shape ``[H, W, 3]``. | ||
image: Numpy array of shape ``[H, W, 3]``. | ||
alpha: Float, weightage parameter of weighted sum. | ||
# Returns | ||
Numpy array with shape ``[H, W, 3]``. Image with rectangle. | ||
""" | ||
return cv2.addWeighted(raw_image, 1-alpha, image, alpha, 0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.