41 #include <opencv2/highgui/highgui.hpp>
42 #include <opencv2/imgproc/imgproc.hpp>
44 #include <dynamic_reconfigure/server.h>
45 #include "opencv_apps/CornerHarrisConfig.h"
65 typedef opencv_apps::CornerHarrisConfig
Config;
84 const std::string&
frameWithDefault(
const std::string& frame,
const std::string& image_frame)
91 void imageCallbackWithInfo(
const sensor_msgs::ImageConstPtr& msg,
const sensor_msgs::CameraInfoConstPtr& cam_info)
93 doWork(msg, cam_info->header.frame_id);
98 doWork(msg, msg->header.frame_id);
106 void doWork(
const sensor_msgs::ImageConstPtr& image_msg,
const std::string& input_frame_from_msg)
115 cv::Mat dst, dst_norm, dst_norm_scaled;
116 dst = cv::Mat::zeros(frame.size(), CV_32FC1);
120 if (frame.channels() > 1)
122 cv::cvtColor(frame, src_gray, cv::COLOR_BGR2GRAY);
127 cv::cvtColor(src_gray, frame, cv::COLOR_GRAY2BGR);
132 int aperture_size = 3;
136 cv::cornerHarris(src_gray, dst, block_size, aperture_size, k, cv::BORDER_DEFAULT);
139 cv::normalize(dst, dst_norm, 0, 255, cv::NORM_MINMAX, CV_32FC1, cv::Mat());
140 cv::convertScaleAbs(dst_norm, dst_norm_scaled);
143 for (
int j = 0; j < dst_norm.rows; j++)
145 for (
int i = 0; i < dst_norm.cols; i++)
147 if ((
int)dst_norm.at<
float>(j, i) >
threshold_)
149 cv::circle(frame, cv::Point(i, j), 5, cv::Scalar(0), 2, 8, 0);
158 const int max_threshold = 255;
171 int c = cv::waitKey(1);
175 sensor_msgs::Image::Ptr out_img =
179 catch (cv::Exception& e)
181 NODELET_ERROR(
"Image processing error: %s %s %s %i", e.err.c_str(), e.func.c_str(), e.file.c_str(), e.line);
218 dynamic_reconfigure::Server<Config>::CallbackType
f =
237 ROS_WARN(
"DeprecationWarning: Nodelet corner_harris/corner_harris is deprecated, "
238 "and renamed to opencv_apps/corner_harris.");
244 #ifdef USE_PLUGINLIB_CLASS_LIST_MACROS_H