Skip to content

Commit

Permalink
Fix windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Sep 20, 2024
1 parent a6856b6 commit 8cd79df
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
11 changes: 7 additions & 4 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ model {
}

binaries.all {
// lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared'
// lib library: nativeName
lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared'
lib library: nativeName

// nativeUtils.useRequiredLibrary(it, "wpilib_shared")
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
}
}
}
Expand Down Expand Up @@ -255,7 +255,10 @@ task installPhotonlibpyNative(type: Copy) {
into("$projectDir/py/photonlibpy")

from "$projectDir/build/libs/photonlib/shared/$jniPlatform/release/libphotonlib.so"
from "$projectDir/build/libs/photonlib/shared/$jniPlatform/release/photonlib.dll"

for (lib in [
"photontargeting.dll",
"cameraserver.dll",
"cscore.dll",
"opencv_core480.dll",
Expand All @@ -264,7 +267,7 @@ task installPhotonlibpyNative(type: Copy) {
"opencv_imgcodecs480.dll",
"opencv_flann480.dll",
"opencv_imgproc480.dll",
"photontargeting.so",

"libcameraserver.so",
"libcscore.so",
"libopencv_core.so.4.8",
Expand Down
2 changes: 2 additions & 0 deletions photon-lib/py/photonlibpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@
import robotpy_apriltag

# and now our extension module
import os
os.add_dll_directory(os.path.dirname(os.path.realpath(__file__)))
from ._photonlibpy import *
Binary file modified photon-lib/py/photonlibpy/_photonlibpy.pyd
Binary file not shown.
58 changes: 29 additions & 29 deletions photon-lib/src/main/pybindings/cpp/photonlib_nanobind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* SOFTWARE.
*/

// #include <fmt/format.h>
// #include "photon/PhotonCamera.h"
#include <fmt/format.h>
#include "photon/PhotonCamera.h"

// actual nanobind include
#include <nanobind/nanobind.h>
Expand All @@ -36,34 +36,34 @@ NB_MODULE(_photonlibpy, m) {

m.doc() = "C++ bindings for photonlib";

// nb::class_<photon::PhotonPipelineMetadata>(m, "PhotonPipelineMetadata")
// .def_ro("sequenceID", &photon::PhotonPipelineMetadata::sequenceID)
// .def_ro("captureTimestampMicros",
// &photon::PhotonPipelineMetadata::captureTimestampMicros)
// .def_ro("publishTimestampMicros",
// &photon::PhotonPipelineMetadata::publishTimestampMicros);
nb::class_<photon::PhotonPipelineMetadata>(m, "PhotonPipelineMetadata")
.def_ro("sequenceID", &photon::PhotonPipelineMetadata::sequenceID)
.def_ro("captureTimestampMicros",
&photon::PhotonPipelineMetadata::captureTimestampMicros)
.def_ro("publishTimestampMicros",
&photon::PhotonPipelineMetadata::publishTimestampMicros);

// nb::class_<photon::PhotonTrackedTarget>(m, "PhotonTrackedTarget")
// .def_ro("yaw", &photon::PhotonTrackedTarget::yaw)
// .def_ro("pitch", &photon::PhotonTrackedTarget::pitch)
// // String representation
// .def("__repr__", [](const photon::PhotonTrackedTarget& t) {
// std::string s;
// fmt::format_to(std::back_inserter(s),
// "PhotonTrackedTarget<yaw={},pitch={}>", t.yaw, t.pitch);
// return s;
// });
// nb::class_<photon::MultiTargetPNPResult>(m, "MultiTargetPNPResult")
// .def_ro("fiducialIDsUsed", &photon::MultiTargetPNPResult::fiducialIDsUsed)
// ;
nb::class_<photon::PhotonTrackedTarget>(m, "PhotonTrackedTarget")
.def_ro("yaw", &photon::PhotonTrackedTarget::yaw)
.def_ro("pitch", &photon::PhotonTrackedTarget::pitch)
// String representation
.def("__repr__", [](const photon::PhotonTrackedTarget& t) {
std::string s;
fmt::format_to(std::back_inserter(s),
"PhotonTrackedTarget<yaw={},pitch={}>", t.yaw, t.pitch);
return s;
});
nb::class_<photon::MultiTargetPNPResult>(m, "MultiTargetPNPResult")
.def_ro("fiducialIDsUsed", &photon::MultiTargetPNPResult::fiducialIDsUsed)
;

// nb::class_<photon::PhotonPipelineResult>(m, "PhotonPipelineResult")
// .def_ro("metadata", &photon::PhotonPipelineResult::metadata)
// .def_ro("targets", &photon::PhotonPipelineResult::targets)
// .def_ro("multitagResult", &photon::PhotonPipelineResult::multitagResult);
nb::class_<photon::PhotonPipelineResult>(m, "PhotonPipelineResult")
.def_ro("metadata", &photon::PhotonPipelineResult::metadata)
.def_ro("targets", &photon::PhotonPipelineResult::targets)
.def_ro("multitagResult", &photon::PhotonPipelineResult::multitagResult);

// nb::class_<photon::PhotonCamera>(m, "PhotonCamera")
// .def(nb::init<const std::string&>())
// .def("GetDriverMode", &photon::PhotonCamera::GetDriverMode)
// .def("GetLatestResult", &photon::PhotonCamera::GetLatestResult);
nb::class_<photon::PhotonCamera>(m, "PhotonCamera")
.def(nb::init<const std::string&>())
.def("GetDriverMode", &photon::PhotonCamera::GetDriverMode)
.def("GetLatestResult", &photon::PhotonCamera::GetLatestResult);
}

0 comments on commit 8cd79df

Please sign in to comment.