diff --git a/.gitignore b/.gitignore index b3abc5c..ba4b9fc 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,5 @@ _deps *.a *.cmake + +native_build/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 24e7fee..9a3c7b5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "pthread-win32"] - path = pthread-win32 - url = https://github.com/GerHobbelt/pthread-win32 [submodule "apriltag"] path = apriltag url = https://github.com/AprilRobotics/apriltag/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e1360b5..3e55de1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # your build. cmake_minimum_required(VERSION 3.5) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 11) project("apriltag") @@ -23,11 +23,6 @@ if("${ARCH}" STREQUAL "x86_64") set(ARCH "amd64") endif() -if(WIN32) - # Add the pthread-win32 subdirectory - add_subdirectory(pthread-win32) -endif() - message(STATUS "Target architecture: ${ARCH}") message(STATUS $ENV{JAVA_HOME}) @@ -63,6 +58,7 @@ add_library( # Specifies the name of the library. apriltag/common/svd22.c apriltag/common/time_util.c apriltag/common/unionfind.c + apriltag/common/pthreads_cross.c # EOCV-AprilTag-Plugin does not add this, but it is needed for windows... apriltag/common/workerpool.c apriltag/common/zarray.c apriltag/common/zhash.c @@ -76,16 +72,17 @@ add_library( # Specifies the name of the library. apriltag/tagCircle21h7.c apriltag/tagStandard41h12.c) + +# VROOOOOOOM +target_compile_options(apriltag PRIVATE + "$<$:-O3>" + "$<$:-O3>" + ) + set_target_properties(apriltag PROPERTIES OUTPUT_NAME "apriltag_${ARCH}") include_directories( apriltag apriltag/common ${JNI_INCLUDE_DIRS} -) - -# If on Windows, link pthread to apriltag -if(WIN32) - # Choose one of the pthread-win32 libraries depending on your use case: - target_link_libraries(apriltag pthreadVC3) # Or pthreadVSE3 or pthreadVCE3 depending on your build -endif() \ No newline at end of file +) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0800da8..b50f86b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group 'com.github.deltacv' -version '2.1.0-A' +version '2.1.0-B' java { toolchain { diff --git a/build_native_win.bat b/build_native_win.bat new file mode 100644 index 0000000..232416c --- /dev/null +++ b/build_native_win.bat @@ -0,0 +1,5 @@ +@echo off +mkdir native_build +cd native_build +cmake -T ClangCL .. +cmake --build . \ No newline at end of file diff --git a/example/src/main/java/io/github/deltacv/apriltag/example/AprilTagExample.java b/example/src/main/java/io/github/deltacv/apriltag/example/AprilTagExample.java index cccd116..c1dd21a 100644 --- a/example/src/main/java/io/github/deltacv/apriltag/example/AprilTagExample.java +++ b/example/src/main/java/io/github/deltacv/apriltag/example/AprilTagExample.java @@ -31,10 +31,12 @@ public class AprilTagExample { // UNITS ARE METERS public static double TAG_SIZE = 0.166; - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { long detector = AprilTagDetectorJNI.createApriltagDetector(AprilTagDetectorJNI.TagFamily.TAG_36h11.string, 3, 3); System.out.println("Created apriltag detector " + detector); + AprilTagDetectorJNI.setApriltagDetectorDecimation(detector, 4); + VideoCapture camera = new VideoCapture(); System.out.print("Enter camera index: "); @@ -64,6 +66,13 @@ public static void main(String[] args) { for(AprilTagDetection detection : detections) { System.out.printf("detected apriltag %d at x=%.2f y=%.2f z=%.2f\n", detection.id, detection.pose.x, detection.pose.y, detection.pose.z); } + + Thread.sleep(1000); + + if(true) { + AprilTagDetectorJNI.releaseApriltagDetector(detector); + return; + } } // not necessary since our program will exit at this point, just to show off the apriltag api diff --git a/lib/apriltag_amd64.dll b/lib/apriltag_amd64.dll index b4afcf2..54449ea 100644 Binary files a/lib/apriltag_amd64.dll and b/lib/apriltag_amd64.dll differ diff --git a/pthread-win32 b/pthread-win32 deleted file mode 160000 index 3309f4d..0000000 --- a/pthread-win32 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3309f4d6e7538f349ae450347b02132ecb0606a7 diff --git a/src/main/java/io/github/deltacv/apriltag/AprilTagLibLoader.java b/src/main/java/io/github/deltacv/apriltag/AprilTagLibLoader.java index 9011133..40675fd 100644 --- a/src/main/java/io/github/deltacv/apriltag/AprilTagLibLoader.java +++ b/src/main/java/io/github/deltacv/apriltag/AprilTagLibLoader.java @@ -73,7 +73,8 @@ public static void load() { String osArch = osName + " (" + arch + ")"; String name = prefix + "apriltag" + extension; - String version = Integer.toUnsignedString(Build.versionString.hashCode()); + // generate a unique version string based on the build date and version, for the temp folder name + String version = Integer.toUnsignedString((Build.versionString + Build.buildDate).hashCode()); String tmpDir = System.getProperty("java.io.tmpdir");