Go to the documentation of this file.00001 #include "fake_image_processing_alg_node.h"
00002
00003 FakeImageProcessingAlgNode::FakeImageProcessingAlgNode(void) :
00004 algorithm_base::IriBaseAlgorithm<FakeImageProcessingAlgorithm>(), it_(this->public_node_handle_)
00005 {
00006
00007 this->loop_rate_ = 5;
00008
00009
00010 image_pub_ = it_.advertise("image_out", 1);
00011
00012
00013 image_sub_ = it_.subscribe("image_in", 1, &FakeImageProcessingAlgNode::image_callback, this);
00014
00015
00016
00017
00018
00019
00020
00021
00022 }
00023
00024 FakeImageProcessingAlgNode::~FakeImageProcessingAlgNode(void)
00025 {
00026
00027 }
00028
00029 void FakeImageProcessingAlgNode::mainNodeThread(void)
00030 {
00031
00032 this->alg_.lock();
00033
00034
00035 if (cv_ptr!=NULL)
00036 {
00037 myLib.setInputImage(cv_ptr->image);
00038 myLib.fakeProcessing();
00039 myLib.getOutputImage(cv_ptr->image);
00040 }
00041
00042
00043 if (cv_ptr!=NULL)
00044 image_pub_.publish(cv_ptr->toImageMsg());
00045
00046
00047 this->alg_.unlock();
00048
00049
00050
00051
00052
00053
00054
00055
00056 }
00057
00058
00059 void FakeImageProcessingAlgNode::image_callback(const sensor_msgs::ImageConstPtr& msg)
00060 {
00061 this->alg_.lock();
00062 try
00063 {
00064 cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
00065 }
00066 catch (cv_bridge::Exception& e)
00067 {
00068 ROS_ERROR("cv_bridge exception: %s", e.what());
00069 return;
00070 }
00071 this->alg_.unlock();
00072 }
00073
00074
00075
00076
00077
00078
00079
00080 void FakeImageProcessingAlgNode::node_config_update(Config &config, uint32_t level)
00081 {
00082 this->alg_.lock();
00083
00084 this->alg_.unlock();
00085 }
00086
00087 void FakeImageProcessingAlgNode::addNodeDiagnostics(void)
00088 {
00089 }
00090
00091
00092 int main(int argc,char *argv[])
00093 {
00094 return algorithm_base::main<FakeImageProcessingAlgNode>(argc, argv, "fake_image_processing_alg_node");
00095 }