Rudimentary custom dataset collector for OnePose.
This dataset collector uses a diamond-shaped aruco board to obtain poses. There are two implementations:
detect_arucoboard_realsense.py
if you are using an Intel Realsense camera. Install the Realsense SDK and its Python wrapper (which can be pip-installed withpip3 install pyrealsense2
).detect_arucoboard_opencv.py
if you are using any other camera that can be picked up bycv2.VideoCapture
. You will need to calibrate your camera and provide the intrinsic matrix as a 3x3 NumPy array, stored as a.txt
file (withnp.savetxt
), underconfigs/intrin/
Addendum: OpenCV camera calibration guide here.
Only OpenCV and NumPy are required. Install them using pip
.
The board provided is a diamond-shaped aruco board generated by OpenCV.
You may choose to modify the square length (sl
) and marker length (ml
), and the aruco markers themselves of the board by
adding your own .json
config, stored in configs/aruco
. I have provided a sample config (sl200_ml120.json
).
Run arucoboard.py
to generate the board as a .png
file. The file can be found in out/aruco/
. Example:
python3 arucoboard.py --config sl200_ml120
Print the .png
file and lay it flat on a surface.
Place your desired object in the middle of the board. If the object is too big (covers all 4 aruco markers), you may wish to generate a board with smaller aruco markers by changing the ml
parameter in the config file.
Simply run detect_arucoboard_realsense.py
, specifying the aruco board config file you used to generate your board with --config
and the name of the dataset you wish to save it as with --name
.
Example:
python3 detect_arucoboard_realsense.py --config sl200_ml120 --name empty
Save the image, the corresponding intrinsic matrix and the pose by pressing spacebar
. Press q
to quit the program.
Your dataset is saved in out/datasets/
.
You will need to place your camera intrinsic file in configs/intrin
.
Run detect_arucoboard_opencv.py
. You will need to specify your camera parameters as flags. Example:
python3 detect_arucoboard_opencv.py --intrin intrin_ps3 --width 640 --height 480 --camidx 0 --config sl200_ml120 --name empty
Change --camidx
to choose your desired camera if you have multiple cameras.
Save the image, the corresponding intrinsic matrix and the pose by pressing spacebar
. Press q
to quit the program.
Your dataset is saved in out/datasets/
.
- 'w' and 's': change the height of your pose from the board
- 'e' and 'd': change the x-width of your bounding box.
- 'r' and 'f': change the y-width of your bounding box.
- 't' and 'g': change the height of your bounding box.
- 'spacebar': record your data (RGB, poses, intrinsics, bounding box).
- 'q': exit the program.
Most of the functions in utils.py
used for cropping and obtaining post-crop intrinsics are taken from the original OnePose repository.