3845 move OpenCv library to corelibs

This commit is contained in:
William Schaefer 2018-05-24 11:00:54 -04:00
parent 0549b46568
commit 0fca4ebe4f
9 changed files with 81 additions and 47 deletions

View File

@ -21,11 +21,6 @@
</target>
<target name="get-thirdparty-dependencies" description="get third-party dependencies">
<!--Copy openCV dependencies to release-->
<copy todir="${modules.dir}" >
<fileset dir="${thirdparty.dir}/opencv" />
</copy>
<!--Copy photorec to release-->
<copy todir="${basedir}/release/photorec_exec" >
<fileset dir="${thirdparty.dir}/photorec_exec"/>

View File

@ -12,7 +12,6 @@ file.reference.jython-standalone-2.7.0.jar=release/modules/ext/jython-standalone
file.reference.mchange-commons-java-0.2.9.jar=release/modules/ext/mchange-commons-java-0.2.9.jar
file.reference.metadata-extractor-2.10.1.jar=release/modules/ext/metadata-extractor-2.10.1.jar
file.reference.postgresql-9.4.1211.jre7.jar=release/modules/ext/postgresql-9.4.1211.jre7.jar
file.reference.opencv-2413.jar=release/modules/ext/opencv-2413.jar
file.reference.Rejistry-1.0-SNAPSHOT.jar=release/modules/ext/Rejistry-1.0-SNAPSHOT.jar
file.reference.sevenzipjbinding-AllPlatforms.jar=release/modules/ext/sevenzipjbinding-AllPlatforms.jar
file.reference.sevenzipjbinding.jar=release/modules/ext/sevenzipjbinding.jar

View File

@ -309,18 +309,6 @@
<package>net.sf.sevenzipjbinding.impl</package>
<package>net.sf.sevenzipjbinding.simple</package>
<package>net.sf.sevenzipjbinding.simple.impl</package>
<package>org.opencv.calib3d</package>
<package>org.opencv.contrib</package>
<package>org.opencv.core</package>
<package>org.opencv.features2d</package>
<package>org.opencv.gpu</package>
<package>org.opencv.highgui</package>
<package>org.opencv.imgproc</package>
<package>org.opencv.ml</package>
<package>org.opencv.objdetect</package>
<package>org.opencv.photo</package>
<package>org.opencv.utils</package>
<package>org.opencv.video</package>
<package>org.sleuthkit.autopsy.actions</package>
<package>org.sleuthkit.autopsy.appservices</package>
<package>org.sleuthkit.autopsy.casemodule</package>
@ -391,10 +379,6 @@
<runtime-relative-path>ext/jgraphx-v3.8.0.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jgraphx-v3.8.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/opencv-2413.jar</runtime-relative-path>
<binary-origin>release/modules/ext/opencv-2413.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/jython-standalone-2.7.0.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jython-standalone-2.7.0.jar</binary-origin>

View File

@ -59,10 +59,10 @@ import javax.imageio.stream.ImageInputStream;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.opencv.core.Core;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corelibs.OpenCvLoader;
import org.sleuthkit.autopsy.corelibs.ScalrWrapper;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector.FileTypeDetectorInitException;
@ -96,7 +96,6 @@ public class ImageUtils {
private static final List<String> SUPPORTED_IMAGE_EXTENSIONS = new ArrayList<>();
private static final SortedSet<String> SUPPORTED_IMAGE_MIME_TYPES;
private static boolean OPEN_CV_LOADED;
private static final boolean FFMPEG_LOADED;
/**
@ -119,7 +118,7 @@ public class ImageUtils {
}
DEFAULT_THUMBNAIL = tempImage;
boolean tempFfmpegLoaded = false;
if (isOpenCvLoaded()) {
if (OpenCvLoader.isOpenCvLoaded()) {
try {
if (System.getProperty("os.arch").equals("amd64") || System.getProperty("os.arch").equals("x86_64")) { //NON-NLS
System.loadLibrary("opencv_ffmpeg2413_64"); //NON-NLS
@ -156,25 +155,6 @@ 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) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
OPEN_CV_LOADED = true;
}
} catch (UnsatisfiedLinkError e) {
OPEN_CV_LOADED = 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);
}
return OPEN_CV_LOADED;
}
/**
* initialized lazily
*/

View File

@ -20,8 +20,16 @@
<property name="thirdparty.dir" value="${basedir}/../thirdparty" />
<property name="lib.dir" value="${basedir}/release/modules/lib" />
<target name="get-deps" description="retrieve dependencies using ivy" depends="init-ivy,build-native-libs">
<property name="modules.dir" value="${basedir}/release/modules/" />
<target name="get-thirdparty-dependencies" description="get third-party dependencies">
<!--Copy openCV dependencies to release-->
<copy todir="${modules.dir}" >
<fileset dir="${thirdparty.dir}/opencv" />
</copy>
</target>
<target name="get-deps" description="retrieve dependencies using ivy" depends="init-ivy,build-native-libs,get-thirdparty-dependencies">
<ivy:settings file="ivysettings.xml" />
<ivy:resolve log="quiet"/>
<ivy:retrieve pattern="${basedir}/release/modules/ext/[artifact]-[revision](-[classifier]).[ext]" />

View File

@ -56,6 +56,7 @@ file.reference.LGoodDatePicker-10.3.1.jar=release/modules/ext/LGoodDatePicker-10
file.reference.log4j-1.2.17.jar=release/modules/ext/log4j-1.2.17.jar
file.reference.logkit-1.0.1.jar=release/modules/ext/logkit-1.0.1.jar
file.reference.mail-1.4.3.jar=release/modules/ext/mail-1.4.3.jar
file.reference.opencv-2413.jar=release/modules/ext/opencv-2413.jar
file.reference.openjfx-dialogs-1.0.2.jar=release/modules/ext/openjfx-dialogs-1.0.3.jar
file.reference.platform-3.4.0.jar=release/modules/ext/platform-3.4.0.jar
file.reference.poi-3.17.jar=release/modules/ext/poi-3.17.jar

View File

@ -619,6 +619,18 @@
<package>org.joda.time.field</package>
<package>org.joda.time.format</package>
<package>org.joda.time.tz</package>
<package>org.opencv.calib3d</package>
<package>org.opencv.contrib</package>
<package>org.opencv.core</package>
<package>org.opencv.features2d</package>
<package>org.opencv.gpu</package>
<package>org.opencv.highgui</package>
<package>org.opencv.imgproc</package>
<package>org.opencv.ml</package>
<package>org.opencv.objdetect</package>
<package>org.opencv.photo</package>
<package>org.opencv.utils</package>
<package>org.opencv.video</package>
<package>org.openxmlformats.schemas.drawingml.x2006.chart</package>
<package>org.openxmlformats.schemas.drawingml.x2006.chart.impl</package>
<package>org.openxmlformats.schemas.drawingml.x2006.main</package>
@ -733,6 +745,10 @@
<runtime-relative-path>ext/jfxtras-common-8.0-r4.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jfxtras-common-8.0-r4.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/opencv-2413.jar</runtime-relative-path>
<binary-origin>release/modules/ext/opencv-2413.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/jsr305-1.3.9.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jsr305-1.3.9.jar</binary-origin>

View File

@ -0,0 +1,50 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.corelibs;
import org.opencv.core.Core;
public final class OpenCvLoader {
private static final boolean OPEN_CV_LOADED;
static {
boolean tempOpenCvLoaded = false;
try {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
tempOpenCvLoaded = true;
} catch (UnsatisfiedLinkError e) {
tempOpenCvLoaded = false;
System.out.println("OpenCV native library failed to load " + e.toString());
}
OPEN_CV_LOADED = tempOpenCvLoaded;
}
/**
* Return whether or not the OpenCV library has been loaded.
*
* @return - true if the opencv library is loaded or false if it is not
*/
public static boolean isOpenCvLoaded() throws UnsatisfiedLinkError {
if (!OPEN_CV_LOADED){
throw new UnsatisfiedLinkError("OpenCV native library failed to load");
}
return OPEN_CV_LOADED;
}
}

View File

@ -32,6 +32,7 @@ import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.corelibs.OpenCvLoader;
import org.sleuthkit.autopsy.coreutils.ImageUtils;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
@ -63,7 +64,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()) {
if (OpenCvLoader.isOpenCvLoaded() && classifierDir.exists() && classifierDir.isDirectory()) {
for (File classifier : classifierDir.listFiles()) {
if (classifier.isFile() && FilenameUtils.getExtension(classifier.getName()).equalsIgnoreCase("xml")) {
cascades.put(classifier.getName(), new CascadeClassifier(classifier.getAbsolutePath()));