Skip to content
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
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.py text eol=lf
*.sh text eol=lf
*.bash text eol=lf
Dockerfile text eol=lf
Makefile text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
67 changes: 35 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
install/
log/
build/

# Ignore generated docs
*.dox
*.wikidoc

# eclipse stuff
.project
.cproject

# qcreator stuff
CMakeLists.txt.user

srv/_*.py
*.pcd
*.pyc
qtcreator-*
*.user

*~

# Emacs
.#*

# Colcon custom files
COLCON_IGNORE
AMENT_IGNORE

.venv
.need_to_resume_installation
install/
log/
build/

# Ignore generated docs
*.dox
*.wikidoc

# eclipse stuff
.project
.cproject

# qcreator stuff
CMakeLists.txt.user

srv/_*.py
*.pcd
*.pyc
qtcreator-*
*.user

*~

# Emacs
.#*

# Colcon custom files
COLCON_IGNORE
AMENT_IGNORE

.venv
.need_to_resume_installation

# .vscode settings
.vscode/
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2025 OxRAM Society

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2025 OxRAM Society
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# ROS2 stuff
source ./install/local_setup.bash

# https://github.com/ros2/rviz/issues/1245
export QT_QPA_PLATFORM=xcb
8 changes: 4 additions & 4 deletions src/computer_vision/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.roboflow_key

cam_params.yaml
camera_info.yaml
.roboflow_key
cam_params.yaml
camera_info.yaml
34 changes: 17 additions & 17 deletions src/computer_vision/LICENSE
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
42 changes: 21 additions & 21 deletions src/computer_vision/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Setup

1. (Optional) If you are planning on training the YOLO model, copy `.roboflow_key.example` to `.roboflow_key`, get your Roboflow key and write it into the file
2. Get camera calibration and parameter files and put them into `config/cam_params.yaml` and `config/camera_info.yaml`. This can be done in 2 ways:
- Copy over the templates `config/cam_params_template.yaml` and `config/camera_info_template.yaml`. This is done by default in `install.py`.
- Calibrate the camera by yourself (See the section below).

## TODO: add documentation for how to calibrate the camera
TODO: calibrate camera
TODO: optimise params

# Usage
## Running the nodes
`board_detection` node doesn't use any extra parameters: just do `ros2 run computer_vision board_detection`

## Debugging
To start the camera node directly, run `ros2 run usb_cam usb_cam_node_exe --ros-args --params-file config/cam_params.yaml`

To simulate a camera with an image, run `ros2 run stub_scripts compressed_image_publisher --ros-args -p input_path:="test/test_images/chessboards/1.jpeg"`, where the image path can be replaced for other images

To view camera output, run `rqt`, select "Plugins/visualization/Image view" and select the correct topic
# Setup
1. (Optional) If you are planning on training the YOLO model, copy `.roboflow_key.example` to `.roboflow_key`, get your Roboflow key and write it into the file
2. Get camera calibration and parameter files and put them into `config/cam_params.yaml` and `config/camera_info.yaml`. This can be done in 2 ways:
- Copy over the templates `config/cam_params_template.yaml` and `config/camera_info_template.yaml`. This is done by default in `install.py`.
- Calibrate the camera by yourself (See the section below).
## TODO: add documentation for how to calibrate the camera
TODO: calibrate camera
TODO: optimise params
# Usage
## Running the nodes
`board_detection` node doesn't use any extra parameters: just do `ros2 run computer_vision board_detection`
## Debugging
To start the camera node directly, run `ros2 run usb_cam usb_cam_node_exe --ros-args --params-file config/cam_params.yaml`
To simulate a camera with an image, run `ros2 run stub_scripts compressed_image_publisher --ros-args -p input_path:="test/test_images/chessboards/1.jpeg"`, where the image path can be replaced for other images
To view camera output, run `rqt`, select "Plugins/visualization/Image view" and select the correct topic
46 changes: 23 additions & 23 deletions src/computer_vision/config/cam_params_template.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/**:
ros__parameters:
video_device: "/dev/video0"
framerate: 30.0
io_method: "mmap"
frame_id: "camera"
pixel_format: "mjpeg2rgb" # see usb_cam/supported_formats for list of supported formats
av_device_format: "YUV422P"
image_width: 640
image_height: 480
camera_name: "main_camera"
camera_info_url: "package://computer_vision/config/camera_info.yaml"
brightness: -1
contrast: -1
saturation: -1
sharpness: -1
gain: -1
auto_white_balance: true
white_balance: 4000
autoexposure: true
exposure: 100
autofocus: false
focus: -1
/**:
ros__parameters:
video_device: "/dev/video0"
framerate: 30.0
io_method: "mmap"
frame_id: "camera"
pixel_format: "mjpeg2rgb" # see usb_cam/supported_formats for list of supported formats
av_device_format: "YUV422P"
image_width: 640
image_height: 480
camera_name: "main_camera"
camera_info_url: "package://computer_vision/config/camera_info.yaml"
brightness: -1
contrast: -1
saturation: -1
sharpness: -1
gain: -1
auto_white_balance: true
white_balance: 4000
autoexposure: true
exposure: 100
autofocus: false
focus: -1
52 changes: 26 additions & 26 deletions src/computer_vision/config/camera_info_template.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
image_width: 640
image_height: 480
camera_name: main_camera
camera_matrix:
rows: 3
cols: 3
data: [796.62207, 0. , 674.57298,
0. , 856.057 , 586.88776,
0. , 0. , 1. ]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [-0.274258, 0.040343, -0.054555, -0.014826, 0.000000]
rectification_matrix:
rows: 3
cols: 3
data: [1., 0., 0.,
0., 1., 0.,
0., 0., 1.]
projection_matrix:
rows: 3
cols: 4
data: [609.51172, 0. , 633.486 , 0. ,
0. , 844.12219, 583.22598, 0. ,
0. , 0. , 1. , 0. ]
image_width: 640
image_height: 480
camera_name: main_camera
camera_matrix:
rows: 3
cols: 3
data: [796.62207, 0. , 674.57298,
0. , 856.057 , 586.88776,
0. , 0. , 1. ]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [-0.274258, 0.040343, -0.054555, -0.014826, 0.000000]
rectification_matrix:
rows: 3
cols: 3
data: [1., 0., 0.,
0., 1., 0.,
0., 0., 1.]
projection_matrix:
rows: 3
cols: 4
data: [609.51172, 0. , 633.486 , 0. ,
0. , 844.12219, 583.22598, 0. ,
0. , 0. , 1. , 0. ]
54 changes: 27 additions & 27 deletions src/computer_vision/package.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>computer_vision</name>
<version>0.0.0</version>
<description>Camera-based detection of chess pieces, chessboard, etc</description>
<maintainer email="misha.nekrasov@gmail.com">mic</maintainer>
<license>MIT</license>

<exec_depend>usb_cam</exec_depend>
<exec_depend>image_transport_plugins</exec_depend>

<!-- Only required for the launch file of usb_cam, until
https://github.com/ros-drivers/usb_cam/commit/98fa950342fa1edd8fd1de81392aeb83a691af14
is available in Ubuntu repos
-->
<exec_depend>python3-pydantic</exec_depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>computer_vision</name>
<version>0.0.0</version>
<description>Camera-based detection of chess pieces, chessboard, etc</description>
<maintainer email="misha.nekrasov@gmail.com">mic</maintainer>
<license>MIT</license>
<exec_depend>usb_cam</exec_depend>
<exec_depend>image_transport_plugins</exec_depend>
<!-- Only required for the launch file of usb_cam, until
https://github.com/ros-drivers/usb_cam/commit/98fa950342fa1edd8fd1de81392aeb83a691af14
is available in Ubuntu repos
-->
<exec_depend>python3-pydantic</exec_depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<export>
<build_type>ament_python</build_type>
</export>
</package>
8 changes: 4 additions & 4 deletions src/computer_vision/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[develop]
script_dir=$base/lib/computer_vision
[install]
install_scripts=$base/lib/computer_vision
[develop]
script_dir=$base/lib/computer_vision
[install]
install_scripts=$base/lib/computer_vision
8 changes: 4 additions & 4 deletions src/computer_vision/train/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data/**

# The model
yolov8n.pt
data/**
# The model
yolov8n.pt
2 changes: 1 addition & 1 deletion src/computer_vision/train/.roboflow_key.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
YOUR_KEY_HERE
YOUR_KEY_HERE
6 changes: 3 additions & 3 deletions src/computer_vision/train/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ultralytics==8.3.73
roboflow==1.1.53
supervision==0.25.1
ultralytics==8.3.73
roboflow==1.1.53
supervision==0.25.1
Loading