我实现了Firebase ML工具包,你们可以帮助我如何根据这些信息创建位图并将其显示给imageview?请帮助我如何在此阶段创建位图并将其保存到设备内存中?我尝试了这段代码,帮助我更深入。
fn2<Tree, "age">(tree, dog); // error, dog is not a StrictPicked<Tree, "age">
答案 0 :(得分:0)
您可以执行以下操作:
// bitmap is the image you already detected faces
Paint myRectPain = new Paint();
myRectPain.setStrokeWidth(10);
myRectPain.setColor(Color.RED);
myRectPain.setStyle(Paint.Style.STROKE);
Bitmap tempBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(),Bitmap.Config.RGB_565);
Canvas tempCanvas = new Canvas(tempBitmap);
tempCanvas.drawBitmap(bitmap,0,0,null);
for (FirebaseVisionFace face: faces) {
Rect bound = face.getBoundingBox();
tempCanvas.drawRect(bound,myRectPain);
}
// imgView is an ImageView
imgView.setImageDrawable(new BitmapDrawable(getResources(),tempBitmap));