00001 00018 #include "CameraUtils/camerathread.h" 00019 #include <QMetaType> 00020 00021 CameraThread::CameraThread(QObject *parent, std::string topicName) : 00022 QThread(parent) 00023 { 00024 this->topicName = topicName; 00025 qRegisterMetaType<sensor_msgs::Image::ConstPtr>("sensor_msgs::Image::ConstPtr"); 00026 } 00027 00028 void CameraThread::run() 00029 { 00030 ros::NodeHandle n; 00031 a = n.subscribe(topicName, 1000, &CameraThread::onImage, this); 00032 ROS_INFO_STREAM("Camera started: " << topicName); 00033 while (ros::ok()) 00034 { 00035 ros::spinOnce(); 00036 } 00037 } 00038 00039 void CameraThread::onImage(const sensor_msgs::Image::ConstPtr& msg) 00040 { 00041 this->imageReceived(msg); 00042 }