mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
3845 adjust comments to clarify object detection module
This commit is contained in:
parent
82d45af1b9
commit
093d9c531d
@ -129,8 +129,8 @@ public class ImageUtils {
|
|||||||
tempFfmpegLoaded = true;
|
tempFfmpegLoaded = true;
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
tempFfmpegLoaded = false;
|
tempFfmpegLoaded = false;
|
||||||
LOGGER.log(Level.SEVERE, "OpenCV Native code library failed to load", e); //NON-NLS
|
LOGGER.log(Level.SEVERE, "opencv_ffmepeg 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);
|
MessageNotifyUtil.Notify.show("OpenCV FFMpeg", "OpenCV FFMpeg library failed to load, see log for more details", MessageNotifyUtil.MessageType.WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FFMPEG_LOADED = tempFfmpegLoaded;
|
FFMPEG_LOADED = tempFfmpegLoaded;
|
||||||
@ -156,6 +156,12 @@ public class ImageUtils {
|
|||||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), evt -> cacheFileMap.clear());
|
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() {
|
public static boolean isOpenCvLoaded() {
|
||||||
try {
|
try {
|
||||||
if (!OPEN_CV_LOADED) {
|
if (!OPEN_CV_LOADED) {
|
||||||
|
@ -46,6 +46,9 @@ import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_OBJEC
|
|||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data source module to detect objects in images.
|
||||||
|
*/
|
||||||
public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter {
|
public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter {
|
||||||
|
|
||||||
private final static Logger logger = Logger.getLogger(ObjectDetectectionFileIngestModule.class.getName());
|
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());
|
File classifierDir = new File(PlatformUtil.getObjectDetectionClassifierPath());
|
||||||
cascades = new HashMap<>();
|
cascades = new HashMap<>();
|
||||||
|
//Load all classifiers found in PlatformUtil.getObjectDetectionClassifierPath()
|
||||||
if (ImageUtils.isOpenCvLoaded() && classifierDir.exists() && classifierDir.isDirectory()) {
|
if (ImageUtils.isOpenCvLoaded() && 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")) {
|
||||||
@ -76,15 +80,18 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Messages({"# {0} - detectionCount", "ObjectDetectionFileIngestModule.classifierDetection.text=Classifier detected {0} object(s)"})
|
@Messages({"# {0} - detectionCount", "ObjectDetectionFileIngestModule.classifierDetection.text=Classifier detected {0} object(s)"})
|
||||||
@Override
|
@Override
|
||||||
public ProcessResult process(AbstractFile file) {
|
public ProcessResult process(AbstractFile file) {
|
||||||
if (ImageUtils.isImageThumbnailSupported(file)) {
|
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());
|
Mat originalImage = Highgui.imread(file.getLocalPath());
|
||||||
MatOfRect detectionRectangles = new MatOfRect();
|
MatOfRect detectionRectangles = new MatOfRect(); //the rectangles which reprent the coordinates on the image for where objects were detected
|
||||||
for (String cascadeKey : cascades.keySet()) {
|
for (String cascadeKey : cascades.keySet()) {
|
||||||
|
//apply each classifier to the file
|
||||||
cascades.get(cascadeKey).detectMultiScale(originalImage, detectionRectangles);
|
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 {
|
try {
|
||||||
BlackboardArtifact artifact = file.newArtifact(TSK_OBJECT_DETECTED);
|
BlackboardArtifact artifact = file.newArtifact(TSK_OBJECT_DETECTED);
|
||||||
artifact.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION,
|
artifact.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION,
|
||||||
|
@ -34,6 +34,11 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
|||||||
public class ObjectDetectionModuleFactory extends IngestModuleFactoryAdapter {
|
public class ObjectDetectionModuleFactory extends IngestModuleFactoryAdapter {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the Object Detection module
|
||||||
|
*
|
||||||
|
* @return the name of the Object Detection module
|
||||||
|
*/
|
||||||
static String getModuleName() {
|
static String getModuleName() {
|
||||||
return Bundle.ObjectDetectionModuleFactory_moduleName_text();
|
return Bundle.ObjectDetectionModuleFactory_moduleName_text();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user