Skip to content

Commit

Permalink
Chore: update repo with latest fork (#1)
Browse files Browse the repository at this point in the history
We still need to decide what's the best way to deal with 2 different stag repos
  • Loading branch information
JasperTan97 committed Feb 8, 2024
1 parent 3bd35e0 commit f1452d2
Show file tree
Hide file tree
Showing 75 changed files with 126 additions and 27,428 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

71 changes: 17 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
cmake_minimum_required(VERSION 3.16)
project(Stag)
cmake_minimum_required(VERSION 3.2)
PROJECT(STag VERSION 0.0.0 LANGUAGES CXX)

IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(BUILD_TESTING OFF)

MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})
find_package(OpenCV REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/include)

IF (WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
ENDIF (WIN32)
FILE(GLOB_RECURSE SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -w ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -w ")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(BUILD_TESTING)
add_executable(stag_main ${PROJECT_SOURCE_DIR}/src/example.cpp)
target_link_libraries(stag_main ${OpenCV_LIBS} ${PROJECT_NAME})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
install(TARGETS ${PROJECT_NAME}
DESTINATION lib)

find_package(OpenCV 4 REQUIRED)

file(GLOB SRC_FILE1 "src/*.c*")
file(GLOB SRC_FILE2 "src/ED/*.c*")

include_directories(
${OpenCV_INCLUDE_DIRS}
src/
src/ED/
)
add_library(
staglib
${SRC_FILE1}
${SRC_FILE2}
src/Stag.cpp
src/Stag.h
)
target_link_libraries(
staglib
${OpenCV_LIBS}
)

add_executable(
stag_example
main.cpp
)

target_link_libraries(
stag_example
staglib
)

IF (MSVC)
set_target_properties(stag_example PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set_target_properties(stag_example PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR})
set_target_properties(stag_example PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR})
ENDIF (MSVC)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include)
114 changes: 41 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,63 @@
# STag - A Stable, Occlusion-Resistant Fiducial Marker System
# STag: A Stable Fiducial Marker System

This repository is an improved and updated fork of the [stable fiducial marker system](https://github.com/bbenligiray/stag), using __OpenCV 4__.
Code used in the following paper:

> [!NOTE]
> For the corresponding __Python__ package, refer to: https://github.com/ManfredStoiber/stag-python.
[B. Benligiray; C. Topal; C. Akinlar, "STag: A Stable Fiducial Marker System," Image and Vision Computing (Accepted), 2019.](https://arxiv.org/abs/1707.06292)

## 📊 Comparison Between Different Marker Systems:
[<img src="https://github.com/ManfredStoiber/stag/assets/47210077/668ca457-33dd-4ce7-8b94-662c7a5bb4d9" width="400" height="200" />](https://www.youtube.com/watch?v=vnHI3GzLVrY)
Markers (will provide a generation script in the future):

## 📖 Usage
```c++
// load image
cv::Mat image = cv::imread("example.jpg");
https://drive.google.com/drive/folders/0ByNTNYCAhWbIV1RqdU9vRnd2Vnc

// set HD library
int libraryHD = 21;
### TODO:
* Add a makefile
* Write Matlab and Python wrappers

auto corners = std::vector<std::vector<cv::Point2f>>();
auto ids = std::vector<int>();
auto rejectedImgPoints = std::vector<std::vector<cv::Point2f>>(); // optional, helpful for debugging
[![Supplementary Video](https://user-images.githubusercontent.com/19530665/57184379-6a250580-6ec3-11e9-8ab3-7e139966f13b.png)](https://www.youtube.com/watch?v=vnHI3GzLVrY)

// detect markers
stag::detectMarkers(image, libraryHD, corners, ids, rejectedImgPoints);
Some figures from the paper:

// draw and save results
stag::drawDetectedMarkers(image, corners, ids);
cv::imwrite("example_result.jpg", image);
```
For an explanation of `libraryHD = 21` refer to [Configuration](#-configuration)
## 🏷 Markers
- Markers are downloadable here: [Drive](https://drive.google.com/drive/folders/0ByNTNYCAhWbIV1RqdU9vRnd2Vnc?resourcekey=0-9ipvecbezW8EWUva5GBQTQ&usp=sharing)
- Reference code for Marker Generator: [ref/marker_generator](https://github.com/ManfredStoiber/stag/tree/master/ref/marker_generator)
## 📋 Getting Started
0. __Install__ Prerequisites
<p align="center">
<img src="https://user-images.githubusercontent.com/19530665/57179654-c0c11e00-6e88-11e9-9ca5-0c0153b28c91.png"/>
</p>

[__CMake__ >= 3.16](https://cmake.org/getting-started/)
- On Linux: `apt install cmake`
<p align="center">
<img src="https://user-images.githubusercontent.com/19530665/57179660-cae31c80-6e88-11e9-8f80-bf8e24e59957.png"/>
</p>

[__OpenCV__ 4](https://opencv.org/get-started/) for C++
- On Linux: `apt install libopencv-dev`
1. __Clone__ this repository
- `git clone https://github.com/ManfredStoiber/stag`
2. __Build__ the project.
## Dockerfile and example code:

In the project directory, run the following commands:
1. `mkdir build`
2. `cd build`
3. `cmake ..`
4. `cmake --build .`
3. __Run__ the example
- On Linux: Run `./stag_example`
- On Windows: Run `stag_example.exe`
Set BUILD_TESTING in CMakeLists to ON, and build the Dockerfile

This example application detects the markers in `../example.jpg` and saves the visualized results to `example_result.jpg`
### Dockerfile

> [!NOTE]
> The library is created as static by default. If you want to create a shared library instead, use the cmake option `BUILD_SHARED_LIBS=ON`.
``` Dockerfile
# syntax=docker/dockerfile:1

## 🛠 Configuration
When initializing the library, following parameters can be specified:
- __`libraryHD`__:
- Sets the "family" or "type" of used STag markers
- Each library has a different amount of markers
- Only the markers of the chosen library will be detected
- The following HD libraries are possible:
# Use an official Ubuntu runtime as the base image
FROM ubuntu:22.04

| __HD__ | 11 | 13 | 15 | 17 | 19 | 21 | 23 |
|------------------|--------|-------|-----|-----|----|----|----|
| __Library Size__ | 22,309 | 2,884 | 766 | 157 | 38 | 12 | 6 |
# Update the system
RUN apt-get update -y && apt-get upgrade -y

- Specifies the used Hamming Distance, for further information refer to the [original paper](https://arxiv.org/abs/1707.06292)
# Install OpenCV
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libopencv-dev cmake g++
# RUN apt-get install -y g++

# Copy the current directory contents into the container at /app
COPY . /app

- __`errorCorrection`__:
- Sets the amount of error correction
- Has to be in range `0 <= errorCorrection <= (libraryHD-1)/2`
- For further information refer to the [original paper](https://arxiv.org/abs/1707.06292)
# Set the working directory to /app
WORKDIR /app

## 📰 Originally Published in the Following Paper:
# Create a build directory and navigate into it
RUN mkdir build && cd build

[B. Benligiray; C. Topal; C. Akinlar, "STag: A Stable Fiducial Marker System," Image and Vision Computing, 2019.](https://arxiv.org/abs/1707.06292)
# Run CMake to generate the Makefile
RUN cmake .

<p align="center">
<img src="https://user-images.githubusercontent.com/19530665/57179654-c0c11e00-6e88-11e9-9ca5-0c0153b28c91.png"/>
</p>
# Build the project
RUN make

<p align="center">
<img src="https://user-images.githubusercontent.com/19530665/57179660-cae31c80-6e88-11e9-8f80-bf8e24e59957.png"/>
</p>
# Run the compiled binary
CMD ["./stag_main"]
```
Binary file removed example.jpg
Binary file not shown.
Binary file added example/STag-HD23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/STag-HDS23-detected-markers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions main.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions ref/marker_generator/App.config

This file was deleted.

90 changes: 0 additions & 90 deletions ref/marker_generator/EDMarker Generator.csproj

This file was deleted.

Loading

0 comments on commit f1452d2

Please sign in to comment.