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

Apriltags #151

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
975ca61
:see_no_evil: Added emacs temp file to .gitignore
rhololkeolke Sep 30, 2019
73bc2e4
:see_no_evil: Added ccls cache to gitignore
rhololkeolke Sep 30, 2019
5ea3fac
:see_no_evil: Added compile_commands.json to gitignore
rhololkeolke Sep 30, 2019
94084c5
:sparkles: Added Greyscale vision plugin
rhololkeolke Sep 30, 2019
39a437a
:sparkles: Added greyscale plugin to robocup stack
rhololkeolke Sep 30, 2019
1c096c2
:recycle: Using PluginGreyscale output in visualize greyscale
rhololkeolke Sep 30, 2019
2002389
:bug: Added const qualifier to CameraCalibration::getWorldLocation()
rhololkeolke Oct 11, 2019
27d5430
:bug: Fixed field lines from being changed on reload
rhololkeolke Oct 11, 2019
490a6d0
:sparkles: Added use apriltag option to cmake
rhololkeolke Sep 30, 2019
2a0bf69
:sparkles: Added apriltag vision plugin
rhololkeolke Sep 30, 2019
c9e7567
:sparkles: Adding apriltag plugin to robocup stack
rhololkeolke Sep 30, 2019
f94a64b
:sparkles: Drawing detected april tags
rhololkeolke Sep 30, 2019
6670306
:sparkles: Added Custom20h7 tag group
rhololkeolke Oct 10, 2019
8503a27
:sparkles: Adding detected robot to proto message
rhololkeolke Oct 10, 2019
fd33611
:sparkles: Added a team tags class to map april tags to team colors
rhololkeolke Oct 25, 2019
3d86d28
:sparkles: Using TeamTag map settings in apriltags detector
rhololkeolke Oct 25, 2019
55e6d94
:sparkles: Using Team Height from team selector in apriltag
rhololkeolke Oct 25, 2019
088a1fe
:wastebasket: Removed dbg statements
rhololkeolke Oct 25, 2019
c9333d9
:books: Added documentation about the apriltags to the README
rhololkeolke Oct 25, 2019
b53b308
Conditionally include apriltag header
g3force Nov 3, 2019
dce2e36
Add apriltag to circleci pipeline
g3force Jan 18, 2020
a6b3787
:sparkles: Use masked image in apriltags detector
rhololkeolke Jan 29, 2020
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
86 changes: 71 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,93 @@ jobs:
steps:
- run: apt-get update -qq && apt-get install -qq git
- checkout
- run: DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run: make
- run:
name: "Install dependencies"
command: |
DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run:
name: "Build"
command: make
build-v4l:
docker:
- image: ubuntu:18.04
- image: ubuntu:18.04
steps:
- run: apt-get update -qq && apt-get install -qq git
- checkout
- run: DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run: mkdir -p build && cd build && cmake -DUSE_V4L=true .. && cd ..
- run: make
- run:
name: "Install dependencies"
command: |
DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run:
name: "Configure"
command: |
mkdir -p build
cmake -B build -DUSE_V4L=true .
- run:
name: "Build"
command: make
build-splitter:
docker:
- image: ubuntu:18.04
steps:
- run: apt-get update -qq && apt-get install -qq git
- checkout
- run: DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run: mkdir -p build && cd build && cmake -DUSE_SPLITTER=true .. && cd ..
- run: cmake -B build -DUSE_SPLITTER=true .
- run: make
- run:
name: "Install dependencies"
command: |
DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run:
name: "Configure"
command: |
mkdir -p build
cmake -B build -DUSE_SPLITTER=true .
- run:
name: "Build"
command: make
build-qt5:
docker:
- image: ubuntu:18.04
steps:
- run: apt-get update -qq && apt-get install -qq git
- checkout
- run: DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run: apt-get install -qq qtdeclarative5-dev
- run: mkdir -p build && cd build && cmake -DUSE_QT5=true .. && cd ..
- run: cmake -B build -DUSE_QT5=true .
- run: make
- run:
name: "Install dependencies"
command: |
DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
apt-get install -qq qtdeclarative5-dev
- run:
name: "Configure"
command: |
mkdir -p build
cmake -B build -DUSE_QT5=true .
- run:
name: "Build"
command: make
build-apriltag:
docker:
- image: ubuntu:18.04
steps:
- run: apt-get update -qq && apt-get install -qq git
- checkout
- run:
name: "Install dependencies"
command: |
DEBIAN_FRONTEND=noninteractive ./InstallPackagesUbuntu.sh
- run:
name: "Install april tag"
command: |
git clone https://github.com/AprilRobotics/apriltag.git
cd apriltag
cmake .
make install
- run:
name: "Configure"
command: |
mkdir -p build
cmake -B build -DUSE_APRILTAG=true .
- run:
name: "Build"
command: make

workflows:
version: 2
Expand All @@ -47,3 +102,4 @@ workflows:
- build-v4l
- build-splitter
- build-qt5
- build-apriltag
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
/backup
/test-data/**
/.idea
/.dir-locals.el
.ccls-cache
*~
cmake-build*
/compile_commands.json
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(USE_PYLON FALSE CACHE BOOL "Compile with pylon driver (Basler cameras)")
set(USE_FLYCAP FALSE CACHE BOOL "Compile with flycap driver (FLIR cameras, predecessor of Spinnaker)")
set(USE_V4L FALSE CACHE BOOL "Compile with Video4Linux support (generic webcams)")
set(USE_SPLITTER FALSE CACHE BOOL "Compile with Camera splitter support (virtual cameras with part of a full image)")
set(USE_APRILTAG FALSE CACHE BOOL "Compile with apriltag detection for robots")

if(USE_DC1394 AND USE_mvIMPACT)
message(FATAL_ERROR "DC1394 and mvImpact are not compatible: mvImpact crashes when creating device manager")
Expand Down Expand Up @@ -190,6 +191,15 @@ else()
message(STATUS "Camera splitter disabled")
endif()

if(USE_APRILTAG)
find_package(apriltag REQUIRED)
add_definitions(-DAPRILTAG)
set(SRCS ${SRCS} src/app/plugins/plugin_apriltag.cpp)
message(STATUS "apriltag enabled")
else()
message(STATUS "apriltag disabled")
endif()

include_directories(${PROJECT_SOURCE_DIR}/src/app)
include_directories(${PROJECT_SOURCE_DIR}/src/app/gui)
include_directories(${PROJECT_SOURCE_DIR}/src/app/plugins)
Expand Down Expand Up @@ -220,6 +230,7 @@ set (SRCS ${SRCS}
src/app/plugins/plugin_detect_balls.cpp
src/app/plugins/plugin_detect_robots.cpp
src/app/plugins/plugin_find_blobs.cpp
src/app/plugins/plugin_greyscale.cpp
src/app/plugins/plugin_publishgeometry.cpp
src/app/plugins/plugin_legacypublishgeometry.cpp
src/app/plugins/plugin_runlength_encode.cpp
Expand Down Expand Up @@ -347,6 +358,9 @@ set (libs ${QT_LIBRARIES}
${SPINNAKER_LIBS}
)
target_link_libraries(sslvision ${libs})
if(USE_APRILTAG)
target_link_libraries(sslvision apriltag)
endif()
if(USE_QT5)
qt5_use_modules(sslvision Widgets)
endif()
Expand All @@ -356,6 +370,9 @@ set (libs ${libs} sslvision)
set (target vision)
add_executable(${target} ${UI_SRCS} ${MOC_SRCS} ${RC_SRCS} ${SRCS})
target_link_libraries(${target} ${libs})
if (USE_APRILTAG)
target_link_libraries(${target} apriltag)
endif()
if(USE_QT5)
qt5_use_modules(${target} Widgets OpenGL)
endif()
Expand Down
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,44 @@ cmake -DUSE_WHAT_SO_EVER=true ..
cd ..
make
```
The `USE_*` parameters are cached, so they do not have to be passed in each time.
The `USE_*` parameters are cached, so they do not have to be passed in
each time.

### Apriltags Support

There is experimental support for detecting and tracking robots via
[Apriltags](https://april.eecs.umich.edu/software/apriltag). The
standard tag sets in the [Apriltags Imgs
Repo](https://github.com/AprilRobotics/apriltag-imgs) are all
supported along with two customized tag sets:

- Custom20h7: 26 unique tags

To generate the custom tag images you must use the
[Apriltag-Generation
Repo](https://github.com/AprilRobotics/apriltag-generation). Follow
the instructions listed in the repo. The tag layouts are as follows:

- Custom20h7

custom_xxddddxxxwwwwwwxdwbbbbwddwbddbwddwbddbwddwbbbbwdxwwwwwwxxxddddxx

The hamming distance used during generation are as follows:

- Custom20h7: 7

To enable you must set the `USE_APRILTAG` option to `ON`. e.g.:

``` bash
cd build
cmake -DUSE_APRILTAG=ON ..
cd ..
make
```

This will add a new plugin to each camera that runs on every frame. At
the moment the old robot detection patterns are detected in addition
to the apriltag detection.

## Running

Expand Down Expand Up @@ -199,3 +236,40 @@ program refuses to start completely when parsing the XML files
(this should normally never occur) then simply delete all
XML files and restart. The program will restore its default
settings.

#### Apriltags

Unlike the butterfly pattern, there are no colors in the apriltags. So
you must manually assign tag ids to the different team colors. Under
Global settings there are two settings list "Blue April Tags" and
"Yellow April Tags". Expand each list and click "Add Tag" to create a
new tag entry for the associated team color. Expand the new entry and
edit the value to a valid tag id in order to begin detection.

You must also configure the apriltag detection settings. The settings
are per camera under the "AprilTag" settings in each thread. Select
the tag family and configure the size in mm of the side of the
Apriltag quad. See the apriltags repository for explanation of the
other options and how they affect detection accuracy and speed.

Apriltag detection takes place on a greyscale version of the image. To
see this image enable "greyscale" un the Visualization plugin for the
appropriate camera. If a tag is not detecting check the greyscale
image contrast. Verify that the tag doesn't have a glare or a large
contrast due to shadows.

Under the Visualization plugin you can also enable the "detected
AprilTags" option. This will draw a cyan border around the quad of the
tag (i.e. the part you should measure and enter as quad size in the
detector settings). It will also draw the tag id in magenta over the
detected tag.

##### Large Distortions

Currently, the tag detection runs on a raw image provided by the
camera to maximize performance. Fixes for distortion happen *AFTER*
detection. However, the apriltag detector is designed to work on
undistorted (aka rectified) images. If your camera lens has a large
distortion (you can see this by the field lines and other image lines
being highly curved), then the detection accuracy may be lower or even
fail.
Loading