[6127] | 1 | /*
|
---|
[13061] | 2 | * Copyright 2002-2017 Drew Noakes
|
---|
[6127] | 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | *
|
---|
| 16 | * More information about this project is available at:
|
---|
| 17 | *
|
---|
[8132] | 18 | * https://drewnoakes.com/code/exif/
|
---|
| 19 | * https://github.com/drewnoakes/metadata-extractor
|
---|
[6127] | 20 | */
|
---|
| 21 | package com.drew.metadata;
|
---|
| 22 |
|
---|
| 23 | import com.drew.lang.annotations.NotNull;
|
---|
| 24 | import com.drew.lang.annotations.Nullable;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * Class to hold information about a detected or recognized face in a photo.
|
---|
[8132] | 28 | * <p>
|
---|
[6127] | 29 | * When a face is <em>detected</em>, the camera believes that a face is present at a given location in
|
---|
| 30 | * the image, but is not sure whose face it is. When a face is <em>recognised</em>, then the face is
|
---|
| 31 | * both detected and identified as belonging to a known person.
|
---|
| 32 | *
|
---|
| 33 | * @author Philipp Sandhaus, Drew Noakes
|
---|
| 34 | */
|
---|
| 35 | public class Face
|
---|
| 36 | {
|
---|
| 37 | private final int _x;
|
---|
| 38 | private final int _y;
|
---|
| 39 | private final int _width;
|
---|
| 40 | private final int _height;
|
---|
| 41 | @Nullable
|
---|
| 42 | private final String _name;
|
---|
| 43 | @Nullable
|
---|
| 44 | private final Age _age;
|
---|
| 45 |
|
---|
| 46 | public Face(int x, int y, int width, int height, @Nullable String name, @Nullable Age age)
|
---|
| 47 | {
|
---|
| 48 | _x = x;
|
---|
| 49 | _y = y;
|
---|
| 50 | _width = width;
|
---|
| 51 | _height = height;
|
---|
| 52 | _name = name;
|
---|
| 53 | _age = age;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public int getX()
|
---|
| 57 | {
|
---|
| 58 | return _x;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | public int getY()
|
---|
| 62 | {
|
---|
| 63 | return _y;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | public int getWidth()
|
---|
| 67 | {
|
---|
| 68 | return _width;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | public int getHeight()
|
---|
| 72 | {
|
---|
| 73 | return _height;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | @Nullable
|
---|
| 77 | public String getName()
|
---|
| 78 | {
|
---|
| 79 | return _name;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | @Nullable
|
---|
| 83 | public Age getAge()
|
---|
| 84 | {
|
---|
| 85 | return _age;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | @Override
|
---|
| 89 | public boolean equals(@Nullable Object o)
|
---|
| 90 | {
|
---|
| 91 | if (this == o) return true;
|
---|
| 92 | if (o == null || getClass() != o.getClass()) return false;
|
---|
| 93 |
|
---|
| 94 | Face face = (Face)o;
|
---|
| 95 |
|
---|
| 96 | if (_height != face._height) return false;
|
---|
| 97 | if (_width != face._width) return false;
|
---|
| 98 | if (_x != face._x) return false;
|
---|
| 99 | if (_y != face._y) return false;
|
---|
| 100 | if (_age != null ? !_age.equals(face._age) : face._age != null) return false;
|
---|
| 101 | if (_name != null ? !_name.equals(face._name) : face._name != null) return false;
|
---|
| 102 |
|
---|
| 103 | return true;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | @Override
|
---|
| 107 | public int hashCode()
|
---|
| 108 | {
|
---|
| 109 | int result = _x;
|
---|
| 110 | result = 31 * result + _y;
|
---|
| 111 | result = 31 * result + _width;
|
---|
| 112 | result = 31 * result + _height;
|
---|
| 113 | result = 31 * result + (_name != null ? _name.hashCode() : 0);
|
---|
| 114 | result = 31 * result + (_age != null ? _age.hashCode() : 0);
|
---|
| 115 | return result;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[8132] | 118 | @Override
|
---|
[6127] | 119 | @NotNull
|
---|
| 120 | public String toString()
|
---|
| 121 | {
|
---|
| 122 | StringBuilder result = new StringBuilder();
|
---|
| 123 | result.append("x: ").append(_x);
|
---|
| 124 | result.append(" y: ").append(_y);
|
---|
| 125 | result.append(" width: ").append(_width);
|
---|
| 126 | result.append(" height: ").append(_height);
|
---|
| 127 | if (_name != null)
|
---|
| 128 | result.append(" name: ").append(_name);
|
---|
| 129 | if (_age != null)
|
---|
| 130 | result.append(" age: ").append(_age.toFriendlyString());
|
---|
| 131 | return result.toString();
|
---|
| 132 | }
|
---|
| 133 | }
|
---|