OpenCV PCL和Cmake

时间:2018-08-25 09:11:23

标签: c++ opencv point-cloud-library

我想使用cmake生成有关PCL和OpenCV的项目。

运行项目时,发现以下错误:

  

LNK2038:检测到'runtimelibrary'值'MTd_StaticDebug'不匹配,与main.obj中的'MDd_DynamicDebug'不匹配

我尝试通过以下方法来纠正此错误:进入“项目属性”(和/或您正在使用的库的属性),然后进入C / C ++,然后是“代码生成”,然后检查“运行时库”的值,但是没有工作。

 #include <pcl/visualization/cloud_viewer.h>
 #include <iostream>
 #include <pcl/io/io.h>
 #include <pcl/io/pcd_io.h>
 #include <opencv2/opencv.hpp>
 int user_data;

 void viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(0.0, 0.0, 0.0);
}

void viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
user_data = 9;
}

int main()
{
pcl::PointCloud<pcl::PointXYZRGB> cloud_a;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new   pcl::PointCloud<pcl::PointXYZRGB>);


cv::Mat image = cv::imread("person.jpg");

int rowNumber = image.rows;
int colNumber = image.cols;

cloud_a.width = rowNumber;
cloud_a.height = colNumber;
cloud_a.points.resize(cloud_a.width*cloud_a.height);

cv::Mat_<cv::Vec3b>::iterator it = image.begin<cv::Vec3b>();
cv::Mat_<cv::Vec3b>::iterator itend = image.end<cv::Vec3b>();

for (unsigned int i = 0; i<cloud_a.points.size(); ++i)
{
    cloud_a.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
    cloud_a.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
    cloud_a.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);

    cloud_a.points[i].r = (int)(*it)[2];
    cloud_a.points[i].g = (int)(*it)[1];
    cloud_a.points[i].b = (int)(*it)[0];

    ++it;
}

*cloud = cloud_a;

pcl::visualization::CloudViewer viewer("Cloud Viewer");

viewer.showCloud(cloud);

viewer.runOnVisualizationThreadOnce(viewerOneOff);

viewer.runOnVisualizationThread(viewerPsycho);

while (!viewer.wasStopped())
{
    user_data = 9;
}

return 0;
}

0 个答案:

没有答案