Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements for windows compilation #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#app
__pycache__/
/app/
/build/
/Vocabulary/*
/build/
/.vscode/
/lib/
/datasets/
/ref/marker_image/
pyStag.egg-info/




Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

cmake_minimum_required(VERSION 3.20)
project(Stag)

IF(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -36,6 +36,7 @@ add_library(
)
target_link_libraries(
LibStag
PRIVATE
${OpenCV_LIBS}
)

Expand All @@ -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)
Expand All @@ -61,6 +62,7 @@ pybindSrc/opencv2numpy/converter.cpp
)

target_link_libraries(pyStag
PRIVATE
${OpenCV_LIBS}
LibStag
)
Expand All @@ -75,5 +77,6 @@ add_executable(

target_link_libraries(
testrun
PRIVATE
LibStag
)
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Stag.h"
#include "opencv2/opencv.hpp"

#include <iostream>
#include <opencv2/highgui.hpp>

Expand Down
6 changes: 3 additions & 3 deletions pybindSrc/pyStag.cpp
Original file line number Diff line number Diff line change
@@ -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 <pybind11/cast.h>
#include <pybind11/complex.h>
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -38,7 +38,7 @@ def run(self):
author_email="[email protected]",
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.
Expand Down
4 changes: 2 additions & 2 deletions src/ED/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include <chrono>
#include <ctime>
#include <sys/_types/_int64_t.h>
#include <sys/_types/_timespec.h>
#include <sys/types.h>
//#include <sys/_types/_timespec.h>

class Timer {
private:
Expand Down
2 changes: 2 additions & 0 deletions src/Stag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Stag::Stag(int libraryHD, int inErrorCorrection, bool inKeepLogs) {
fillCodeLocations();
decoder = Decoder(libraryHD);
}

std::vector<std::vector<std::vector<double>>> Stag::getContours() {

std::vector<std::vector<std::vector<double>>> ret;
Expand All @@ -27,6 +28,7 @@ std::vector<std::vector<std::vector<double>>> Stag::getContours() {
}
return ret;
}

std::vector<int> Stag ::getIds() {
std::vector<int> ret;
for (auto marker : markers) {
Expand Down
6 changes: 5 additions & 1 deletion test_warpper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()