hey cameron mckenzie here at cameron mcnz on twitter and i wanted to talk to you about
integrating google cloud vision with ui path sometimes the ui path ocr facilities just aren't
quite up to the job in those cases you really need a heavyweight contender and google cloud
vision is a great one to use so i'll kick this off by creating a new process project and i'll call it
google cloud vision ocr and as that project is creating i'm going to show you these memes i've
got one two three four five six of my favorite memes in here and i want to do some ocr on them
i did another video and i showed you how that the built-in ocr with uipath
really doesn't do a very good job with these images but google cloud vision is
awesome and so i want to show you how i can loop through all of these files that's in that are in
this memes directory and do google cloud vision ocr on them first step is opening the main window
and then looking for the for each activity the for each activity just going to allow me to loop
through all of the files in this directory so i'll say for each file in the directory
dot get files
and the folder is c memes okay that looks good sometimes i forget the quotes
so for each file in here what i need to do is i need to first create an image
object and so i'll see if i can find the load image function ui automation load image
and what image do i want to load well every time i
find a file i want to load it so that's file.tostring
that loads the image now that image gets held in a variable and the variable can be
set by putting the variable name over here in the output i haven't declared a variable
so i need to do that right now and i'm going to call that meme image and the type there is very
important there's a bunch of different image types but this has to be from core from uipath
dot core dot image if it's a different type you'll end up with a runtime error and you don't want to
get that and so that meme image variable is where the loaded image is going to be stored and after
i've loaded that image well the next thing to do is just do some google cloud vision ocr so
i'll type in google cloud you'll see that under ocr engines google cloud vision is one of them
i'm going to move that over here there's a couple of options that need to be set one is just a you
need a temporary variable to store the result of doing the google cloud vision so i'm just going to
create a temporary variable of type string called meme text and when google cloud vision runs
the text will be stored in that variable right there
and i may as well do a little bit of a right line
underneath just to write that out and so this right line command here will just print out the
text that's been extracted from the google cloud vision process on that meme
now there's a couple other things you need to set up here so this google cloud vision needs to know
what image is going to be processed we create that variable named meme image that was loaded up here
and so i need to specify that meme image that's been done and then the other thing i need to
specify is this api key now you get the api key by registering with google cloud vision
and in order to use the api you actually have to enable billing now you can put like a limit on
your account and say don't ever charge me more than ten dollars a month and and really you get
i think like you know a thousand free image processing so you know you need to sign up and
register a google cloud vision account and enable billing provide a credit card to get an api key
but once you do you just put your api key in quotes and paste it into that api key
and then this will work now if i put my api key in there and a thousand people do this video then
i could end up with a thousand dollar bill at the end of the month so i'm going to pause the video
so i've now entered in my api key over here i'm going to close that window so you can't see it
anymore i'm going to click ctrl s for save and then i'm going to run this application
it now uploads those images to google cloud vision
gets the response back and you can look at the output over here
notice that it's done a really good job at extracting the data from all of these memes i can
see over here i don't always use in an explorer when i do i usually download a better browser
it's even got the you can see right in that lower left hand corner it's got the it's got the url of
the website that's generated that image so cache me outside how about that notice the ph there it's
actually trying to process the little watermark there where it says dr phil so that's pretty cool
um probably have to extract that out but i mean that's actually some pretty amazing ocr there
and yeah it just goes through and it actually does a really good job at bringing all of this
out a much much better job than the the built-in ocr and the built-in ocr with uipath is really
good for extracting structured data from pdf files and invoices and those types of resources
but if you need to go that extra mile certainly using google cloud vision is one of the ways to go
and there you go that's how you integrate google cloud vision with uipath if you enjoyed
this tutorial head over to theserverside.com i'm the editor-in-chief over there we've got
lots of great articles and tutorials on enterprise software development if you're
interested in my personal antics you can follow me on twitter at cameronmcnz and subscribe on youtube