Bitmap icon = BitmapFactory.decodeResource(getResources(), drawableID);
Mat mat = new Mat();
Bitmap bmp32 = icon.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(bmp32, mat);
Point position = new Point(300, 300);
Scalar color = new Scalar(255.0, 0.0, 0.0);
int font = Imgproc.FONT_HERSHEY_SIMPLEX;
int scale = 1;
int thickness = 3;
//Adding text to the image
Imgproc.cvtColor(mat2, mat, 1, 4);
Imgproc.putText(mat, "98.452", position, font, scale, color, thickness);
int baseline[] = {0};
Size textSize = Imgproc.getTextSize("98.452", Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, 3, baseline);
//Drawing a Circle
Imgproc.circle(
mat, //Matrix obj of the image
new Point(300 + textSize.width+20, 300 -(textSize.height+20)), //Center of the circle
7, //Radius
new Scalar(255.0, 0.0, 0.0), //Scalar object for color
3 //Thickness of the circle
);
Imgproc.putText(mat, "F", new Point(300 + (textSize.width+textSize.height), 300), font, scale, color, thickness);
Bitmap output = Bitmap.createBitmap(bmp32.getWidth(), bmp32.getHeight(), bmp32.getConfig());
Utils.matToBitmap(mat, output);
return output;
}
3条答案
按热度按时间bakd9h0s1#
我在OpenCV中找不到任何方法来支持度符号(º)特殊字符。请评论,如果有人发现任何方法相同。我已经解决了上述问题,画了一个圆圈来代替度数符号(º)。请在下面找到代码:
private setImageWithText(ImageView imageView){
amrnrhlw2#
因为你使用的是Android,所以 Backbone.js 不可避免地是Java。尝试在字符串中使用Unicode
\u00B0
,然后将其写入图像。ryoqjall3#