在图像上叠加文本的程序会产生无穷无尽的字符串错误

时间:2017-08-10 06:38:52

标签: c++ string scope char

我写了一个短程序来覆盖图像上的文字:

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void drawMM( const cv::Mat mm, std::string mCap ){
     //Input output windows
     cv::namedWindow( "Example2_5-out", cv::WINDOW_AUTOSIZE );
     //Input window
     cv::imshow( "Example2_5-in", mm );
     //The Holder of Output(Copyright 2009 Holders Series)
     cv::Mat out = mm.clone();
     //Smoothing 
     cv::putText(out, mCap, cv::Point(40,200), cv::FONT_HERSHEY_PLAIN, 2.0, 255, 2);
     //Show the output image.
     cv::imshow( "Example2_5-out", out);
     //Wait.
     cv::waitKey( 0 );     

}

void inStr(int argc, char* argv[]){

     if (argc == 1)
     {
         string st = "If your boyfriend dosn't know what this is.";
         cout << st << endl;
     }else{
         string st = argv[1];
         cout << st << endl;
     }
}

int main(int argc, char *argv[]) {
    string mT << inStr() << endl;
    cv::Mat img = cv::imread(argv[1]);
    drawMM(img, mT);
    return 0;
}

但不管我做什么,每次我尝试编译它时都会遇到两个错误:

  1. 意外的令牌:
  2. CMG--00.cpp:39:15: error: expected initialiser before ‘<<’ token string mT << inStr() << endl;

    1. 未申报的范围:
    2. CMG--00.cpp:41:17: error: ‘mT’ was not declared in this scope drawMM(img, mT);

      谁能告诉我我做错了什么?

0 个答案:

没有答案