Watson Visual Recognition's Detect Face face detection feature allows you to read a person's age, gender, and position of the face in an image. This time, we implemented a code in Java that uses a face detection function called Detect Face to detect the position of the face from a human image and process it into an image of only the face part.
Please refer to the following URL for the installation method. http://qiita.com/hiesiea/items/54e49dabfb5606edb54d#2-jdk%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB 2. Install eclipse Install eclipse from the following URL. http://www.eclipse.org/downloads/
Please refer to the following URL for the installation method. http://qiita.com/hiesiea/items/54e49dabfb5606edb54d#3-eclipse%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB 3. Create Maven project Create "New"-> "Project"-> "Maven Project" of eclipse.
Create a Visual Recognition service on Bluemix. Log in to Bluemix from the URL below and create a "Catalog"-> "Watson"-> "Visual Recognition" service. https://console.bluemix.net/
After creating the Visual Recognition service, check {api_key} from "Service Credentials"-> "Credentials-1" and make a note of it.
This time, we will execute DetectFaces.java, which is a code that cuts and saves only the face part of a person's image.
Modify the code in DetectFacesThread.java. Change the {api_key} in the code for this class to the api_key you noted earlier.
Place the image you want to detect the face. For images, create a "trainImage" folder directly under the project, create a "image ID name" folder in the "trainImage" folder, and place the image in the "image ID name" folder. This image ID is used to sort by person, so place the same person in the folder with the same image ID name.
PROJECTNAME
|-trainImage
|-IMGID_NAME
|-IMG
|-IMG
For example, the images of "m010462.jpg " and "m010469.jpg " are stored in the folder with the image ID name "femaleA" as shown below.
Put the following in the argument and implement. 「./trainImage」
The execution result is as follows.
After execution, a folder with the image ID will be created in the faceImage folder directly under the project, and the image will be saved in that image ID folder.
Recommended Posts