Skip to content

Commit

Permalink
Scrap pthreadwin32 and use pthreads_cross instead
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Oct 8, 2024
1 parent 0af8952 commit 41699ef
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ _deps

*.a
*.cmake

native_build/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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/
23 changes: 10 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# your build.

cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 11)

project("apriltag")

Expand All @@ -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})
Expand Down Expand Up @@ -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
Expand All @@ -76,16 +72,17 @@ add_library( # Specifies the name of the library.
apriltag/tagCircle21h7.c
apriltag/tagStandard41h12.c)


# VROOOOOOOM
target_compile_options(apriltag PRIVATE
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-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()
)
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'com.github.deltacv'
version '2.1.0-A'
version '2.1.0-B'

java {
toolchain {
Expand Down
5 changes: 5 additions & 0 deletions build_native_win.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
mkdir native_build
cd native_build
cmake -T ClangCL ..
cmake --build .
Original file line number Diff line number Diff line change
Expand Up @@ -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: ");
Expand Down Expand Up @@ -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
Expand Down
Binary file modified lib/apriltag_amd64.dll
Binary file not shown.
1 change: 0 additions & 1 deletion pthread-win32
Submodule pthread-win32 deleted from 3309f4
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 41699ef

Please sign in to comment.