mirror of
https://github.com/dgirardeau/q3DMASC.git
synced 2026-08-29 08:34:48 +08:00
use num_threads instead of omp_set_num_threads
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ if (PLUGIN_STANDARD_3DMASC)
|
|||||||
project( Q3DMASC_PLUGIN )
|
project( Q3DMASC_PLUGIN )
|
||||||
|
|
||||||
AddPlugin( NAME ${PROJECT_NAME} )
|
AddPlugin( NAME ${PROJECT_NAME} )
|
||||||
set(Q3DMASC_PLUGIN_VERSION "0.12")
|
set(Q3DMASC_PLUGIN_VERSION "0.12+")
|
||||||
|
|
||||||
include( CMakePolicies NO_POLICY_SCOPE )
|
include( CMakePolicies NO_POLICY_SCOPE )
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,10 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
|||||||
if (!scaled() && !sfWasAlreadyExisting) //with 'kNN' neighbors, we can compute the values right away
|
if (!scaled() && !sfWasAlreadyExisting) //with 'kNN' neighbors, we can compute the values right away
|
||||||
{
|
{
|
||||||
unsigned pointCount = corePoints.size();
|
unsigned pointCount = corePoints.size();
|
||||||
QString logMessage = QString("Computing %1 on cloud %2 with context cloud %3\n(core points: %4)").arg(typeStr).arg(corePoints.cloud->getName()).arg(cloud1Label).arg(pointCount);
|
QString logMessage = "Computing " + typeStr
|
||||||
|
+ " on cloud " + corePoints.cloud->getName() + " (" + QString::number(pointCount) + " points)"
|
||||||
|
+ " with context cloud " + cloud1Label
|
||||||
|
+ " (class " + QString::number(ctxClassLabel) + ")";
|
||||||
|
|
||||||
//first: look for the number of points in the relevent class
|
//first: look for the number of points in the relevent class
|
||||||
const ScalarType fClass = static_cast<ScalarType>(ctxClassLabel);
|
const ScalarType fClass = static_cast<ScalarType>(ctxClassLabel);
|
||||||
@@ -165,7 +168,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//compute the octree
|
//compute the octree
|
||||||
ccLog::Print(QString("Computing octree of class %1 points (%2 points)").arg(ctxClassLabel).arg(classCount));
|
ccLog::Print(QString("Computing octree of class %1 (%2 points)").arg(ctxClassLabel).arg(classCount));
|
||||||
ccOctree::Shared classOctree = classCloud.computeOctree(progressCb);
|
ccOctree::Shared classOctree = classCloud.computeOctree(progressCb);
|
||||||
if (!classOctree)
|
if (!classOctree)
|
||||||
{
|
{
|
||||||
@@ -191,8 +194,7 @@ bool ContextBasedFeature::prepare( const CorePoints& corePoints,
|
|||||||
bool cancelled = false;
|
bool cancelled = false;
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
omp_set_num_threads(std::max(1, omp_get_max_threads() - 2));
|
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
||||||
|
|||||||
+1
-2
@@ -424,8 +424,7 @@ static bool ComputeMathOpWithNearestNeighbor( const CorePoints& corePoints,
|
|||||||
error.clear();
|
error.clear();
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
omp_set_num_threads(std::max(1, omp_get_max_threads() - 2));
|
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
||||||
|
|||||||
+1
-1
@@ -372,7 +372,7 @@ void q3DMASCPlugin::doTrainAction()
|
|||||||
masc::TrainParameters tempParams;
|
masc::TrainParameters tempParams;
|
||||||
if (!masc::Tools::LoadTrainingFile(inputFilename, featuresTest, scalesTest, loadedCloudsTest, tempParams))
|
if (!masc::Tools::LoadTrainingFile(inputFilename, featuresTest, scalesTest, loadedCloudsTest, tempParams))
|
||||||
{
|
{
|
||||||
m_app->dispToConsole("Failed to load the training file (for test)", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
|
m_app->dispToConsole("Failed to load the training file (for TEST)", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,8 +204,7 @@ bool Classifier::classify( const Feature::Source::Set& featureSources,
|
|||||||
int numberOfTrees = static_cast<int>(m_rtrees->getRoots().size());
|
int numberOfTrees = static_cast<int>(m_rtrees->getRoots().size());
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
omp_set_num_threads(std::max(1, omp_get_max_threads() - 2));
|
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < static_cast<int>(cloud->size()); ++i)
|
for (int i = 0; i < static_cast<int>(cloud->size()); ++i)
|
||||||
|
|||||||
+10
-9
@@ -1223,20 +1223,21 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
unsigned char octreeLevel = octree->findBestLevelForAGivenNeighbourhoodSizeExtraction(largestRadius);
|
unsigned char octreeLevel = octree->findBestLevelForAGivenNeighbourhoodSizeExtraction(largestRadius);
|
||||||
|
|
||||||
unsigned pointCount = corePoints.size();
|
unsigned pointCount = corePoints.size();
|
||||||
QString logMessage = QString("Computing %1 features on cloud %2\n(core points: %3)").arg(fas.featureCount).arg(sourceCloud->getName()).arg(pointCount);
|
QString logMessage = QString("Computing %1 features on cloud %2 (%3 core points)").arg(fas.featureCount).arg(sourceCloud->getName()).arg(pointCount);
|
||||||
if (progressCb)
|
if (progressCb)
|
||||||
{
|
{
|
||||||
progressCb->setMethodTitle("Compute features");
|
progressCb->setMethodTitle("Compute features");
|
||||||
progressCb->setInfo(qPrintable(logMessage));
|
progressCb->setInfo(qPrintable(logMessage));
|
||||||
}
|
}
|
||||||
ccLog::Print(logMessage);
|
ccLog::Print(logMessage + " , nb threads " + QString::number(omp_get_max_threads() - 2) + ", nb points " + QString::number(pointCount));
|
||||||
CCCoreLib::NormalizedProgress nProgress(progressCb, pointCount);
|
CCCoreLib::NormalizedProgress nProgress(progressCb, pointCount);
|
||||||
|
nProgress.reset();
|
||||||
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
omp_set_num_threads(std::max(1, omp_get_max_threads() - 2));
|
#pragma omp parallel for num_threads(std::max(1, omp_get_max_threads() - 2))
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
for (int i = 0; i < static_cast<int>(pointCount); ++i)
|
||||||
@@ -1372,10 +1373,10 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} //for each scale
|
|
||||||
|
|
||||||
|
} //for each scale
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressCb)
|
if (progressCb)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@@ -1385,15 +1386,15 @@ bool Tools::PrepareFeatures(const CorePoints& corePoints, Feature::Set& features
|
|||||||
{
|
{
|
||||||
//process cancelled by the user
|
//process cancelled by the user
|
||||||
ccLog::Warning("Process cancelled");
|
ccLog::Warning("Process cancelled");
|
||||||
errorStr = "Process cancelled";
|
errorStr = "Process cancelled, iteration " + QString::number(i);
|
||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //for each point
|
} //for each point
|
||||||
|
|
||||||
} //for each cloud
|
} //for each cloud
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Feature::Shared& feature : features)
|
for (const Feature::Shared& feature : features)
|
||||||
|
|||||||
+2
-2
@@ -56,8 +56,8 @@ namespace masc
|
|||||||
|
|
||||||
static bool SaveClassifier(QString filename, const Feature::Set& features, const QString corePointsRole, const masc::Classifier& classifier, QWidget* parent = nullptr);
|
static bool SaveClassifier(QString filename, const Feature::Set& features, const QString corePointsRole, const masc::Classifier& classifier, QWidget* parent = nullptr);
|
||||||
|
|
||||||
static bool PrepareFeatures(const CorePoints& corePoints, Feature::Set& features, QString& error,
|
static bool PrepareFeatures(const CorePoints& corePoints, Feature::Set& features, QString& error,
|
||||||
CCCoreLib::GenericProgressCallback* progressCb = nullptr, SFCollector* generatedScalarFields = nullptr);
|
CCCoreLib::GenericProgressCallback* progressCb = nullptr, SFCollector* generatedScalarFields = nullptr);
|
||||||
|
|
||||||
static bool RandomSubset(ccPointCloud* cloud, float ratio, CCCoreLib::ReferenceCloud* inRatioSubset, CCCoreLib::ReferenceCloud* outRatioSubset);
|
static bool RandomSubset(ccPointCloud* cloud, float ratio, CCCoreLib::ReferenceCloud* inRatioSubset, CCCoreLib::ReferenceCloud* outRatioSubset);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user