Edit text in frame android

主宰稳场 提交于 2020-06-13 09:19:19

问题


How to make it "Bold" and change color ? somebody can help me ? I try many times but still not working.

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

回答1:


Read the documentation: you have parameters for both of them.

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.

Then:

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)
) 


来源:https://stackoverflow.com/questions/37445202/edit-text-in-frame-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!