Skip to content

Commit 48014e7

Browse files
committed
Require nThreads to be a sane value
1 parent 354592d commit 48014e7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/ComponentLabeling.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void myCompLabeler::Label()
3232
w = binaryImage.size().width;
3333
CBlobContour* label=NULL;
3434
for(r=startPoint.y;r<endPoint.y;r++){
35+
printf("%d\n", r);
3536
//First col
3637
pos = r*w;
3738
c=startPoint.x;
@@ -454,6 +455,9 @@ myCompLabelerGroup::~myCompLabelerGroup()
454455

455456
void myCompLabelerGroup::set( int nThreads, Mat binIm )
456457
{
458+
if (nThreads <= 0) {
459+
nThreads = 1;
460+
}
457461
this->numThreads=nThreads;
458462
if(binIm.isContinuous()){
459463
this->img=binIm;
@@ -478,7 +482,7 @@ void myCompLabelerGroup::set( int nThreads, Mat binIm )
478482
delete []labelers;
479483
}
480484
tIds = new pthread_t[nThreads];
481-
labelers = new myCompLabeler*[nThreads];
485+
labelers = new myCompLabeler*[nThreads > 0? nThreads : 1];
482486
Size sz = binIm.size();
483487
int numPx = sz.width*sz.width;
484488
int i=0;

0 commit comments

Comments
 (0)