-
-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1299c13
commit 209a2ff
Showing
17 changed files
with
958 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
nbproject/ | ||
build.xml | ||
build/ | ||
dist/ | ||
build_*/ | ||
*.dll | ||
*.bat | ||
*.sh | ||
*.lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
project(libbgs_java_module) | ||
|
||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
if(UNIX) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=gnu++0x") | ||
set(CMAKE_MACOSX_RPATH 1) | ||
endif(UNIX) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") | ||
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules) | ||
|
||
# compilation mode setup | ||
set(CMAKE_BUILD_TYPE Release) | ||
#set(CMAKE_BUILD_TYPE Debug) | ||
|
||
if(WIN32) | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") | ||
endif(WIN32) | ||
|
||
set(bgs_out_dir ".") | ||
# First for the generic no-config case (e.g. with mingw) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${bgs_out_dir}) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${bgs_out_dir}) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${bgs_out_dir}) | ||
# Second, for multi-config builds (e.g. msvc) | ||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) | ||
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir}) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir}) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir}) | ||
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) | ||
|
||
if(UNIX) | ||
# add some standard warnings | ||
ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas) | ||
|
||
# -ansi does not compile with sjn module | ||
#ADD_DEFINITIONS(-ansi) | ||
|
||
# if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare | ||
#ADD_DEFINITIONS(-Wconversion -Wfloat-equal) | ||
endif(UNIX) | ||
|
||
find_package(JNI REQUIRED) | ||
if (JNI_FOUND) | ||
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}") | ||
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}") | ||
endif() | ||
|
||
set(OpenCV_STATIC OFF) | ||
find_package(OpenCV REQUIRED) | ||
if (OpenCV_FOUND) | ||
message(STATUS "OpenCV library status:") | ||
message(STATUS " version: ${OpenCV_VERSION}") | ||
message(STATUS " libraries: ${OpenCV_LIBS}") | ||
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") | ||
endif() | ||
|
||
file(GLOB_RECURSE analysis_src ../package_analysis/*.cpp) | ||
file(GLOB_RECURSE analysis_inc ../package_analysis/*.h) | ||
file(GLOB_RECURSE bgs_src ../package_bgs/*.cpp package_bgs/*.c) | ||
file(GLOB_RECURSE bgs_inc ../package_bgs/*.h) | ||
|
||
include_directories(${CMAKE_SOURCE_DIR} ${JNI_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS}) | ||
|
||
add_library(libbgs STATIC ${bgs_src} ${analysis_src}) | ||
target_link_libraries(libbgs ${OpenCV_LIBS}) | ||
set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_inc} ${analysis_inc}) | ||
if(WIN32) | ||
# set_property(TARGET libbgs PROPERTY SUFFIX ".lib") | ||
else() | ||
set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs") | ||
endif() | ||
|
||
set(SOURCE_FILES bgslibrary_java_module.cpp) | ||
add_library(libbgs_java_module SHARED ${SOURCE_FILES}) | ||
set_target_properties(libbgs_java_module PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
target_link_libraries(libbgs_java_module libbgs ${OpenCV_LIBS}) | ||
if(WIN32) | ||
# set_property(TARGET libbgs_java_module PROPERTY SUFFIX ".lib") | ||
else() | ||
set_property(TARGET libbgs_java_module PROPERTY OUTPUT_NAME "bgs_java_module") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
### For Windows users | ||
|
||
* Running CMAKE with Visual Studio 2015 and OpenCV 3.2.0 (x64) | ||
|
||
* * Working directory: **bgslibrary\wrapper_java** | ||
|
||
``` | ||
:: Set OpenCV env | ||
echo "Setting up OpenCV env" | ||
set OpenCV_DIR=C:\OpenCV3.2.0\build | ||
set PATH=%PATH%;%OpenCV_DIR%\x64\vc14\bin | ||
:: Run CMake | ||
echo "Running CMake" | ||
rmdir /S /Q build_cmake | ||
if not exist "build_cmake" mkdir build_cmake | ||
cd build_cmake | ||
cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 14 Win64" .. | ||
cd .. | ||
``` | ||
|
||
* Open **libbgs_java_module.sln** in your Visual Studio IDE and switch to **RELEASE** mode | ||
|
||
* Click on **ALL_BUILD** and build | ||
|
||
* Copy **libbgs_java_module.dll** to **bgslibrary\wrapper_java** | ||
|
||
* Compile Java source | ||
|
||
``` | ||
:: Compile | ||
echo "Compiling" | ||
javac -cp .;src/;libs/opencv-320.jar src/bgslibrary/Main.java | ||
``` | ||
|
||
* Run | ||
|
||
``` | ||
:: Run | ||
echo "Running Main class" | ||
java -cp .;src/;libs/opencv-320.jar -Djava.library.path=. bgslibrary.Main | ||
``` | ||
|
||
[![bgslibrary](https://sites.google.com/site/andrewssobral/bgslib_java_wrapper_screen.png)]() | ||
|
||
|
||
#### Generating JNI files (optional) | ||
|
||
``` | ||
:: Generate JNI | ||
cd src | ||
echo "Generating JNI" | ||
javah -cp .;../libs/opencv-320.jar bgslibrary.Main | ||
cd .. | ||
``` |
Oops, something went wrong.