The goal was to find a way to discover partially shadowed objects and the precache together with hook as single blobs to make object size estimation more precise and to determine hook orientation for precache. It appeared this simple filter does this trick good enough compared to other solutions I saw.
It turns out that the following simple function is already a good detector for srrc samples we have:
cv::Mat makeObjectMask( cv::Mat const& src_bgr_image
, int saturation_threshold = 168
, int brightness_threshold = 20)
{
cv::Mat hsv_image = src_bgr_image.clone();
cv::cvtColor(hsv_image, hsv_image, cv::COLOR_BGR2HSV);
std::vector<cv::Mat> hsv_channels;
cv::split(hsv_image, hsv_channels);
return (hsv_channels[1] < saturation_threshold) & (hsv_channels[2] >= brightness_threshold);
}
Of course this simple rule will not work on sand or asphalt surface or with objects colored by other paints or with different camera settings or lightning conditions.
every blob that's not exactly black is an object candidate. no farther filtering used.
- check out this repo into your catkin_ws and
catkin_make
- open file
test_simple_detector_node.launch
- replace the value for parameter
src_image_src_folder
with path to your folder containing jpg files - replace the value for parameter
output_folder
with the path you want to output the processed images to (it will be created if it does not exist). Everytime you run this node in this folder will be automatically created a subfolder with the name generated from timestamp where the result images are output, so it's ok to specify the value foroutput_folder
only once and then use it unchanged. - call
roslaunch srrc_simple_obj_detector test_simple_detector_node.launch
and wait.
- check out this repo into your catkin_ws and
catkin_make
- open file
simple_detector_node.launch
- replace the value for parameter
input_image_topic
with the name of your image topic - if the image topic is publishing uncompressed images set the value for parameter
input_image_transfer_hint
to 'raw' - call
roslaunch srrc_simple_obj_detector simple_detector_node.launch
- call `rqt_image_view' (f.e.) to see the published processed images.