Skip to content

Commit 0dca4d6

Browse files
author
Stefan Hahmann
committed
Add cancellation support in DeepLearningDetector by implementing a dummy detector workaround
1 parent fc4a0ac commit 0dca4d6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/java/org/mastodon/mamut/detection/DeepLearningDetector.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import org.mastodon.mamut.model.ModelGraph;
4747
import org.mastodon.mamut.util.ImgUtils;
4848
import org.mastodon.mamut.util.LabelImageUtils;
49+
import org.mastodon.tracking.detection.AbstractDetectorOp;
50+
import org.mastodon.tracking.detection.DetectionCreatorFactory;
4951
import org.mastodon.tracking.detection.DetectionUtil;
5052
import org.mastodon.tracking.detection.DetectorKeys;
5153
import org.mastodon.tracking.mamut.detection.AbstractSpotDetectorOp;
@@ -301,4 +303,22 @@ public Map< String, Object > getDefaultSettings()
301303
protected abstract void addSpecificDefaultSettings( final Map< String, Object > defaultSettings );
302304

303305
protected abstract String getDetectorName();
306+
307+
/** Cancels the command execution, with the given reason for doing so. */
308+
@Override
309+
public void cancel( final String reason )
310+
{
311+
// this is a workaround to avoid a null pointer exception during the cancel operation
312+
detector = new DummyDetectorOp();
313+
super.cancel( reason );
314+
}
315+
316+
private class DummyDetectorOp extends AbstractDetectorOp
317+
{
318+
@Override
319+
public void mutate1( final DetectionCreatorFactory arg, final List< SourceAndConverter< ? > > in )
320+
{
321+
// Do nothing
322+
}
323+
}
304324
}

0 commit comments

Comments
 (0)