36 #ifndef JSK_RECOGNITION_UTILS_CV_UTILS_H_ 37 #define JSK_RECOGNITION_UTILS_CV_UTILS_H_ 39 #include <opencv2/opencv.hpp> 40 #if ( CV_MAJOR_VERSION >= 4) 41 #include <opencv2/imgproc/imgproc_c.h> 43 #include <jsk_recognition_msgs/HistogramWithRangeBin.h> 55 float min_value,
float max_value,
56 const cv::Mat& mask_image);
62 std::vector<jsk_recognition_msgs::HistogramWithRangeBin>
71 const std::vector<jsk_recognition_msgs::HistogramWithRangeBin>& histogram);
78 const jsk_recognition_msgs::HistogramWithRangeBin& right);
92 std::vector<jsk_recognition_msgs::HistogramWithRangeBin>
102 const jsk_recognition_msgs::HistogramWithRangeBin& bin,
103 float min_width_value,
104 float max_width_value,
105 float max_height_value,
112 void labelToRGB(
const cv::Mat src, cv::Mat& dst);
125 bool isBGR(
const std::string& encoding);
126 bool isRGB(
const std::string& encoding);
127 bool isBGRA(
const std::string& encoding);
128 bool isRGBA(
const std::string& encoding);
bool isRGBA(const std::string &encoding)
bool isBGRA(const std::string &encoding)
cv::MatND computeHistogram(const cv::Mat &input_image, int bin_size, float min_value, float max_value, const cv::Mat &mask_image)
simple wrapper for cv::calcHist.
cv::MatND HistogramWithRangeBinArrayTocvMatND(const std::vector< jsk_recognition_msgs::HistogramWithRangeBin > &histogram)
convert jsk_recognition_msgs::HistogramimageWithRangeBin array to cv::MatND
std::vector< jsk_recognition_msgs::HistogramWithRangeBin > cvMatNDToHistogramWithRangeBinArray(const cv::MatND &cv_hist, float min_value, float max_value)
convert cv::MatND to jsk_recognition_msgs::HistogramimageWithRangeBin array
std::vector< jsk_recognition_msgs::HistogramWithRangeBin > topNHistogramWithRangeBins(const std::vector< jsk_recognition_msgs::HistogramWithRangeBin > &bins, double top_n_rate)
extract top-N histograms. bins should be sorted. top_n_rate should be 0-1.
void labelToRGB(const cv::Mat src, cv::Mat &dst)
convert label image to rgb one.
void sortHistogramWithRangeBinArray(std::vector< jsk_recognition_msgs::HistogramWithRangeBin > &bins)
sort std::vector<jsk_recognition_msgs::HistogramWithRangeBin>. largest value will be at the first ele...
bool isRGB(const std::string &encoding)
cv::Rect boundingRectOfMaskImage(const cv::Mat &image)
compute bounding rectangle of mask image.
void drawHistogramWithRangeBin(cv::Mat &image, const jsk_recognition_msgs::HistogramWithRangeBin &bin, float min_width_value, float max_width_value, float max_height_value, cv::Scalar color)
draw bin to cv::Mat
bool isBGR(const std::string &encoding)
Check encodings.
bool compareHistogramWithRangeBin(const jsk_recognition_msgs::HistogramWithRangeBin &left, const jsk_recognition_msgs::HistogramWithRangeBin &right)
return true if left.count is larger than right.count.