32 #include <opencv2/highgui/highgui.hpp> 34 #include <boost/date_time/posix_time/posix_time.hpp> 36 #include <marker_msgs/MarkerDetection.h> 45 EllipsesDetectionNode::EllipsesDetectionNode() :
76 ROS_ERROR(
"cv_bridge exception: %s", e.what());
83 std::vector<cv::RotatedRect> ellipses;
94 if (
param()->show_camera_image) {
106 cv::putText(img_debug, ss.str(), cv::Point(10, 15), cv::FONT_HERSHEY_PLAIN, 0.6, cv::Scalar::all(0), 1, CV_AA);
107 cv::imshow(
param()->node_name + std::string(
" - input"), img_debug);
109 cv::imshow(
param()->node_name + std::string(
" - edges"),
imgEdges_);
111 cv::imshow(
param()->node_name + std::string(
" - gradient"),
imgGradient_ * (0xFFFF/0x1FF));
114 cv::imshow(
param()->node_name + std::string(
" - direction"),
imgDirection_ * 0xFFFF/0x1FF);
117 cv::imshow(
param()->node_name + std::string(
" - imgSobelDx_"),
imgSobelDx_ * (0xFFFF/0x1FF));
120 cv::imshow(
param()->node_name + std::string(
" - imgSobelDy_"),
imgSobelDy_ * (0xFFFF/0x1FF));
123 cv::waitKey(
param()->show_camera_image_waitkey);
139 for(
unsigned int i = 0; i < 2; i++) {
140 if(
param()->skip_second_tf && (i == 1))
continue;
141 for(std::list<Marker>::iterator it =
markers_.begin(); it !=
markers_.end(); it++) {
143 sprintf(frame,
"t%i-%i", i, m.
id);
149 R.
setValue (m.
R[i](0,0), m.
R[i](0,1), m.
R[i](0,2), m.
R[i](1,0), m.
R[i](1,1), m.
R[i](1,2), m.
R[i](2,0), m.
R[i](2,1), m.
R[i](2,2));
168 marker_msgs::MarkerDetection msg;
171 msg.distance_min = 0;
172 msg.distance_max = 8;
173 msg.distance_max_id = 5;
174 msg.view_direction.x = 0;
175 msg.view_direction.y = 0;
176 msg.view_direction.z = 0;
177 msg.view_direction.w = 1;
178 msg.fov_horizontal = 6;
179 msg.fov_vertical = 0;
180 msg.type =
"ellipses";
184 marker_msgs::Marker &marker = msg.markers[i];
188 marker.pose.position.
x = srcT.
x();
189 marker.pose.position.y = srcT.
y();
190 marker.pose.position.z = srcT.
z();
192 marker.pose.orientation.x = srcQ.x();
193 marker.pose.orientation.y = srcQ.y();
194 marker.pose.orientation.z = srcQ.z();
195 marker.pose.orientation.w = srcQ.w();
203 marker_msgs::FiducialDetection msg;
208 for (std::vector<Ellipse>::iterator it =
ellipses_.begin(); it !=
ellipses_.end(); it++) {
212 marker_msgs::Fiducial fiducial;
214 geometry_msgs::Point objectPoint;
215 objectPoint.x = 0.0f;
216 objectPoint.y = 0.0f;
217 objectPoint.z = 0.0f;
218 fiducial.object_points.push_back(objectPoint);
220 geometry_msgs::Point imagePoint;
224 fiducial.image_points.push_back(imagePoint);
226 fiducial.ids.resize(0);
227 fiducial.ids_confidence.resize(0);
229 msg.fiducial.push_back(fiducial);
const cv::Matx33d & intrinsicMatrix() const
ros::Publisher pub_perceptions_
std::list< Marker > markers_
const ParametersNode * param()
void publish(const boost::shared_ptr< M > &message) const
void draw_ellipses(cv::Mat &m)
CameraSubscriber subscribeCamera(const std::string &base_topic, uint32_t queue_size, const CameraSubscriber::Callback &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
tf::TransformBroadcaster transformBroadcaster_
boost::posix_time::ptime timeCallbackReceivedLast_
boost::posix_time::ptime timeDetectionStart_
cv::RotatedRect boxEllipse
unsigned long callback_counter_
void setValue(const tfScalar &xx, const tfScalar &xy, const tfScalar &xz, const tfScalar &yx, const tfScalar &yy, const tfScalar &yz, const tfScalar &zx, const tfScalar &zy, const tfScalar &zz)
std::list< tf::StampedTransform > markerTransforms_
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
#define PLUGINLIB_DECLARE_CLASS(pkg, class_name, class_type, base_class_type)
void getRotation(Quaternion &q) const
std::string resolve(const std::string &prefix, const std::string &frame_name)
TFSIMD_FORCE_INLINE const tfScalar & x() const
boost::posix_time::ptime timeDetectionEnd_
void imageCallback(const sensor_msgs::ImageConstPtr &image_msg, const sensor_msgs::CameraInfoConstPtr &info_msg)
std::vector< Ellipse > ellipses_
TFSIMD_FORCE_INLINE const tfScalar & z() const
ros::Publisher pub_fiducials_
CvImagePtr cvtColor(const CvImageConstPtr &source, const std::string &encoding)
sensor_msgs::CameraInfoConstPtr camera_info_
bool fromCameraInfo(const sensor_msgs::CameraInfo &msg)
boost::posix_time::ptime timeCallbackReceived_
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
TFSIMD_FORCE_INLINE const tfScalar & y() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
cv::Mat_< double > R[2]
two plausible translations solutions
uint32_t getNumSubscribers() const
cv_bridge::CvImagePtr image_mono_
image_transport::CameraSubscriber sub_camera_
const cv::Matx34d & projectionMatrix() const
void createTransforms(const std_msgs::Header &header)
image_transport::ImageTransport imageTransport_
const cv::Mat_< double > & distortionCoeffs() const
void publishFiducials(const std_msgs::Header &header)
void fit_ellipses_opencv(const cv::Mat &m, const cv::Mat cameraMatrix, const cv::Mat distCoeffs, const cv::Mat projectionMatrix, const boost::posix_time::ptime &tstamp)
cv::Point3d translations[2]
ellipse equation
void publishMarker(const std_msgs::Header &header)