需要帮助! 我有这个代码。如何绘制68并在相机预览中看到它们?
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
rgba = inputFrame.rgba();
try {
Bitmap bmp = matToBitmap(rgba);
points = getLandmark(bmp, this, predictorPath); // getting 68 points
drawPoints(bmp, points);
} catch (Exception e) {
Log.i(TAG, "bitmap error! " + e.getMessage());
}
return rgba;
}
编辑:添加了此方法,但没有任何反应
public void drawPoints(Bitmap bitmap, List<Point> points) {
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
float radius = 4f;
// draw points
for(Point point : points) {
canvas.drawCircle(point.x, point.y, radius, paint);
}
}
答案 0 :(得分:0)
尝试使用Canvas在位图上绘制内容。 Here您可以找到有关此内容的更多信息。
答案 1 :(得分:0)
您可以在Canvas类的帮助下在Bitmap上绘制点。一个例子:
public void drawPoints(Bitmap bitmap, List<Point> points) {
// a canvas for drawing on the bitmap
Canvas canvas = new Canvas(bitmap);
// a paint to describe how points are drawn
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
float radius = 4f;
// draw points
for(Point point : points) {
canvas.drawCircle(point.x, point.y, radius, paint);
}
// the bitmap has now been updated
}
这可以根据您接收点的方式以及点的显示方式(大小,颜色,形状等)进行更改。
对于实时绘图,您可能希望缓存Paint对象。