3845 adjust comments to clarify object detection module

This commit is contained in:
William Schaefer 2018-05-23 16:53:31 -04:00
parent 82d45af1b9
commit 093d9c531d
3 changed files with 24 additions and 6 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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();
}