From 093d9c531d9fdb922b5887d26175afda88a1393f Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 23 May 2018 16:53:31 -0400 Subject: [PATCH] 3845 adjust comments to clarify object detection module --- .../sleuthkit/autopsy/coreutils/ImageUtils.java | 10 ++++++++-- .../ObjectDetectectionFileIngestModule.java | 15 +++++++++++---- .../ObjectDetectionModuleFactory.java | 5 +++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java index 527e76127e..af0a06feec 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java @@ -129,8 +129,8 @@ public class ImageUtils { tempFfmpegLoaded = true; } catch (UnsatisfiedLinkError e) { tempFfmpegLoaded = false; - LOGGER.log(Level.SEVERE, "OpenCV Native code library failed to load", e); //NON-NLS - MessageNotifyUtil.Notify.show("Open CV", "OpenCV native library failed to load, see log for more details", MessageNotifyUtil.MessageType.WARNING); + LOGGER.log(Level.SEVERE, "opencv_ffmepeg code library failed to load", e); //NON-NLS + MessageNotifyUtil.Notify.show("OpenCV FFMpeg", "OpenCV FFMpeg library failed to load, see log for more details", MessageNotifyUtil.MessageType.WARNING); } } FFMPEG_LOADED = tempFfmpegLoaded; @@ -156,6 +156,12 @@ public class ImageUtils { Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), evt -> cacheFileMap.clear()); } + /** + * Check if the OpenCV library has been loaded, if it has not attempt to + * load it, then return true if it is loaded or false if it is not. + * + * @return - true if the opencv library is loaded or false if it is not + */ public static boolean isOpenCvLoaded() { try { if (!OPEN_CV_LOADED) { diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectectionFileIngestModule.java b/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectectionFileIngestModule.java index 6c077d7cef..9f4da49370 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectectionFileIngestModule.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectectionFileIngestModule.java @@ -46,6 +46,9 @@ import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_OBJEC import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.TskCoreException; +/** + * Data source module to detect objects in images. + */ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter { private final static Logger logger = Logger.getLogger(ObjectDetectectionFileIngestModule.class.getName()); @@ -59,6 +62,7 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter File classifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath()); cascades = new HashMap<>(); + //Load all classifiers found in PlatformUtil.getObjectDetectionClassifierPath() if (ImageUtils.isOpenCvLoaded() && classifierDir.exists() && classifierDir.isDirectory()) { for (File classifier : classifierDir.listFiles()) { if (classifier.isFile() && FilenameUtils.getExtension(classifier.getName()).equalsIgnoreCase("xml")) { @@ -76,15 +80,18 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter } } + @Messages({"# {0} - detectionCount", "ObjectDetectionFileIngestModule.classifierDetection.text=Classifier detected {0} object(s)"}) @Override public ProcessResult process(AbstractFile file) { - if (ImageUtils.isImageThumbnailSupported(file)) { - Mat originalImage = Highgui.imread(file.getLocalPath()); - MatOfRect detectionRectangles = new MatOfRect(); + if (ImageUtils.isImageThumbnailSupported(file)) { //Any image we can create a thumbnail for is one we should apply the classifiers to + Mat originalImage = Highgui.imread(file.getLocalPath()); + MatOfRect detectionRectangles = new MatOfRect(); //the rectangles which reprent the coordinates on the image for where objects were detected for (String cascadeKey : cascades.keySet()) { + //apply each classifier to the file cascades.get(cascadeKey).detectMultiScale(originalImage, detectionRectangles); - if (!detectionRectangles.empty()) { + if (!detectionRectangles.empty()) { + //if any detections occurred create an artifact for this classifier and file combination try { BlackboardArtifact artifact = file.newArtifact(TSK_OBJECT_DETECTED); artifact.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION, diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectionModuleFactory.java b/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectionModuleFactory.java index 74e39ac9e5..fd9d0f0e82 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectionModuleFactory.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/objectDetection/ObjectDetectionModuleFactory.java @@ -34,6 +34,11 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; public class ObjectDetectionModuleFactory extends IngestModuleFactoryAdapter { + /** + * Get the name of the Object Detection module + * + * @return the name of the Object Detection module + */ static String getModuleName() { return Bundle.ObjectDetectionModuleFactory_moduleName_text(); }