diff --git a/.gitignore b/.gitignore index 61e5f67..e830ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,15 @@ #app +__pycache__/ /app/ +/build/ /Vocabulary/* /build/ /.vscode/ /lib/ /datasets/ /ref/marker_image/ +pyStag.egg-info/ + diff --git a/CMakeLists.txt b/CMakeLists.txt index 3720e6b..25a95dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ - +cmake_minimum_required(VERSION 3.20) project(Stag) IF(NOT CMAKE_BUILD_TYPE) @@ -36,6 +36,7 @@ add_library( ) target_link_libraries( LibStag + PRIVATE ${OpenCV_LIBS} ) @@ -50,7 +51,7 @@ include_directories( # "# You need to change this follow Path to your own Path. " # "# You need to change this follow Path to your own Path. " - /Users/bytedance/anaconda3/lib/python3.8/site-packages/numpy/core/include + /Users/samy.grisard/Anaconda3/lib/site-packages/numpy/core/include ) add_subdirectory(pybindSrc/pybind11) @@ -61,6 +62,7 @@ pybindSrc/opencv2numpy/converter.cpp ) target_link_libraries(pyStag +PRIVATE ${OpenCV_LIBS} LibStag ) @@ -75,5 +77,6 @@ add_executable( target_link_libraries( testrun + PRIVATE LibStag ) diff --git a/README.md b/README.md index 3c250e7..9dcd6f0 100644 --- a/README.md +++ b/README.md @@ -49,17 +49,21 @@ -5. then you will got a `pyStag.cpython-3*-**.so` in `./lib` +5. then you will got a `pyStag.cpython-3*-**.pyd` in `./lib` 6. **install Python package** +- open cmd +- cd to pyStag directory ``` python setup.py install ``` +You must import your opencv dll in your site-packages directory. ("users/Anaconda/Lib/site-packages" for Anaconda). +If **import error DLL load failed while importing pyStag**: check dependencies with [DependencyWalker](https://www.dependencywalker.com/). # Test -```python +``` python test_warpper.py ``` diff --git a/main.cpp b/main.cpp index 1406032..942fe61 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include "Stag.h" #include "opencv2/opencv.hpp" + #include #include diff --git a/pybindSrc/pyStag.cpp b/pybindSrc/pyStag.cpp index f113641..fa6d3b7 100644 --- a/pybindSrc/pyStag.cpp +++ b/pybindSrc/pyStag.cpp @@ -1,6 +1,6 @@ -#include "../src/Marker.h" -#include "../src/Quad.h" -#include "../src/Stag.h" +#include "Marker.h" +#include "Quad.h" +#include "Stag.h" #include "opencv2numpy/converter.h" #include #include diff --git a/setup.py b/setup.py index 4ffb8bb..e2fcae3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import shutil __version__ = "0.0.1" -__library_file__ = './lib/pyStag.cpython-38-darwin.so' +__library_file__ = './lib/Release/pyStag.cp38-win_amd64.pyd' class CopyLibFile(install): @@ -38,7 +38,7 @@ def run(self): author_email="dawsonwen123@gmail.com", url="None", description="warpping of Stag, a fiducial marker detection system", - long_description="", + long_description="description", extras_require={"test": "pytest"}, # Currently, build_ext only provides an optional "highest supported C++ # level" feature, but in the future it may provide more features. diff --git a/src/ED/Timer.h b/src/ED/Timer.h index 2c30196..0d7b23a 100644 --- a/src/ED/Timer.h +++ b/src/ED/Timer.h @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +//#include class Timer { private: diff --git a/src/Stag.cpp b/src/Stag.cpp index ea8465b..e2a8e8f 100644 --- a/src/Stag.cpp +++ b/src/Stag.cpp @@ -15,6 +15,7 @@ Stag::Stag(int libraryHD, int inErrorCorrection, bool inKeepLogs) { fillCodeLocations(); decoder = Decoder(libraryHD); } + std::vector>> Stag::getContours() { std::vector>> ret; @@ -27,6 +28,7 @@ std::vector>> Stag::getContours() { } return ret; } + std::vector Stag ::getIds() { std::vector ret; for (auto marker : markers) { diff --git a/test_warpper.py b/test_warpper.py index 0af443d..45921be 100644 --- a/test_warpper.py +++ b/test_warpper.py @@ -3,9 +3,13 @@ det = stag.Detector(15, 7, False) -imgPath = "../00003.png" +imgPath = "./00003.png" grayImg = cv2.imread(imgPath, cv2.IMREAD_GRAYSCALE) cv2.imshow("img", grayImg) + print("detected markers Cnt: ", det.detect(grayImg)) print("detected markers's Id: ", det.getIds()) print("detected markers's Coners: ", det.getContours()) + +cv2.waitKey(0) +cv2.destroyAllWindows() \ No newline at end of file