Because you're using Android, the backbone is inevitably Java. Try using Unicode\°
inside your string, then write this to the image.
String degrees = "100\u00B0";
Imgproc.putText(img, degrees, ...);
I don't find any method in OpenCV to support degree symbol (º) Special Character. 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) {
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.