Open bellonemauro opened 7 years ago
I have made few modification on my local branch to solve this issue and also to add a couple of features to the svm_wrapper
I have also wrote a small test here :
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.
The PR has already pointed out the places where PCL_EXPORTS is needed. The issue will only be found on Windows, not Linux or MacOS due to default symbol visibility settings.
Hi bellonemauro, I started to learn PCL point cloud library recently, and found the same problem as you, but I failed to fix the error LNK2019 according to your solution. May I ask if the only lines of code to be modified are the ones posted by you? I really have no way out
Hi,
you can see those lines in this commit:
https://github.com/bellonemauro/pcl/commit/ff567d907c6a28b7edd082a8cdf848121039110c
also check the files svm.h/cpp and svm_wrapper.h/cpp for other modifications. I hope this helps. M.
Hi,
Thank you for your letter.
I modified the files svm.h and svm_wrapper.h according to what you said, but the IDE still gave an error to LNK2019, I was compiled and run under VS2017, Debug ×64 environment, do I need to rely on libsvm.lib file? Or some other lib file? I'm really at a loss.
I hope you can help me!
M.
------------------ 原始邮件 ------------------ 发件人: "PointCloudLibrary/pcl" @.>; 发送时间: 2021年4月7日(星期三) 凌晨1:55 @.>; @.**@.>; 主题: Re: [PointCloudLibrary/pcl] Support Vector Machine link error (#1726)
Hi,
you can see those lines in this commit:
@.***
also check the files svm.h/cpp and svm_wrapper.h/cpp for other modifications. I hope this helps. M.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
include
include
include <Eigen/Core>
include "pcl/point_types.h"
include "pcl/point_cloud.h"
include "pcl/io/pcd_io.h"
include <pcl/search/kdtree.h>
include <pcl/features/normal_3d_omp.h>
include <pcl/filters/voxel_grid.h>
include <pcl/features/vfh.h>
include <pcl/visualization/pcl_plotter.h>
include <pcl/ml/svm_wrapper.h>
int number(142); pcl::SVMParam param; int nrfold(0);
void
downsample(pcl::PointCloud
void
compute_surface_normals(pcl::PointCloud
// Use a KdTree to perform neighborhood searches
norm_est.setSearchMethod(pcl::search::KdTree<pcl::PointXYZ>::Ptr(new pcl::search::KdTree<pcl::PointXYZ>));
// Specify the size of the local neighborhood to use when computing the surface normals
norm_est.setRadiusSearch(normal_radius);
// Set the input points
norm_est.setInputCloud(points);
// Estimate the surface normals and store the result in "normals_out"
norm_est.compute(*normals_out);
}
void
compute_VFH_features(pcl::PointCloud
pcl::VFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::VFHSignature308> vfh_est;
vfh_est.setInputCloud(points);
vfh_est.setInputNormals(normals);
vfh_est.setSearchMethod(pcl::search::KdTree<pcl::PointXYZ>::Ptr(new pcl::search::KdTree<pcl::PointXYZ>));
vfh_est.setNormalizeBins(true);
// Also, we can normalize the SDC with the maximum size found between
// the centroid and any of the cluster's points.
vfh_est.setNormalizeDistance(false);
// std::cout << "start compute VFH features descriptors" << std::endl;
vfh_est.compute(*descriptors_out);
// std::cout << "Compute VFH descriptors successfully" << std::endl;
}
/ Function : output the .txt file for Libsvm use*/
void
write2file(pcl::PointCloud
void
write2svmdata(pcl::PointCloud
int main() { const char *modelFileName = "person_svm";
std::vector<pcl::SVMData> tranning_dataset;
for (int i = 0; i < (number_ + 1); i++)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr points1(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr downsampled1(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::Normal>::Ptr normals1(new pcl::PointCloud<pcl::Normal>);
pcl::PointCloud<pcl::VFHSignature308>::Ptr descriptors_vfh1(new pcl::PointCloud<pcl::VFHSignature308>);
std::stringstream ss0;
std::stringstream ss1, ss2;
//C://Users//QYQY//Desktop//np
ss1 << "C://Users//QYQY//Desktop//np//pedestrian" << i << ".pcd";
pcl::io::loadPCDFile(ss1.str(), *points1);
const float voxel_grid_leaf_size1 = 4.0;
downsample(points1, voxel_grid_leaf_size1, downsampled1);
const float normal_radius1 = 4.5;
compute_surface_normals(downsampled1, normal_radius1, normals1);
compute_VFH_features(downsampled1, normals1, descriptors_vfh1);
std::cout << "write features of model No." << i << std::endl;
// Store the VF histogram into the txt for libsvm input
write2svmdata(descriptors_vfh1, i, tranning_dataset);
}
std::cout << "All the SVM datas have been created" << std::endl;
// SVM trainning
pcl::SVMTrain Mytrainner;
Mytrainner.setParameters(param_);
Mytrainner.resetTrainingSet();
Mytrainner.setInputTrainingSet(tranning_dataset);
Mytrainner.trainClassifier();
Mytrainner.saveClassifierModel(modelFileName);
std::cout << "Output trainning model : " << modelFileName << std::endl;
return (0);
} //this is my code
Hi Developers,
I have worked a bit an SVM classifier test with PCL and I have few issues. The svm_wrapper gives me an error to link dlls in visual studio.
Here link error is reported.
Your Environment
Expected Behavior
NO link errors
Current Behavior
there is a link error when I try to build any object from the SMV class in visual studio in file svm_wrapper.h
No link error anymore
Possible Solution
I don't know if it is correct, but I have solved in my local code using PCL_EXPORTS in the following lines:
the same happen with functions called in svm.h
so here is my code to fix
Code to Reproduce
if you want to reproduce my error you can use the following code: cmakelists.txt
pcl_SVM_PCD_test.cpp
COMPILER ANSWER :
Context
Build a machine learning algorithm based on the SVM classifier. On my local code I have made few modifications, I can commit the changes in a branch and then check/pull if you are interested. I have prepared a tutorial on how to classify point clouds, just in case.