47 #include <visualization_msgs/Marker.h> 57 #include "fiducial_msgs/Fiducial.h" 58 #include "fiducial_msgs/FiducialArray.h" 59 #include "fiducial_msgs/FiducialTransform.h" 60 #include "fiducial_msgs/FiducialTransformArray.h" 102 double world_diagonal,
double x0,
double y0,
103 double x1,
double y1,
double x2,
double y2,
104 double x3,
double y3);
106 void fiducial_cb(
int id,
int direction,
double world_diagonal,
double x0,
107 double y0,
double x1,
double y1,
double x2,
double y2,
108 double x3,
double y3);
111 void processImage(
const sensor_msgs::ImageConstPtr &msg);
130 double world_diagonal,
double x0,
131 double y0,
double x1,
double y1,
132 double x2,
double y2,
double x3,
135 ths->
fiducial_cb(
id, direction, world_diagonal, x0, y0, x1, y1, x2, y2, x3,
140 double x0,
double y0,
double x1,
double y1,
141 double x2,
double y2,
double x3,
double y3) {
142 fiducial_msgs::Fiducial fid;
145 "fiducial: id=%d dir=%d diag=%f (%.2f,%.2f), (%.2f,%.2f), (%.2f,%.2f), " 147 id, direction, world_diagonal, x0, y0, x1, y1, x2, y2, x3, y3);
149 fid.direction = direction;
150 fid.fiducial_id = id;
166 fiducial_msgs::FiducialTransform ft;
167 geometry_msgs::Transform trans;
168 ft.transform = trans;
176 const sensor_msgs::CameraInfo::ConstPtr &msg) {
177 if (msg->K != boost::array<double, 9>({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0})) {
186 ROS_WARN(
"%s",
"CameraInfo message has invalid intrinsics, K matrix is all zeros");
227 IplImage *image =
new IplImage(cv_img->image);
229 ROS_INFO(
"Got first image! Setting up Fiducials library");
252 cvLine(image, cvPoint(fid.x0, fid.y0), cvPoint(fid.x1, fid.y1),
253 CV_RGB(255, 0, 0), 3);
254 cvLine(image, cvPoint(fid.x1, fid.y1), cvPoint(fid.x2, fid.y2),
255 CV_RGB(255, 0, 0), 3);
256 cvLine(image, cvPoint(fid.x2, fid.y2), cvPoint(fid.x3, fid.y3),
257 CV_RGB(255, 0, 0), 3);
258 cvLine(image, cvPoint(fid.x3, fid.y3), cvPoint(fid.x0, fid.y0),
259 CV_RGB(255, 0, 0), 3);
268 ROS_ERROR(
"cv_bridge exception: %s", e.what());
282 nh.
param<std::string>(
"log_file",
log_file,
"fiducials.log.txt");
292 if (publish_images) {
293 image_pub = img_transport.advertise(
"fiducial_images", 1);
300 "/fiducial_transforms", 1);
308 img_sub = img_transport.subscribe(
"/camera", 1,
314 ROS_INFO(
"Fiducials Localization ready");
317 int main(
int argc,
char **argv) {
318 ros::init(argc, argv,
"fiducial_detect");
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
ros::Subscriber caminfo_sub
image_transport::Subscriber img_sub
void publish(const boost::shared_ptr< M > &message) const
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
Fiducials_Fiducial_Announce_Routine fiducial_announce_routine
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::string data_directory
String_Const fiducials_path
bool fiducialCallback(fiducial_msgs::Fiducial *fiducial, fiducial_msgs::FiducialTransform *transform)
ROSCPP_DECL void spin(Spinner &spinner)
fiducial_msgs::FiducialTransformArray fiducialTransformArray
std::string last_camera_frame
void processImage(const sensor_msgs::ImageConstPtr &msg)
static void fiducial_announce(void *t, int id, int direction, double world_diagonal, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
boost::thread * update_thread
void publish(const sensor_msgs::Image &message) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Fiducials Fiducials__create(CV_Image original_image, Fiducials_Create fiducials_create)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
FiducialsNode(ros::NodeHandle &nh)
ros::Time last_image_time
Fiducials_Create Fiducials_Create__one_and_only(void)
fiducial_msgs::FiducialArray fiducialVertexArray
Fiducials_Results Fiducials__process(Fiducials fiducials)
void fiducial_cb(int id, int direction, double world_diagonal, double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
image_transport::Publisher image_pub
void camInfoCallback(const sensor_msgs::CameraInfo::ConstPtr &msg)
int main(int argc, char **argv)
void camInfoCallback(const sensor_msgs::CameraInfo::ConstPtr &msg)
String_Const log_file_name
ros::Publisher vertices_pub
void Fiducials__image_set(Fiducials fiducials, CV_Image image)