你好,我想找到的是一种为ROI获得正确文本比例的方法.还应根据插入文本的大小来控制比例值.
简单来说,我想找到的是函数"getTextScale"或类似的东西:
std::String text = "Huhu";
int fontface = cv::FONT_HERSHEY_PLAIN;
int thickness = 2;
int baseline = 0;
cv::Size sz(500,200);
double fontScale = cv::getTextScale(text, fontFace, thickness, &baseline,sz);
Run Code Online (Sandbox Code Playgroud)
在此计算之后cv :: getTextSize(text,fontFace,fontScale,thickness和&baseline); 将检索与sz类似的值.有opencv这个功能吗?
- 编辑 -
我发现opencv中的cv :: getTextSize如下所示:
Size getTextSize( const string& text, int fontFace, double fontScale, int thickness, int* _base_line)
{
Size size;
double view_x = 0;
const char **faces = cv::g_HersheyGlyphs;
const int* ascii = getFontData(fontFace);
int base_line = (ascii[0] & 15);
int cap_line = (ascii[0] >> 4) & …Run Code Online (Sandbox Code Playgroud) 你好,我有一个关于opencv的基本问题.如果我尝试使用cv :: Mat类分配内存,我可以执行以下操作:
cv::Mat sumimg(rows,cols,CV_32F,0);
float* sumimgrowptr = sumimg.ptr<float>(0);
Run Code Online (Sandbox Code Playgroud)
但后来我得到了一个糟糕的指针(Null).在互联网上,有人使用这个:
cv::Mat* ptrsumimg = new cv::Mat(rows,cols,CV_32F,0);
float* sumimgrowptr = ptrsumimg->ptr<float>(0);
Run Code Online (Sandbox Code Playgroud)
而且在这里我得到一个Null指针!但如果我最终这样做:
cv::Mat sumimg;
sumimg.create(rows,cols,CV_32F);
sumimg.setTo(0);
float* sumimgrowptr = sumimg.ptr<float>(0);
Run Code Online (Sandbox Code Playgroud)
那一切都很好!所以我想知道我在做什么是错的?