Skip to content

added coordinate feature for each object.#8110

Open
parikshit223933 wants to merge 1 commit intotensorflow:masterfrom
parikshit223933:patch-1
Open

added coordinate feature for each object.#8110
parikshit223933 wants to merge 1 commit intotensorflow:masterfrom
parikshit223933:patch-1

Conversation

@parikshit223933
Copy link

@parikshit223933 parikshit223933 commented Feb 4, 2020

With the changes made in the code, the user will now be able to:

  • Get the center-coordinates of the box, corresponding to each object in the image, which will make locating objects in the image easier for the user.
  • User won't need to write bunch of lines for getting an array of labelled objects found in the image
  • Sequencing of the text will become easier. for example, if the user has created a model on text detection, it is often difficult for him to print the objects in a sequence. It will become much easier now.
  • Training a batch of images in a single tensorflow session, and printing the text for each image in a particular sequence will become easier.

EXAMPLE:
image
As you can see in the above image, if the first six characters have to be printed before the last four characters, then you will need to know the coordinates of each character of the image. otherwise, the characters will be printed in a shuffled order.
(In the right hand side in the command prompt, there is the string which has been detected in a correct sequence)

EXAMPLE CODE TO MAKE USE OF CHANGES DONE:

#I am taking an example of text detection. to describe the usability of added lines of code. image with text is attatched below.
#as shown in the image attatched below, we have two lines written in the image, now to print the sequence as such, we have to have
#the center coordinates of each character in the image.
# code snippet to print and license number as such.
#this is the main code which tells us the use of the arrays corresponding_coordinates and 
corresponding_coordinates=np.array(vis_util.corresponding_coordinates)
character=np.array(vis_util.label_array)
#this is a 2d array which will contain all the characters and accuracies corresponding to them as a string.
characters=[]
for i in range(len(character)):
    for string in character[i]:
        characters.append(string.split(':')[0])
#now i have got all the characters in a list named characters.
threshold_y=np.mean(corresponding_coordinates[:, 1])
#decided the threshold value of y coordinate. if any character coordinate lies above this threshold value
#that will be printed first
#and vice versa.
#this threshold value is the mean of all the y coordinates of all the characters.
characters=np.array(characters)
sortable_initial_x_coordinates=corresponding_coordinates[:, 0][corresponding_coordinates[:, 1]<threshold_y]
#got the coordinates for all the characters which are lying above the threshold value.
starting_characters=characters[corresponding_coordinates[:, 1]<threshold_y][np.argsort(sortable_initial_x_coordinates)]
#then printed the upper characters first in the sorted order of x values.
sortable_final_x_coordinates=corresponding_coordinates[:, 0][corresponding_coordinates[:, 1]>=threshold_y]
#repeated for the characters lying below the threshold value.
ending_characters=characters[corresponding_coordinates[:, 1]>=threshold_y][np.argsort(sortable_final_x_coordinates)]
#printed the ending characters which lie below the threshold y value, in the sorted order of x values.
print(''.join([''.join(starting_characters), ''.join(ending_characters)]))
vis_util.clearer()
#this clearer function has to be called before switching to another image to clear two currently filled arrays.
# namely, vis_util.corresponding_coordinates array and vis_utils.label_array.

UP14AQ6194_484_17

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@parikshit223933
Copy link
Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@parikshit223933
Copy link
Author

parikshit223933 commented Oct 18, 2020

Hello sir, How long does it take to review a PR on tensorflow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants