解决error: ‘CvFont’ was not declared in this scope 225 | CvFont font;的问题

解决如下问题:

error: ‘CvFont’ was not declared in this scope
  225 |   CvFont font;
      |   ^~~~~~
/home/kilox/workspace/kilox/slam/ws_stargazer/src/Stargazer/lidar_slam/src/pcl_common.cpp:226:15: error: ‘font’ was not declared in this scope
  226 |   cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 2, 8);
      |               ^~~~
/home/kilox/workspace/kilox/slam/ws_stargazer/src/Stargazer/lidar_slam/src/pcl_common.cpp:226:21: error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
  226 |   cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 2, 8);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~
/home/kilox/workspace/kilox/slam/ws_stargazer/src/Stargazer/lidar_slam/src/pcl_common.cpp:226:3: error: ‘cvInitFont’ was not declared in this scope
  226 |   cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 2, 8);
      |   ^~~~~~~~~~
/home/kilox/workspace/kilox/slam/ws_stargazer/src/Stargazer/lidar_slam/src/pcl_common.cpp:228:33: error: ‘cvPoint’ was not declared in this scope
  228 |   cv::putText(mat_bg, msg_info, cvPoint(10, 30), cv::FONT_HERSHEY_PLAIN, 1.5, cvScalar(255, 255, 255), 1);
      |                                 ^~~~~~~
/home/kilox/workspace/kilox/slam/ws_stargazer/src/Stargazer/lidar_slam/src/pcl_common.cpp:228:79: error: ‘cvScalar’ was not declared in this scope; did you mean ‘tfScalar’?
  228 |   cv::putText(mat_bg, msg_info, cvPoint(10, 30), cv::FONT_HERSHEY_PLAIN, 1.5, cvScalar(255, 255, 255), 1);

解决方法:

在报错的cpp文件中添加如下头文件,即可解决报错

#include "opencv2/imgproc/imgproc_c.h"

你可能感兴趣的:(opencv,c++)