Ask Your Question

Revision history [back]

This worked for me, the java method getTextSize() is from "org.bytedeco.opencv.global.opencv_imgproc"


int baseline[]={0};
Size textSize=getTextSize("Hello World", FONT_HERSHEY_DUPLEX, 1,1,baseline);
int textwidth=textSize.get(0);
int textheight=textSize.get(1);
rectangle(yourMat, new Point(x1 + 2, y2 - 2), new Point(x1 + 2+textwidth, y2 - 2-textheight),RGB(255,255,0), FILLED,0,0);