feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake

1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试
2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程
3.重整权利声明文件,重整代码工程,确保最小化侵权风险

Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake
Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
wangzhengyang
2022-05-10 09:54:44 +08:00
parent ecdd171c6f
commit 718c41634f
10018 changed files with 3593797 additions and 186748 deletions

View File

@ -0,0 +1,95 @@
# Using Maven to build OpenCV
This page describes the how to build OpenCV using [Apache Maven](http://maven.apache.org/index.html). The Maven build is simply a wrapper around the existing CMake process but has the additional aims of creating Java OSGi-compatible bundles with included native support and also allow the build to be carried out on RaspberryPi (ARM) architecture. There is nothing preventing using the POM on x86 Linux however.
The following assumes building on Debian-based Linux platform.
## 1 - Overview
The Maven build process aims to:
1. Provide a simpler route to build OpenCV and Java bundles.
2. Automatically check the required native dependencies.
3. Make the Java libraries OSGi compatible.
4. Include the native OpenCV native library inside the Java bundle.
5. Integration testing of the bundle within an OSGi environment.
6. Allow the build to function on x86, x86_64 or amd architectures, Debian-based Linux platform.
### 2 - Preparing The Build environment
To build using the Maven build process both `Maven` and and up-to-date `JDK` (Java Development Kit) need to be installed. If you know you already have these installed then continue to `Environment Variable` otherwise the easiest solution is to install them using the aptitude package manager:
`sudo aptitude install maven default-jdk`
Note that installing via `aptitude` you are unlikely to get the latest version of Maven or JDK although if you are not developing Java code this shouldn't matter for this build process.
### 3 - Starting the build
#### 3.1 - Environment variables
**Applicability:** All processors.
The following environment variables must be set otherwise the build will fail and halt:
* `$JAVA_HOME` (the absolute path to the JDK root directory)
* `$ANT_HOME` (the absolute path to the Ant root directory)
It is recommended that advantage is taken of multiple processor cores to reduce build time. This can be done by setting a MAKEFLAGS environment variable specifying the number of parallel builds e.g.:
* `$MAKEFLAGS="-j8"`
However if this flag is not set the build will NOT fail. On a RaspberryPi 2 typical build times are 5 hours with `-j1` (which is the default if `$MAKEFLAGS` is not specified) and a little over 2 hours with `-j4`.
All of the above environment variables can be set on an ad-hoc basis using 'export'.
#### 3.2 - Build Directory
**Applicability:** All processors
By default the following build directories are created.
`<OpenCV_root_dir>/build`
`<OpenCV_root_dir>/build/maven/opencv/target`
`<OpenCV_root_dir>/build/maven/opencv-it/target`
Under `build` are the standard OpenCV artifacts. Under `build/maven/opencv/target` can be found the OSGi compatible Java bundle. When deploying the bundle into an OSGi framework e.g. [Apache Karaf](http://karaf.apache.org/), loading of the native library is automatically taken care of. An integration testing module is created under the `opencv-it` directory and is only of use during the build but is disabled by fault. The standard Java library as created by the CMake process is also available as specified in the existing OpenCV documentation.
The Maven build is initiated from the directory contain the `pom.xml` file.
#### 3.3 - x86 or x86_64 Architecture:
Generally all that is required is the standard Maven command:
`mvn clean install`
One of the first things the build will do is check the required native dependencies. The Maven build indicates the status of the required dependencies and will fail at this point if any are missing. Install using the package manager e.g. aptitude or apt-get, and restart the build with the above command.
Once the build successfully completes the OSGi compatible artifacts are available as described above in 'Build Directory'.
#### 3.4 - ARM 32-bit Architecture - Raspbian Distribution
Similar to the x86 architecture the native dependencies are first checked so install any that are missing, however at the time of writing there are no official `libtbb2` and `libtbb-dev` packages in Raspbian. Version 4.4.3 of Intel's Thread Building Blocks library are available [here](http://www.javatechnics.com/thread-building-blocks-tbb-4-4-3-for-raspbian) as a Raspbian-compatible Debian packages.
**PLEASE NOTE THESE ARE NOT OFFICIAL RASPBIAN PACKAGES. INSTALL AT YOUR OWN RISK.**
The build can be started with the following command:
`mvn clean install`
Upon a successful build the libraries will be available as described above in 'Build Directory'.
#### 3.5 CMake
**Applicability:** x86 processors
The CMake Maven plugin is configured to use the native CMake package (recommended) i.e. it will NOT download the latest CMake binary. Should you require CMake download then include the following Maven commandline switch when building:
`-Ddownload.cmake=true`
#### 3.6 Integration Tests
**Applicability:** All processors
OSGi integration tests can be run as part of the build by including the following commandline switch to Maven:
`-Pintegration`
### 4.0 Maintainer Notes
This section is relevant to those maintaining the Maven platform build. If you just want to build the library then you do not need to refer to this section.
#### 4.1 Updating POM Version to Match Core Version
Maven requires the version to be hard-coded in the POM or in otherwords it cannot be changed at runtime. When the core C/C++ code version changes it is easy to forget to update the Maven version. The POM utilises the enforcer plugin to ensure the POM and Core versions match causing the build to fail if they do not.
Should the POM version require updating then this can be done utilising the Maven 'versions' plugin and this will apply the correct version to all POMs within the project. Execute the following Maven command from the root directory of the Maven project:
`mvn versions:set -DnewVersion=$(. ./opencv/scripts/functions && cd ./opencv/scripts && extract_version && echo $REPLY)`

View File

@ -0,0 +1,111 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>4.5.4</version>
</parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-it</artifactId>
<name>OpenCV Integration Test</name>
<dependencies>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.24</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>org.apache.karaf.log.core</artifactId>
<groupId>org.apache.karaf.log</groupId>
<version>4.0.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>opencv</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>../../../build/maven/opencv-it/target</directory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testOutputDirectory>../../../build/maven/opencv-it/target</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>generate-depends-file</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,97 @@
package org.opencv.osgi;
import java.io.File;
import javax.inject.Inject;
import junit.framework.TestCase;
import org.apache.karaf.log.core.LogService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.ops4j.pax.logging.spi.PaxLoggingEvent;
import org.osgi.framework.BundleContext;
/**
*
* @author Kerry Billingham <contact@AvionicEngineers.com>
*/
@ExamReactorStrategy(PerClass.class)
@RunWith(PaxExam.class)
public class DeployOpenCVTest {
/*
The expected string in Karaf logs when the bundle has deployed and native library loaded.
*/
private static final String OPENCV_SUCCESSFUL_LOAD_STRING = "Successfully loaded OpenCV native library.";
private static final String KARAF_VERSION = "4.0.6";
@Inject
protected BundleContext bundleContext;
@Inject
private LogService logService;
/*
This service is required to ensure that the native library has been loaded
before any test is carried out.
*/
@Inject
private OpenCVInterface openCVInterface;
@Configuration
public static Option[] configuration() throws Exception {
MavenArtifactUrlReference karafUrl = maven()
.groupId("org.apache.karaf")
.artifactId("apache-karaf")
.version(KARAF_VERSION)
.type("tar.gz");
return new Option[]{
karafDistributionConfiguration()
.frameworkUrl(karafUrl)
.unpackDirectory(new File("../../../build/target/exam"))
.useDeployFolder(false),
keepRuntimeFolder(),
mavenBundle()
.groupId("org.opencv")
.artifactId("opencv")
.versionAsInProject(),
logLevel(LogLevelOption.LogLevel.INFO)
};
}
/**
* Tests that the OpenCV bundle has been successfully deployed and that the
* native library has been loaded.
*/
@Test
public void testOpenCVNativeLibraryLoadSuccess() {
Iterable<PaxLoggingEvent> loggingEvents = logService.getEvents();
boolean loadSuccessful = logsContainsMessage(loggingEvents, OPENCV_SUCCESSFUL_LOAD_STRING);
TestCase.assertTrue("Could not determine if OpenCV library successfully loaded from the logs.", loadSuccessful);
}
private boolean logsContainsMessage(Iterable<PaxLoggingEvent> logEnumeration, final String logMessageString) {
boolean contains = false;
for (PaxLoggingEvent logEntry : logEnumeration) {
if (logEntry.getMessage().contains(logMessageString)) {
contains = true;
break;
}
}
return contains;
}
}

View File

@ -0,0 +1,272 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>4.5.4</version>
</parent>
<groupId>org.opencv</groupId>
<artifactId>opencv</artifactId>
<packaging>bundle</packaging>
<name>OpenCV</name>
<properties>
<source.path>../../..</source.path>
<build.directory>${source.path}/build</build.directory>
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
<resources.directory>${build.directory}/src</resources.directory>
</properties>
<build>
<directory>../../../build/maven/opencv/target</directory>
<outputDirectory>../../../build/src</outputDirectory>
<sourceDirectory>../../../build/src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>${build.directory}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>get-opencv-version</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<workingDirectory>${project.basedir}/scripts</workingDirectory>
<arguments>
<argument>properties</argument>
<argument>${build.directory}</argument>
<argument>build.properties</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>setup-environment</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<workingDirectory>${project.basedir}/scripts</workingDirectory>
<arguments>
<!-- Optional packages should be placed BEFORE required ones
in the following argument list. -->
<argument>deb_package_check</argument>
<argument>-olibpng-dev|libpng12-dev</argument>
<argument>-olibopenjp2-7-dev|libjasper-dev</argument>
<argument>-opython-dev</argument>
<argument>-opython-numpy</argument>
<argument>build-essential</argument>
<argument>cmake</argument>
<argument>git</argument>
<argument>libgtk2.0-dev</argument>
<argument>pkg-config</argument>
<argument>libavcodec-dev</argument>
<argument>libavformat-dev</argument>
<argument>libswscale-dev</argument>
<argument>libtbb2</argument>
<argument>libtbb-dev</argument>
<argument>libjpeg-dev</argument>
<argument>libtiff5-dev</argument>
<argument>libdc1394-22-dev</argument>
<argument>execstack</argument>
<argument>ant</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>check-execstack</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${project.basedir}/scripts</workingDirectory>
<executable>bash</executable>
<arguments>
<argument>execstack_check</argument>
<argument>${build.directory}/lib/libopencv_java${lib.version.string}.so</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${resources.directory}</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>set-arch-properties</id>
<phase>process-resources</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${build.directory}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<phase>validate</phase>
<id>enforce-os</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireOS>
<family>unix</family>
<message>This POM is written to function on UNIX family of OS.
More specifically it should be a Debian flavour of Linux.</message>
</requireOS>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-environment</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireEnvironmentVariable>
<level>ERROR</level>
<variableName>ANT_HOME</variableName>
<message>$ANT_HOME is not set. Build may fail.</message>
</requireEnvironmentVariable>
<requireEnvironmentVariable>
<level>ERROR</level>
<variableName>JAVA_HOME</variableName>
<message>$JAVA_HOME is not set. Build will fail.</message>
</requireEnvironmentVariable>
<requireEnvironmentVariable>
<level>WARN</level>
<variableName>MAKEFLAGS</variableName>
<message>No MAKEFLAGS environment variable. Build may be slow.
To speed up the build you can try exporting MAKEFLAGS=-jX where X equals the number of parallel builds.</message>
</requireEnvironmentVariable>
</rules>
</configuration>
</execution>
<execution>
<phase>process-resources</phase>
<id>check-versions-match</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>project.version</property>
<regex>${opencv.version}</regex>
<regexMessage>The Maven POM version ${project.version} does not match the extracted OpenCV version ${opencv.version}.
To correct this please execute the following Maven command from the Maven root directory:
mvn versions:set -DnewVersion=$(. ./opencv/scripts/functions &amp;&amp; cd ./opencv/scripts &amp;&amp; extract_version &amp;&amp; echo $REPLY)</regexMessage>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>*</Export-Package>
<Bundle-NativeCode>${nativelibrary.name};osname=linux;processor=${osgi.processor}</Bundle-NativeCode>
<Include-Resource>${build.directory}/lib/${nativelibrary.name}</Include-Resource>
</instructions>
<manifestLocation>${build.directory}/manifest</manifestLocation>
<niceManifest>true</niceManifest>
</configuration>
</plugin>
<plugin>
<groupId>com.googlecode.cmake-maven-project</groupId>
<artifactId>cmake-maven-plugin</artifactId>
<version>3.4.1-b2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<id>cmake-generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<sourcePath>../../..</sourcePath>
<targetPath>../../../build</targetPath>
<generator>Unix Makefiles</generator>
<options>
<option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
</options>
</configuration>
</execution>
<execution>
<phase>generate-sources</phase>
<id>cmake-compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<target>opencv_java</target>
<projectDirectory>../../../build</projectDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.osgi.org/xmlns/blueprint/v1.0.0'
xsi:schemaLocation='http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd'>
<bean id="opencvnativeloader" class="org.opencv.osgi.OpenCVNativeLoader" scope="singleton" init-method="init" />
<service id="opencvtestservice" ref="opencvnativeloader" interface="org.opencv.osgi.OpenCVInterface" />
</blueprint>

View File

@ -0,0 +1,102 @@
#!/bin/bash
##################################################################################################
#
# This script checks for the required Debian packages are installed
# to build OpenCV.
# Commandline parameters:
# $@ These are the names of the packages to check with 'dpkg'. Multiple values may
# be specified per package by using pipe as a delimiter, e.g. libpng-dev|libpng12-dev.
# Multiple values are evaluated left-to-right and the first found prevents checking of
# the remaining package options.
#
# -o <package_name> Specifying this switch with a package name marks it as optional
# i.e. it is not required to be installed.
#
# Returns:
# 0 - All packages installed (success)
# 1 - One or more packages missing (failure)
#
# Kerry Billingham <contact (at) avionicengineers (d0t) com>
# 20 April 2016
#
##################################################################################################
red=$'\e[1;31m'
green=$'\e[1;32m'
yellow=$'\e[1;33m'
end=$'\e[0m'
check_message="Checking for "
declare -i packageMissing=0
declare -i installed=1
#########################
# Function declarations.
#########################
function check_package() {
check_message="Checking for package "
dpkg -s $1 &>/dev/null
is_installed=$?
if [ ${is_installed} -ne 0 ]; then
printf "%-80s%s\n" "$2${check_message}${red}$1" " MISSING.${end}"
packageMissing=1
else
printf "%-80s%s\n" "$2${check_message}${green}$1" " INSTALLED.${end}"
packageMissing=0
fi
return $is_installed
}
# Main part of script.
ORIGINAL_IFS=$IFS
dpkg -? &>/dev/null
if [ $? -ne 0 ]; then
printf "%-80s%s\n" "${check_message} ${red}'dpkg'" " MISSING.${end}"
exit 1
else
printf "%-80s%s\n" "${check_message} ${green}'dpkg'" " INSTALLED.${end}"
fi
while getopts o: option; do
case $option in
o)
IFS="|"
packageChoices=( ${OPTARG} )
if [ ${#packageChoices[@]} -gt 1 ]; then
echo "Optional package. One of ${yellow}${packageChoices[@]}${end} can be installed."
for choice in ${packageChoices[@]}; do
check_package ${choice} " "
if [ $? -eq 0 ]; then
break
fi
done
else
echo "Optional package ${yellow}${packageChoices}${end}"
check_package ${OPTARG} " "
fi
IFS=$ORIGINAL_IFS
;;
\?)
echo "No option found"
;;
esac
done
shift $((OPTIND-1))
packageArray=( $@ )
for package in ${packageArray[@]}; do
IFS="|"
packageChoices=( ${package} )
if [ ${#packageChoices[@]} -gt 1 ]; then
echo "Multiple options. One of ${yellow}${packageChoices[@]}${end} must be installed."
for choice in ${packageChoices[@]}; do
check_package ${choice} " "
if [ $? -eq 0 ]; then
break
fi
done
else
check_package ${package} ""
fi
done
exit $packageMissing

View File

@ -0,0 +1,32 @@
#!/bin/bash
##################################################################
#
# This script will clear the executable flag on
# the specified library and then check it has
# been cleared as a separate operation.
#
# $1 - The absolute path to the OpenCV native library.
#
# Returns:
# 0 - The executable flag has been cleared
# 1 - The executable flag could NOT be cleared (failure).
#
# Kerry Billingham <contact (at) avionicengineers (d0t) com>
# 11 March 2017
#
##################################################################
red=$'\e[1;31m'
green=$'\e[1;32m'
end=$'\e[0m'
echo "${green}[INFO] Checking that the native library executable stack flag is NOT set.${end}"
BINARY=execstack
$BINARY --help > /dev/null || BINARY=/usr/sbin/execstack
$BINARY -c $1
$BINARY -q $1 | grep -o ^-
if [ $? -ne 0 ]; then
echo
echo "${red}[ERROR] The Executable Flag could not be cleared on the library $1.${end}"
exit 1
fi
exit 0

View File

@ -0,0 +1,21 @@
#!/bin/bash
###############################################################
#
# Defines some common functions.
#
# Kerry Billingham <contact [At] AvionicEngineers.{com]>
#
##############################################################
majorHashDefine="#define CV_VERSION_MAJOR"
minorHashDefine="#define CV_VERSION_MINOR"
revisionHashDefine="#define CV_VERSION_REVISION"
statusHashDefine="#define CV_VERSION_STATUS"
versionHeader="../../../../modules/core/include/opencv2/core/version.hpp"
function extract_version() {
minorVersion=$(grep "${minorHashDefine}" $versionHeader | grep -o ".$")
majorVersion=$(grep "${majorHashDefine}" $versionHeader | grep -o ".$")
revision=$(grep "${revisionHashDefine}" $versionHeader | grep -o ".$")
REPLY="${majorVersion}.${minorVersion}.${revision}"
}

View File

@ -0,0 +1,86 @@
#!/bin/bash
#####################################################################
# This script extracts several properties and then writes them to a
# to a file, 'build.properties'. These properties include:
#
# 1. OpenCV version.
# 2. OpenVC version as a string for use by Maven.
# 3. The CPU binary word size.
# 4. Architecture string.
# 4. OSGi compatible CPU architecture string.
#
# There is no need to execute this script directly as it will be
# called during the Maven build process.
#
# Command-line parameters:
# $1 - The build directory and where the output file will be written
# $2 - The name of the output file to write to.
#
# Returns:
# 0 - Successfully written the properties file.
# 1 - Error occurred such as build directory does not exist
# or OpenCV version could not be determined or an
# unexpected error.
#
# Kerry Billingham <contact (at) avionicengineers (d0t) com>
# 20 April 2016
#
#####################################################################
# Include some external functions and variables
. ./functions
#Test build directory exists
if [ ! -n "$1" ] || [ ! -d $1 ];then
echo "Build directory not specified or does not exist!"
exit 1
fi
if [ -n "${versionHeader}" ] && [ -e ${versionHeader} ];then
extract_version
bits=$(getconf LONG_BIT)
architecture=$(arch)
osgiProcessor="Not Set"
case ${architecture} in
x86*)
echo "This is x86 (32 | 64) bit"
case ${bits} in
32)
osgiProcessor="x86"
;;
64)
osgiProcessor="x86_64"
;;
*)
osgiProcessor="Unknown"
esac
;;
arm*)
echo "This is ARM"
byteOrder=$(lscpu | grep -i "byte order")
shopt -s nocasematch
if [[ "${byteOrder}" == *little* ]]; then
osgiProcessor="arm_le"
elif [[ "${byteOrder}}" == *big* ]]; then
osgiProcessor="arm_be"
fi
shopt -u nocasematch
;;
*)
echo "This is unknown architecture"
esac
echo "The version number will be ${majorVersion}.${minorVersion}.${revision}"
echo "opencv.version=${majorVersion}.${minorVersion}.${revision}" > ${1}/${2}
echo "lib.version.string=${majorVersion}${minorVersion}${revision}" >> ${1}/${2}
echo "bits=${bits}" >> ${1}/${2}
echo "architecture=$(arch)" >> ${1}/${2}
echo "osgi.processor=${osgiProcessor}" >> ${1}/${2}
exit 0
else
echo "Could not locate file ${versionHeader} to determine versioning."
exit 1
fi

View File

@ -0,0 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.opencv</groupId>
<artifactId>opencv-parent</artifactId>
<version>4.5.4</version>
<packaging>pom</packaging>
<name>OpenCV Parent POM</name>
<licenses>
<license>
<name>License Agreement For Open Source Computer Vision Library (Apache 2.0 License)</name>
<url>http://opencv.org/license.html</url>
</license>
</licenses>
<url>http://opencv.org/</url>
<scm>
<connection>scm:git:https://github.com/opencv/opencv.git</connection>
<url>https://github.com/opencv/opencv</url>
</scm>
<contributors>
<contributor>
<name>Kerry Billingham</name>
<email>contact (at) AvionicEngineers (d0t) c(0)m</email>
<organization>Java Technics</organization>
<url>www.javatechnics.com</url>
</contributor>
</contributors>
<properties>
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
<pax.exam.version>4.8.0</pax.exam.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<download.cmake>false</download.cmake>
</properties>
<distributionManagement>
<snapshotRepository>
<id>${repo.name}</id>
<url>${repo.url}</url>
</snapshotRepository>
</distributionManagement>
<modules>
<module>opencv</module>
</modules>
<profiles>
<profile>
<id>integration</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<modules>
<module>opencv-it</module>
</modules>
</profile>
</profiles>
</project>