How to Detect Objects — Including Types & Locations — In an Image using Java

The more we know about our images, the more easily we can search them in our own databases & make informed changes to them as needed. With our Object Detection API, you can automatically identify objects within your photo and return useful information about them including the object type (this determination is accompanies by a confidence score ranging between 0.0–1.0) & object location (this is expressed in terms of pixel coordinates & approximate measurements of the object). The response body for any given image will look something like the below, with one ObjectClassName string provided for every identifiable object:

This API is completely free to use — you just need to register a free account on our website, and supply your API key within the ready-to-run Java code examples provided below. In the remainder of this article, I’ll walk you through how to structure your API call using said Java code examples; all you need to do is copy & paste.

Our first step is to install the API client. Let’s add a reference to the repository in pom.xml:

And then let’s add one to the pom.xml dependency:

With installation complete, let’s turn our attention to the controller; first include the imports at the top of your file, and then call the function:

With that, you’re all finished — no more code required!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.