Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear Segemntation won't work #3099

Closed
edmondboulet opened this issue May 24, 2019 · 17 comments
Closed

Linear Segemntation won't work #3099

edmondboulet opened this issue May 24, 2019 · 17 comments

Comments

@edmondboulet
Copy link

Hello,

I tried using Line fitting using Ransac but I keep having the same issue regardless of how the method is called.

Your Environment

  • Operating System and version: Windows 10
  • Compiler: Visual Studio 2017
  • PCL Version: 1.9.1

Context

I have the following point cloud :

Photo1

Photo 2

But I'm also testing with this point cloud :

photo 3

Expected Behavior

Ans you can guess these are the walls of a room projected onto the XY plan, and my goal was to perform a segmentation by line to get the coefficient of the walls orientation.
So my goal is to have a line for each part of walls with their model coefficient.

Current Behavior

when I try to get the to perform a linear segmentation i get the following result :

PointCloud input for line segmentation: 22394 data points. [pcl::RandomSampleConsensus::computeModel] No samples could be selected! [pcl::SACSegmentation::segment] Error segmenting the model! No solution found. Could not estimate a linear model for the given dataset. Unused Point Cloud of : 22394 data points. Line Segmentation Done.

Code to Reproduce

I've tried with this implementation :

  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
   pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
   // Create the segmentation object
   pcl::SACSegmentation<pcl::PointXYZ> seg;
   // Optional
   seg.setOptimizeCoefficients (true);
   // Mandatory
   seg.setModelType (pcl::SACMODEL_LINE);
   seg.setMethodType (pcl::SAC_RANSAC);
   seg.setDistanceThreshold (0.01);

   seg.setInputCloud (cloud);
   seg.segment (*inliers, *coefficients); 

But also this one :

 pcl::SampleConsensusModelLine<pcl::PointXYZ>::Ptr
model_l(new pcl::SampleConsensusModelLine<pcl::PointXYZ>(cloud));
 std::vector<int> inliers;
std::vector<int> models;
pcl::RandomSampleConsensus<pcl::PointXYZ> seg(model_l);
seg.setDistanceThreshold(0.01); 
seg.computeModel();
seg.getInliers(inliers);
seg.getModel(models);

and I played with the DistanceThreshold parameter but nothing worked.

Is it a bug or am I missing something ?
thanks for the answers.

@SergioRAgostinho
Copy link
Member

I see at least one PR that has been merged since 1.9.1 fixing a regression with line segmentation #2767. Would you mind giving the current master a try?

@edmondboulet
Copy link
Author

Hello @SergioRAgostinho, thanks for answering.

I have been trying to compile the source code from the master branch but also those dependencies are a pain, I downloaded the branch and put all the 3rdParty libraries in my path pointing to my all-in-one installation directories so that Cmake can Generate properly.
But now visual studio can't build ALL_BUILD properly, saying :

========== Build: 47 succeeded, 112 failed, 0 up-to-date, 0 skipped ==========

and the errors are mostly :

145>D:\.........\pcl-master\kdtree\include\pcl/kdtree/kdtree_flann.h(44): fatal error C1083: Cannot open include file: 'flann/util/params.h': No such file or directory (compiling source file D:\Stage PC\PCLTest\pcl-master\tracking\src\coherence.cpp) 146>D:\.........\pcl-master\kdtree\include\pcl/kdtree/kdtree_flann.h(44): fatal error C1083: Cannot open include file: 'flann/util/params.h': No such file or directory 146>Done building project "pcl_train_linemod_template.vcxproj" -- FAILED.

with a lot others modules :

141>Done building project "pcl_surfel_smoothing_test.vcxproj" -- FAILED.

a lot...

137>Done building project "pcl_sac_segmentation_plane.vcxproj" -- FAILED. 134>Done building project "pcl_pyramid_surface_matching.vcxproj" -- FAILED.

Seems like there is something wrong with my FLANN..

is there a way to fix this ?
Will the next all-in-one installer be released soon ?

Thanks.

@SergioRAgostinho
Copy link
Member

is there a way to fix this ?

That looks messy indeed. Based on the errors you're having I would have expected CMake to not even get past the configuration stage. Once that gets through, there should be no more issues like the ones you have, otherwise our continuous integration builds would be failing as well.

Will the next all-in-one installer be released soon ?

You can follow #2772 too keep track of the release dates. Currently early July, but as you can see there's still a number of pending items to address, so the dates might derail.

@edmondboulet
Copy link
Author

Found the fix to the FANN issue :
Environment variables was getting overwritten by user variable who was pointing to fann and not fann/include.

Will test the linear segmentation tomorrow.

@edmondboulet
Copy link
Author

Update : I have 3 errors left that are preventing me to successfully install the current branch.

They concern :

  • pcl_kdtree.vcxproj
  • pcl_segmentation.vcxproj
  • pcl_registration.vcxproj

And, for pcl_segmentation.vcxproj for instace it goes :

3>unary_classifier.obj : error LNK2019: unresolved external symbol LZ4_decompress_safe referenced in function "private: void __cdecl flann::serialization::LoadArchive::decompressAndLoadV10(struct _iobuf *)" (?decompressAndLoadV10@LoadArchive@serialization@flann@@AEAAXPEAU_iobuf@@@z)
3>supervoxel_clustering.obj : error LNK2001: unresolved external symbol LZ4_decompress_safe
3>unary_classifier.obj : error LNK2019: unresolved external symbol LZ4_setStreamDecode referenced in function "private: void __cdecl flann::serialization::LoadArchive::initBlock(struct _iobuf *)" (?initBlock@LoadArchive@serialization@flann@@AEAAXPEAU_iobuf@@@z)
3>supervoxel_clustering.obj : error LNK2001: unresolved external symbol LZ4_setStreamDecode
3>unary_classifier.obj : error LNK2019: unresolved external symbol LZ4_decompress_safe_continue referenced in function "private: void __cdecl flann::serialization::LoadArchive::loadBlock(char *,unsigned __int64,struct _iobuf *)" (?loadBlock@LoadArchive@serialization@flann@@AEAAXPEAD_KPEAU_iobuf@@@z)
3>supervoxel_clustering.obj : error LNK2001: unresolved external symbol LZ4_decompress_safe_continue
3>unary_classifier.obj : error LNK2019: unresolved external symbol LZ4_resetStreamHC referenced in function "private: void __cdecl flann::serialization::SaveArchive::initBlock(void)" (?initBlock@SaveArchive@serialization@flann@@AEAAXXZ)
3>supervoxel_clustering.obj : error LNK2001: unresolved external symbol LZ4_resetStreamHC
3>unary_classifier.obj : error LNK2019: unresolved external symbol LZ4_compress_HC_continue referenced in function "private: void __cdecl flann::serialization::SaveArchive::flushBlock(void)" (?flushBlock@SaveArchive@serialization@flann@@AEAAXXZ)
3>supervoxel_clustering.obj : error LNK2001: unresolved external symbol LZ4_compress_HC_continue
3>D:\Stage PC\PCL\bin\pcl_segmentationd.dll : fatal error LNK1120: 5 unresolved externals
3>Done building project "pcl_segmentation.vcxproj" -- FAILED.

@edmondboulet
Copy link
Author

update, fixed some linkage issues, got some others :

With Boost :

thread module from Boost is not imported despite CMake clearly stating :

Found the following Boost libraries: system filesystem date_time iostreams serialization chrono thread

When I call :

boost::this_thread::sleep(boost::posix_time::microseconds(100000));

I get :

Error C3083 'this_thread': the symbol to the left of a '::' must be a type

With FLANN :

Error C1083 Cannot open source file: 'FLANN_STATIC': No such file or directory

For some reason...

Additional help is welcome.

@SergioRAgostinho
Copy link
Member

Boost

Worth noting, I recently stripped all mentions to the Boost.Thread from the master branch. Depending on your current checkout, this could be what you are witnessing. You either include Boost Thread explicitly in your downstream cmake project or you make use of the std equivalent.

FLANN
The second error is pretty clear. Where is it happening exactly?

@edmondboulet
Copy link
Author

Boost, what's the best alternative to boost::this_thread::sleep(boost::posix_time::microseconds(100000)); ?

I was using it to display my viewer like the tutorial uses it :

	//--------------------
	// -----Main loop-----
	//--------------------
	while (!viewer->wasStopped())
	{
		viewer->spinOnce(100);
		boost::this_thread::sleep(boost::posix_time::microseconds(100000));
	}

I was getting the FLANN error when compiling my own bit of code, fixed it by commenting this on the CMakeList :

if(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32)) set(FLANN_USE_STATIC ON) endif()

I guess not making it static solved the issue....

@edmondboulet
Copy link
Author

Manage to get my installation to launch, sadly reader makes it crash :

reader.read(PCDname, *cloud_blob);

I just get The thread 0x2d38 has exited with code 0 (0x0).

@SergioRAgostinho
Copy link
Member

Boost, what's the best alternative to boost::this_thread::sleep(boost::posix_time::microseconds(100000)); ?

#include <chrono>
#include <thread>

using namespace std::chrono_literals;

while (!viewer->wasStopped())
{
	viewer->spinOnce(100);
	std::this_thread::sleep_for(100ms);
}

I was getting the FLANN error when compiling my own bit of code, fixed it by commenting this on the CMakeList :

if(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32)) set(FLANN_USE_STATIC ON) endif()

I guess not making it static solved the issue....

I won't be able to comment much here. You are modifying things without really understanding the root problem.

Manage to get my installation to launch, sadly reader makes it crash :

reader.read(PCDname, *cloud_blob);

I just get The thread 0x2d38 has exited with code 0 (0x0).

Threads producing verbose complaints is often the result of threads not being joined before their object runs out of scope.

@edmondboulet
Copy link
Author

edmondboulet commented Jun 4, 2019

My bad, the reading on the disk was just taking some time.

Everything is working fine now, including linear segmentation, master branch isn't concerned by this issue anymore.

I'm closing this and thanks a lot @SergioRAgostinho for the help, sorry for spamming.

@SergioRAgostinho
Copy link
Member

Good to know 👍 Thanks for reporting.

@Archetype90
Copy link

@edmondboulet How did you fix the linker errors you mentioned on May 28th? I am seeing those exact same errors while trying to do a different task, but I am unsure how to resolve them.

@edmondboulet
Copy link
Author

@edmondboulet How did you fix the linker errors you mentioned on May 28th? I am seeing those exact same errors while trying to do a different task, but I am unsure how to resolve them.

Well I should have been more precise in y answer because I can't remember exactly, but most my errors was coming from bad PATH variable pointing to the wrong folder. Hope it helps.

@esteban-andrade
Copy link

@edmondboulet could you please shows us a hint on how to solve the environment value for Flann i havent been able to solve the issue.

Kind Regards,
image

@edmondboulet
Copy link
Author

Sorry, I really can't, it was long ago and I haven't done any CPL since.

@esteban-andrade
Copy link

Thank you anyway. Will have to switch back to ubuntu then.
If anyone founds a solutions, pls post it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants