getFacesEntity method
Returns FacesEntity
which contains original image size and rectangles of faces
Example:
FacesEntity entity = /* FacesEntity */
RenderBox renderBox = context.findRenderObject();
return FractionallySizedBox(
widthFactor: 1,
heightFactor: 1,
child: Stack(
children: <Widget>[
Positioned.fill(
child: Image(
image: UploadcareImageProvider(widget.imageId),
fit: BoxFit.contain,
alignment: Alignment.topCenter,
),
),
...entity
.getRelativeFaces(
Size(
renderBox.size.width,
renderBox.size.width /
entity.originalSize.aspectRatio,
),
)
.map((face) {
return Positioned(
top: face.top,
left: face.left,
child: Container(
width: face.size.width,
height: face.size.height,
decoration: BoxDecoration(
color: Colors.black12,
border: Border.all(color: Colors.white54, width: 1.0),
),
),
);
}).toList(),
],
),
);
Implementation
Future<FacesEntity> getFacesEntity(String imageId) async {
final response = await _detectFaces(imageId);
return FacesEntity.fromJson(response);
}