I am bulding a PCL based application, for which use the default PCL grabber code for velodyne which can seen here.
When i build my application in Debug mode it's working as per the expectations, but in Release build, clouds are etting skipped and i loose one or two clouds. I narrowed down to the fact that there is some issue with the mutex which i have no experience with.
// Retrieved Point Cloud Callback Function
boost::mutex mutex;
boost::function<void(const pcl::PointCloud<PointType>::ConstPtr&)> function =[&cloud, &mutex](const pcl::PointCloud<PointType>::ConstPtr& ptr)
{
boost::mutex::scoped_lock lock(mutex);
// Point Cloud Processing
cloud = ptr;
};
this is the call back for receiving my cloud and the below part is the one in main
while (!viewer->wasStopped())
{
viewer->spinOnce(); // Update Viewer
tStart = clock();
boost::mutex::scoped_try_lock lock(mutex);
I couldn't figure out why there is difference in release vs debug. Any suggestions? I use Visual Studio 2017 and PCL 1.8.1.