Go to the documentation of this file.
   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);
 
  130   bool isBGR(
const std::string& encoding);
 
  131   bool isRGB(
const std::string& encoding);
 
  132   bool isBGRA(
const std::string& encoding);
 
  133   bool isRGBA(
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.
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
cv::Rect boundingRectOfMaskImage(const cv::Mat &image)
compute bounding rectangle of mask image.
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.
bool isBGRA(const std::string &encoding)
bool compareHistogramWithRangeBin(const jsk_recognition_msgs::HistogramWithRangeBin &left, const jsk_recognition_msgs::HistogramWithRangeBin &right)
return true if left.count is larger than right.count.
bool isRGB(const std::string &encoding)
void sortHistogramWithRangeBinArray(std::vector< jsk_recognition_msgs::HistogramWithRangeBin > &bins)
sort std::vector<jsk_recognition_msgs::HistogramWithRangeBin>. largest value will be at the first ele...
void labelToRGB(const cv::Mat src, cv::Mat &dst)
convert label image to rgb one.
bool isRGBA(const std::string &encoding)
bool isBGR(const std::string &encoding)
Check encodings.
cv::Rect boundingRectFromContours(const std::vector< cv::Point > &contours)
Return Bounding Box from contours.
cv::MatND HistogramWithRangeBinArrayTocvMatND(const std::vector< jsk_recognition_msgs::HistogramWithRangeBin > &histogram)
convert jsk_recognition_msgs::HistogramimageWithRangeBin array to cv::MatND