I am not sure how to title my question. Only terms I know are broadcasting
and element wise
. Please correct my title if is not accurate.
Background:
Previously I was working on text detection. However, detected picture is a bit smaller I can't get the whole information from the cropped image
. I understand that I am using English based classifier to do word detection.
Therefore I have to fine tune the cropped coords a bit for overlapping Thai sentence. Here is the example of a bit smaller cropped area. You can see punctuation and tone sign are partially lost
I have 3 squares represented in array called pts
ipdb> pts
array([[[ 436, 3085],
[2968, 3081],
[2968, 3227],
[ 436, 3232]],
[[1222, 397],
[1833, 400],
[1833, 498],
[1221, 496]],
[[ 86, 3275],
[2968, 3268],
[2968, 3421],
[ 87, 3427]]], dtype=int32)
ipdb> pts.shape
(3, 4, 2)
Later on I do a calculation to find the center of them using
np.sum(pts, axis=1) / 4.0
. I put it to center_pts
ipdb> center_pts
array([[1702. , 3156.25],
[1527.25, 447.75],
[1527.25, 3347.75]])
ipdb> center_pts.shape
(3, 2)
Ultimate Goal:
I want to cover the losing punctuation and tone sign
Attempt:
I am trying to do subtraction to make a vector reference from center of the square and point to each corner. And times with small factor to cover the lost part of cropped image.
My first idea is sacrifice one for loop and the use element wise to take advantage of broadcasting like this.
pts[0] - center_pts[0]
array([[-1266. , -71.25],
[ 1266. , -75.25],
[ 1266. , 70.75],
[-1266. , 75.75]])
Questions:
1. Is it possible to do it without for-loop
?
2. Are they any more productive to expand my square?