Merge pull request #4963 from dannysmyda/5225-Graceful-Object-Detection-Failure

5225 graceful object detection failure
This commit is contained in:
Richard Cordovano 2019-06-27 12:28:50 -04:00 committed by GitHub
commit d9c80ba14e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -3,5 +3,7 @@ ObjectDetectionFileIngestModule.classifierDetection.text=Classifier detected {0}
# {0} - classifierDir # {0} - classifierDir
ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed. ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed.
ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found. ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found.
ObjectDetectionFileIngestModule.notWindowsError=This module is only available on Windows.
ObjectDetectionFileIngestModule.openCVNotLoaded=OpenCV was not loaded, but is required to run.
ObjectDetectionModuleFactory.moduleDescription.text=Use object classifiers to identify objects in pictures. ObjectDetectionModuleFactory.moduleDescription.text=Use object classifiers to identify objects in pictures.
ObjectDetectionModuleFactory.moduleName.text=Object Detection ObjectDetectionModuleFactory.moduleName.text=Object Detection

View File

@ -65,14 +65,32 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter
private Blackboard blackboard; private Blackboard blackboard;
@Messages({"ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found.", @Messages({"ObjectDetectionFileIngestModule.noClassifiersFound.subject=No classifiers found.",
"# {0} - classifierDir", "ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed."}) "# {0} - classifierDir", "ObjectDetectionFileIngestModule.noClassifiersFound.message=No classifiers were found in {0}, object detection will not be executed.",
"ObjectDetectionFileIngestModule.openCVNotLoaded=OpenCV was not loaded, but is required to run.",
"ObjectDetectionFileIngestModule.notWindowsError=This module is only available on Windows."
})
@Override @Override
public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException { public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException {
jobId = context.getJobId(); jobId = context.getJobId();
File classifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath()); File classifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath());
classifiers = new HashMap<>(); classifiers = new HashMap<>();
if(!PlatformUtil.isWindowsOS()) {
//Pop-up that catches IngestModuleException will automatically indicate
//the name of the module before the message.
String errorMsg = Bundle.ObjectDetectionFileIngestModule_notWindowsError();
logger.log(Level.SEVERE, errorMsg);
throw new IngestModule.IngestModuleException(errorMsg);
}
if(!OpenCvLoader.hasOpenCvLoaded()) {
String errorMsg = Bundle.ObjectDetectionFileIngestModule_openCVNotLoaded();
logger.log(Level.SEVERE, errorMsg);
throw new IngestModule.IngestModuleException(errorMsg);
}
//Load all classifiers found in PlatformUtil.getObjectDetectionClassifierPath() //Load all classifiers found in PlatformUtil.getObjectDetectionClassifierPath()
if (OpenCvLoader.hasOpenCvLoaded() && classifierDir.exists() && classifierDir.isDirectory()) { if (classifierDir.exists() && classifierDir.isDirectory()) {
for (File classifier : classifierDir.listFiles()) { for (File classifier : classifierDir.listFiles()) {
if (classifier.isFile() && FilenameUtils.getExtension(classifier.getName()).equalsIgnoreCase("xml")) { if (classifier.isFile() && FilenameUtils.getExtension(classifier.getName()).equalsIgnoreCase("xml")) {
classifiers.put(classifier.getName(), new CascadeClassifier(classifier.getAbsolutePath())); classifiers.put(classifier.getName(), new CascadeClassifier(classifier.getAbsolutePath()));