gpt4 book ai didi

c++ - openCV 'cvPoint' 和 'CV_FONT_HERSHEY_SIMPLEX' 未在此范围内声明

转载 作者:太空宇宙 更新时间:2023-11-03 22:07:23 26 4
gpt4 key购买 nike

我正在尝试获取 LSD-SLAM凯文·乔治。
但是我卡住了,因为 openCV 不想合作,并且在使用 catkin_make 时它不知道以下两件事。

/home/adas/ros_workspace/src/src/lsd_slam/lsd_slam_core/src/util/globalFuncs.cpp: In function ‘void lsd_slam::printMessageOnCVImage(cv::Mat&, std::__cxx11::string, std::__cxx11::string)’:
/home/adas/ros_workspace/src/src/lsd_slam/lsd_slam_core/src/util/globalFuncs.cpp:52:28: error: ‘cvPoint’ was not declared in this scope
cv::putText(image, line2, cvPoint(10,image.rows-5),
^~~~~~~
/home/adas/ros_workspace/src/src/lsd_slam/lsd_slam_core/src/util/globalFuncs.cpp:52:28: note: suggested alternative: ‘cvRound’
cv::putText(image, line2, cvPoint(10,image.rows-5),
^~~~~~~
cvRound

/home/adas/ros_workspace/src/src/lsd_slam/lsd_slam_core/src/util/globalFuncs.cpp:53:6: error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
CV_FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(200,200,250), 1, 8);

在 cvPoint catkin_make 的情况下,建议将 cvPoint 替换为 cvRount 这不起作用,因为然后我收到一个新错误,该类型的函数不能被发现。

如果对您有帮助,这里是完整的源代码。

/**
* This file is part of LSD-SLAM.
*
* Copyright 2013 Jakob Engel <engelj at in dot tum dot de> (Technical University of Munich)
* For more information see <http://vision.in.tum.de/lsdslam>
*
* LSD-SLAM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSD-SLAM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSD-SLAM. If not, see <http://www.gnu.org/licenses/>.
*/

#include "util/globalFuncs.h"
#include "util/SophusUtil.h"
#include "opencv2/opencv.hpp"
#include "DataStructures/Frame.h"

namespace lsd_slam
{


SE3 SE3CV2Sophus(const cv::Mat &R, const cv::Mat &t)
{
Sophus::Matrix3f sR;
Sophus::Vector3f st;

for(int i=0;i<3;i++)
{
sR(0,i) = R.at<double>(0,i);
sR(1,i) = R.at<double>(1,i);
sR(2,i) = R.at<double>(2,i);
st[i] = t.at<double>(i);
}

return SE3(toSophus(sR.inverse()), toSophus(st));
}

void printMessageOnCVImage(cv::Mat &image, std::string line1,std::string line2)
{
for(int x=0;x<image.cols;x++)
for(int y=image.rows-30; y<image.rows;y++)
image.at<cv::Vec3b>(y,x) *= 0.5;

cv::putText(image, line2, cvPoint(10,image.rows-5),
CV_FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(200,200,250), 1, 8);

cv::putText(image, line1, cvPoint(10,image.rows-18),
CV_FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(200,200,250), 1, 8);
}


cv::Mat getDepthRainbowPlot(Frame* kf, int lvl)
{
return getDepthRainbowPlot(kf->idepth(lvl), kf->idepthVar(lvl), kf->image(lvl),
kf->width(lvl), kf->height(lvl));
}

cv::Mat getDepthRainbowPlot(const float* idepth, const float* idepthVar, const float* gray, int width, int height)
{
cv::Mat res = cv::Mat(height,width,CV_8UC3);
if(gray != 0)
{
cv::Mat keyFrameImage(height, width, CV_32F, const_cast<float*>(gray));
cv::Mat keyFrameImage8u;
keyFrameImage.convertTo(keyFrameImage8u, CV_8UC1);
cv::cvtColor(keyFrameImage8u, res, cv::COLOR_GRAY2RGB);
}
else
fillCvMat(&res,cv::Vec3b(255,170,168));

for(int i=0;i<width;i++)
for(int j=0;j<height;j++)
{
float id = idepth[i + j*width];

if(id >=0 && idepthVar[i + j*width] >= 0)
{

// rainbow between 0 and 4
float r = (0-id) * 255 / 1.0; if(r < 0) r = -r;
float g = (1-id) * 255 / 1.0; if(g < 0) g = -g;
float b = (2-id) * 255 / 1.0; if(b < 0) b = -b;

uchar rc = r < 0 ? 0 : (r > 255 ? 255 : r);
uchar gc = g < 0 ? 0 : (g > 255 ? 255 : g);
uchar bc = b < 0 ? 0 : (b > 255 ? 255 : b);

res.at<cv::Vec3b>(j,i) = cv::Vec3b(255-rc,255-gc,255-bc);
}
}
return res;
}
cv::Mat getVarRedGreenPlot(const float* idepthVar, const float* gray, int width, int height)
{
float* idepthVarExt = (float*)Eigen::internal::aligned_malloc(width*height*sizeof(float));

memcpy(idepthVarExt,idepthVar,sizeof(float)*width*height);

for(int i=2;i<width-2;i++)
for(int j=2;j<height-2;j++)
{
if(idepthVar[(i) + width*(j)] <= 0)
idepthVarExt[(i) + width*(j)] = -1;
else
{
float sumIvar = 0;
float numIvar = 0;
for(int dx=-2; dx <=2; dx++)
for(int dy=-2; dy <=2; dy++)
{
if(idepthVar[(i+dx) + width*(j+dy)] > 0)
{
float distFac = (float)(dx*dx+dy*dy)*(0.075*0.075)*0.02;
float ivar = 1.0f/(idepthVar[(i+dx) + width*(j+dy)] + distFac);
sumIvar += ivar;
numIvar += 1;
}
}
idepthVarExt[(i) + width*(j)] = numIvar / sumIvar;
}

}


cv::Mat res = cv::Mat(height,width,CV_8UC3);
if(gray != 0)
{
cv::Mat keyFrameImage(height, width, CV_32F, const_cast<float*>(gray));
cv::Mat keyFrameImage8u;
keyFrameImage.convertTo(keyFrameImage8u, CV_8UC1);
cv::cvtColor(keyFrameImage8u, res, cv::COLOR_GRAY2RGB);
}
else
fillCvMat(&res,cv::Vec3b(255,170,168));

for(int i=0;i<width;i++)
for(int j=0;j<height;j++)
{
float idv = idepthVarExt[i + j*width];

if(idv > 0)
{
float var= sqrt(idv);

var = var*60*255*0.5 - 20;
if(var > 255) var = 255;
if(var < 0) var = 0;

res.at<cv::Vec3b>(j,i) = cv::Vec3b(0,255-var, var);
}
}

Eigen::internal::aligned_free((void*)idepthVarExt);

return res;
}
}

这里还有一些我安装的信息,可能对我有帮助:

  • openCV 4.1.1-pre
  • ROS 旋律
  • Ubuntu 18.04
  • CMake 3.10.2
  • CatKin_tools 0.4.5
  • python 3.6.8

希望有人能帮助我。

最佳答案

不要将过时的 C api 与 C++ api 混合使用。使用 cv::Point 而不是 cvPoint,使用 cv::FONT_HERSHEY_SIMPLEX 而不是 CV_FONT_HERSHEY_SIMPLEX,例如:

cv::putText(image, line1, cv::Point(10,image.rows-18),
cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(200,200,250), 1, 8);

关于c++ - openCV 'cvPoint' 和 'CV_FONT_HERSHEY_SIMPLEX' 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57053358/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com