[英]How can I draw a degree symbol (º) Special Character on image using `cv2.putText` (Android +OpenCV)?
I have to draw a text with a special character(100 degrees) over the image in Android by using the OpenCV library.我必须使用 OpenCV 库在 Android 中的图像上绘制带有特殊字符(100 度)的文本。 Whenever I'll set text in putText function of OpenCV it's a show "100??".
每当我在 OpenCV 的 putText 函数中设置文本时,它都会显示“100??”。 So please suggest if we have any third party lib or any other way to do this.
所以请建议我们是否有任何第三方库或任何其他方式来做到这一点。
I don't find any method in OpenCV to support degree symbol (º) Special Character.我在 OpenCV 中找不到任何方法来支持度数符号 (º) 特殊字符。 Please comment if anyone finds any method for the same.
如果有人找到任何相同的方法,请发表评论。 I have resolved the above issue by drawing a circle in place of degree symbol (º).
我通过画一个圆圈代替度数符号 (º) 解决了上述问题。 Please find the code below:
请在下面找到代码:
private Bitmap setImageWithText(ImageView imageView) {私有位图 setImageWithText(ImageView imageView) {
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;
}
import cv2
import numpy as np
im = cv2.imread("image1.jpg")
im = cv2.circle(im, (70,80), 5, (255,100,0), 1)
im = cv2.putText(im, "100", (5,100), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,100,0), 1, cv2.LINE_AA)
cv2.imshow("pl", im)
cv2.waitKey(0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.