Steve
Steve

Reputation: 193

How to crop face detection result using gcloud command line

I have uploaded an image in my Google Cloud Storage inside a bucket. Then I open the gcloud command line and I run the following:

gcloud ml vision detect-faces gs://my-bucket/face.png

I can see the result in json format, so I understand that it returns the position of the face and some face features.

How can I save/export a cropped image containing just the face, using the gcloud command line?

In other words, in the below example, how can I export as a separate image the area within the larger green box?

enter image description here

Upvotes: 2

Views: 164

Answers (1)

Kolban
Kolban

Reputation: 15266

Using face detection API, you get back a rectangle that identifies the found face. If what you now want is to create a new image (which could replace the old image if desired) containing just the face, you can use a tool like ImageMagick. This can be command line executed. This tool takes as input a source image, commands and generates a new image. One of the commands is -crop which will crop an image given an input rectangle (the face box).

Upvotes: 1

Related Questions