From 6b9d90d3d7363fe7dadaab5ecd93553ecfaee2c2 Mon Sep 17 00:00:00 2001 From: Alexey Rogachevskiy Date: Wed, 18 Mar 2020 19:17:17 +0300 Subject: [PATCH] aruco_pose: Use bash trampoline for dynamic_reconfigure --- aruco_pose/cfg/DetectorParams.cfg | 113 +++--------------------------- aruco_pose/cfg/DetectorParams.py | 107 ++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 105 deletions(-) create mode 100755 aruco_pose/cfg/DetectorParams.py diff --git a/aruco_pose/cfg/DetectorParams.cfg b/aruco_pose/cfg/DetectorParams.cfg index ed4a18d3..663b730a 100755 --- a/aruco_pose/cfg/DetectorParams.cfg +++ b/aruco_pose/cfg/DetectorParams.cfg @@ -1,107 +1,10 @@ -#!/usr/bin/env python3 -PACKAGE = "aruco_pose" +#!/usr/bin/env bash -from dynamic_reconfigure.parameter_generator_catkin import * -import cv2.aruco +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +if [ "x${ROS_PYTHON_VERSION}" == "x3" ]; then + PYTHON=python3 +else + PYTHON=python2 +fi -p = cv2.aruco.DetectorParameters_create() - -gen = ParameterGenerator() - -gen.add("adaptiveThreshConstant", double_t, 0, - "Constant for adaptive thresholding before finding contours", - p.adaptiveThreshConstant, 0, 100) - -gen.add("adaptiveThreshWinSizeMin", int_t, 0, - "Minimum window size for adaptive thresholding before finding contours", - p.adaptiveThreshWinSizeMin, 1, 100) - -gen.add("adaptiveThreshWinSizeMax", int_t, 0, - "Maximum window size for adaptive thresholding before finding contours", - p.adaptiveThreshWinSizeMax, 1, 100) - -gen.add("adaptiveThreshWinSizeStep", int_t, 0, - "Increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax during the thresholding", - p.adaptiveThreshWinSizeStep, 1, 100) - -gen.add("cornerRefinementMaxIterations", int_t, 0, - "Maximum number of iterations for stop criteria of the corner refinement process", - p.cornerRefinementMaxIterations, 1, 1000) - -corner_refine_enum = gen.enum([ gen.const("CORNER_REFINE_NONE", int_t, 0, "No refinement"), - gen.const("CORNER_REFINE_SUBPIX", int_t, 1, "Do subpixel refinement"), - gen.const("CORNER_REFINE_CONTOUR", int_t, 2, "Use contour-Points"), - gen.const("CORNER_REFINE_APRILTAG", int_t, 3, "Use the AprilTag2 approach")], - "An enum to set corner refinement method") - -gen.add("cornerRefinementMethod", int_t, 0, "Corner refinement method", 0, 0, 3, edit_method=corner_refine_enum) - -gen.add("cornerRefinementMinAccuracy", double_t, 0, - "Minimum error for the stop criteria of the corner refinement process", - p.cornerRefinementMinAccuracy, 0, 1) - -gen.add("cornerRefinementWinSize", int_t, 0, - "Window size for the corner refinement process (in pixels)", - p.cornerRefinementWinSize, 1, 100) - -gen.add("detectInvertedMarker", bool_t, 0, - "check if there is a white marker. In order to generate a 'white' marker just invert a normal marker by using a tilde", - False) - -gen.add("errorCorrectionRate", double_t, 0, - "Error correction rate respect to the maximum error correction capability for each dictionary", - p.errorCorrectionRate, 0, 1) - -gen.add("minCornerDistanceRate", double_t, 0, - "Minimum distance between corners for detected markers relative to its perimeter", - p.minCornerDistanceRate, 0, 0.25) - -gen.add("markerBorderBits", int_t, 0, - "Number of bits of the marker border, i.e. marker border width", - p.markerBorderBits, 1, 10) - -gen.add("maxErroneousBitsInBorderRate", double_t, 0, - "Maximum number of accepted erroneous bits in the border (i.e. number of allowed white bits in the border)", - p.maxErroneousBitsInBorderRate, 0, 1) - -gen.add("minDistanceToBorder", int_t, 0, - "Minimum distance of any corner to the image border for detected markers (in pixels)", - p.minDistanceToBorder, 0, 1000) - -gen.add("minMarkerDistanceRate", double_t, 0, - "minimum mean distance beetween two marker corners to be considered similar, so that the smaller one is removed. The rate is relative to the smaller perimeter of the two markers", - p.minMarkerDistanceRate, 0, 1) - -gen.add("minMarkerPerimeterRate", double_t, 0, - "Determine minimum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image", - p.minMarkerPerimeterRate, 0, 4) - -gen.add("maxMarkerPerimeterRate", double_t, 0, - "Determine maximum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image", - p.maxMarkerPerimeterRate, 0, 4) - -gen.add("minOtsuStdDev", double_t, 0, - "Minimun standard deviation in pixels values during the decodification step to apply Otsu thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not)", - p.minOtsuStdDev, 0, 100) - -gen.add("perspectiveRemoveIgnoredMarginPerCell", double_t, 0, - "Width of the margin of pixels on each cell not considered for the determination of the cell bit. Represents the rate respect to the total size of the cell, i.e. perpectiveRemovePixelPerCell", - p.perspectiveRemoveIgnoredMarginPerCell, 0, 1) - -gen.add("perspectiveRemovePixelPerCell", int_t, 0, - "Number of bits (per dimension) for each cell of the marker when removing the perspective", - p.perspectiveRemovePixelPerCell, 1, 100) - -gen.add("polygonalApproxAccuracyRate", double_t, 0, - "Minimum accuracy during the polygonal approximation process to determine which contours are squares", - p.polygonalApproxAccuracyRate, 0, 1) - -gen.add("aprilTagQuadDecimate", double_t, 0, - "Detection of quads can be done on a lower-resolution image, improving speed at a cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still done at full resolution", - 0, 0, 1000) - -gen.add("aprilTagQuadSigma", double_t, 0, - "What Gaussian blur should be applied to the segmented image (used for quad detection?) Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values", - 0, 0, 1000) - -exit(gen.generate(PACKAGE, "aruco_pose", "Detector")) +/usr/bin/env ${PYTHON} ${SCRIPT_DIR}/DetectorParams.py "$@" diff --git a/aruco_pose/cfg/DetectorParams.py b/aruco_pose/cfg/DetectorParams.py new file mode 100755 index 00000000..ed4a18d3 --- /dev/null +++ b/aruco_pose/cfg/DetectorParams.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +PACKAGE = "aruco_pose" + +from dynamic_reconfigure.parameter_generator_catkin import * +import cv2.aruco + +p = cv2.aruco.DetectorParameters_create() + +gen = ParameterGenerator() + +gen.add("adaptiveThreshConstant", double_t, 0, + "Constant for adaptive thresholding before finding contours", + p.adaptiveThreshConstant, 0, 100) + +gen.add("adaptiveThreshWinSizeMin", int_t, 0, + "Minimum window size for adaptive thresholding before finding contours", + p.adaptiveThreshWinSizeMin, 1, 100) + +gen.add("adaptiveThreshWinSizeMax", int_t, 0, + "Maximum window size for adaptive thresholding before finding contours", + p.adaptiveThreshWinSizeMax, 1, 100) + +gen.add("adaptiveThreshWinSizeStep", int_t, 0, + "Increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax during the thresholding", + p.adaptiveThreshWinSizeStep, 1, 100) + +gen.add("cornerRefinementMaxIterations", int_t, 0, + "Maximum number of iterations for stop criteria of the corner refinement process", + p.cornerRefinementMaxIterations, 1, 1000) + +corner_refine_enum = gen.enum([ gen.const("CORNER_REFINE_NONE", int_t, 0, "No refinement"), + gen.const("CORNER_REFINE_SUBPIX", int_t, 1, "Do subpixel refinement"), + gen.const("CORNER_REFINE_CONTOUR", int_t, 2, "Use contour-Points"), + gen.const("CORNER_REFINE_APRILTAG", int_t, 3, "Use the AprilTag2 approach")], + "An enum to set corner refinement method") + +gen.add("cornerRefinementMethod", int_t, 0, "Corner refinement method", 0, 0, 3, edit_method=corner_refine_enum) + +gen.add("cornerRefinementMinAccuracy", double_t, 0, + "Minimum error for the stop criteria of the corner refinement process", + p.cornerRefinementMinAccuracy, 0, 1) + +gen.add("cornerRefinementWinSize", int_t, 0, + "Window size for the corner refinement process (in pixels)", + p.cornerRefinementWinSize, 1, 100) + +gen.add("detectInvertedMarker", bool_t, 0, + "check if there is a white marker. In order to generate a 'white' marker just invert a normal marker by using a tilde", + False) + +gen.add("errorCorrectionRate", double_t, 0, + "Error correction rate respect to the maximum error correction capability for each dictionary", + p.errorCorrectionRate, 0, 1) + +gen.add("minCornerDistanceRate", double_t, 0, + "Minimum distance between corners for detected markers relative to its perimeter", + p.minCornerDistanceRate, 0, 0.25) + +gen.add("markerBorderBits", int_t, 0, + "Number of bits of the marker border, i.e. marker border width", + p.markerBorderBits, 1, 10) + +gen.add("maxErroneousBitsInBorderRate", double_t, 0, + "Maximum number of accepted erroneous bits in the border (i.e. number of allowed white bits in the border)", + p.maxErroneousBitsInBorderRate, 0, 1) + +gen.add("minDistanceToBorder", int_t, 0, + "Minimum distance of any corner to the image border for detected markers (in pixels)", + p.minDistanceToBorder, 0, 1000) + +gen.add("minMarkerDistanceRate", double_t, 0, + "minimum mean distance beetween two marker corners to be considered similar, so that the smaller one is removed. The rate is relative to the smaller perimeter of the two markers", + p.minMarkerDistanceRate, 0, 1) + +gen.add("minMarkerPerimeterRate", double_t, 0, + "Determine minimum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image", + p.minMarkerPerimeterRate, 0, 4) + +gen.add("maxMarkerPerimeterRate", double_t, 0, + "Determine maximum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image", + p.maxMarkerPerimeterRate, 0, 4) + +gen.add("minOtsuStdDev", double_t, 0, + "Minimun standard deviation in pixels values during the decodification step to apply Otsu thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not)", + p.minOtsuStdDev, 0, 100) + +gen.add("perspectiveRemoveIgnoredMarginPerCell", double_t, 0, + "Width of the margin of pixels on each cell not considered for the determination of the cell bit. Represents the rate respect to the total size of the cell, i.e. perpectiveRemovePixelPerCell", + p.perspectiveRemoveIgnoredMarginPerCell, 0, 1) + +gen.add("perspectiveRemovePixelPerCell", int_t, 0, + "Number of bits (per dimension) for each cell of the marker when removing the perspective", + p.perspectiveRemovePixelPerCell, 1, 100) + +gen.add("polygonalApproxAccuracyRate", double_t, 0, + "Minimum accuracy during the polygonal approximation process to determine which contours are squares", + p.polygonalApproxAccuracyRate, 0, 1) + +gen.add("aprilTagQuadDecimate", double_t, 0, + "Detection of quads can be done on a lower-resolution image, improving speed at a cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still done at full resolution", + 0, 0, 1000) + +gen.add("aprilTagQuadSigma", double_t, 0, + "What Gaussian blur should be applied to the segmented image (used for quad detection?) Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values", + 0, 0, 1000) + +exit(gen.generate(PACKAGE, "aruco_pose", "Detector"))