android - 在Android框架中编辑文本

标签 android opencv image-processing text

如何使其“加粗”并改变颜色?有人可以帮助我吗?我尝试了很多次,但仍然无法正常工作。

Core.putText(mRgba, "Result : " +
            	contours.size(), new org.opencv.core.Point(0, 300),
            	Core.FONT_HERSHEY_SIMPLEX, 2.6f, new Scalar(255, 255, 0))         

最佳答案

Read the documentation:两者都有参数。

public static void putText(Mat img,
    java.lang.String text,
    Point org,
    int fontFace,
    double fontScale,
    Scalar color,
    int thickness)

Parameters:

  • img - Image.

  • text - Text string to be drawn.

  • org - Bottom-left corner of the text string in the image. fontFace - Font type. One of FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN, FONT_HERSHEY_DUPLEX, FONT_HERSHEY_COMPLEX, FONT_HERSHEY_TRIPLEX, FONT_HERSHEY_COMPLEX_SMALL, FONT_HERSHEY_SCRIPT_SIMPLEX, or FONT_HERSHEY_SCRIPT_COMPLEX, where each of the font ID's can be combined with FONT_ITALIC to get the slanted letters.

  • fontScale - Font scale factor that is multiplied by the font-specific base size.

  • color - Text color.

  • thickness - Thickness of the lines used to draw a text.



然后:
Core.putText(mRgba, 
    "Result : " + contours.size(),         
    new org.opencv.core.Point(0, 300),    
    Core.FONT_HERSHEY_SIMPLEX,         
    2.6f,                             
    new Scalar(255, 255, 0), // color in BGR format, you should change this one
    2 // thickness (can be used to achieve bold)
) 

关于android - 在Android框架中编辑文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37445202/

相关文章:

Android - Gradle : error: package does not exist

android - Kotlin DSL 构建脚本依赖更新

image - Matlab的bwlabel,regionprops & centroid函数解释

c++ - 按质量/连通性对像素进行分组以进行图像处理 (OpenCV)

android - WebView 不会在 Lollipop 设备上显示 JSAlert

Android - Listview行内容的垂直对齐

python opencv matchTemplate 是否实现了掩码功能?

c++ - 如何使用 opencv 禁用网络摄像头的自动对焦

opencv - 如何从视差图中提取 v 视差图

algorithm - 如何使用 Opencv 存储大量图像的分层 K-Means 树?