mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
3996 improve opencv logging and prevent any opencv exceptions from escaping process method
This commit is contained in:
parent
3001ea4a32
commit
083b8d0bfd
@ -106,10 +106,22 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter
|
|||||||
try {
|
try {
|
||||||
imageInMemory = IOUtils.toByteArray(inputStream);
|
imageInMemory = IOUtils.toByteArray(inputStream);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.log(Level.WARNING, "Unable to perform object detection on " + file.getName(), ex);
|
logger.log(Level.WARNING, "Unable to read image to byte array for performing object detection on " + file.getName(), ex);
|
||||||
return IngestModule.ProcessResult.ERROR;
|
return IngestModule.ProcessResult.ERROR;
|
||||||
}
|
}
|
||||||
Mat originalImage = Highgui.imdecode(new MatOfByte(imageInMemory), Highgui.IMREAD_GRAYSCALE);
|
Mat originalImage;
|
||||||
|
try {
|
||||||
|
originalImage = Highgui.imdecode(new MatOfByte(imageInMemory), Highgui.IMREAD_GRAYSCALE);
|
||||||
|
} catch (CvException ex) {
|
||||||
|
//The image was something which could not be decoded by OpenCv, our isImageThumbnailSupported(file) check above failed us
|
||||||
|
logger.log(Level.WARNING, "Unable to decode image from byte array to perform object detection on " + file.getName(), ex); //NON-NLS
|
||||||
|
return IngestModule.ProcessResult.ERROR;
|
||||||
|
} catch (Exception unexpectedException) {
|
||||||
|
//hopefully an unnecessary generic exception catch but currently present to catch any exceptions OpenCv throws which may not be documented
|
||||||
|
logger.log(Level.SEVERE, "Unexpected Exception encountered attempting to use OpenCV to decode picture: " + file.getName(), unexpectedException);
|
||||||
|
return IngestModule.ProcessResult.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
MatOfRect detectionRectangles = new MatOfRect(); //the rectangles which reprent the coordinates on the image for where objects were detected
|
MatOfRect detectionRectangles = new MatOfRect(); //the rectangles which reprent the coordinates on the image for where objects were detected
|
||||||
for (String classifierKey : classifiers.keySet()) {
|
for (String classifierKey : classifiers.keySet()) {
|
||||||
//apply each classifier to the file
|
//apply each classifier to the file
|
||||||
@ -119,6 +131,10 @@ public class ObjectDetectectionFileIngestModule extends FileIngestModuleAdapter
|
|||||||
//The image was likely an image which we are unable to generate a thumbnail for, and the classifier was likely one where that is not acceptable
|
//The image was likely an image which we are unable to generate a thumbnail for, and the classifier was likely one where that is not acceptable
|
||||||
logger.log(Level.INFO, String.format("Classifier '%s' could not be applied to file '%s'.", classifierKey, file.getParentPath() + file.getName())); //NON-NLS
|
logger.log(Level.INFO, String.format("Classifier '%s' could not be applied to file '%s'.", classifierKey, file.getParentPath() + file.getName())); //NON-NLS
|
||||||
continue;
|
continue;
|
||||||
|
} catch (Exception unexpectedException) {
|
||||||
|
//hopefully an unnecessary generic exception catch but currently present to catch any exceptions OpenCv throws which may not be documented
|
||||||
|
logger.log(Level.SEVERE, "Unexpected Exception encountered for image " + file.getName() + " while trying to apply classifier " + classifierKey, unexpectedException);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!detectionRectangles.empty()) {
|
if (!detectionRectangles.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user