1 | //===================================================================================
|
---|
2 | // Name : saliencyDetectionItti.h
|
---|
3 | // Author : Oytun Akman, oytunakman@gmail.com
|
---|
4 | // Version : 1.0
|
---|
5 | // Copyright : Copyright (c) 2010 LGPL
|
---|
6 | // Description : C++ implementation of "A Model of Saliency-Based Visual Attention
|
---|
7 | // for Rapid Scene Analysis" by Laurent Itti, Christof Koch and Ernst
|
---|
8 | // Niebur (PAMI 1998).
|
---|
9 | //===================================================================================
|
---|
10 |
|
---|
11 | #ifndef _SALIENCYMAPITTI_H_INCLUDED_
|
---|
12 | #define _SALIENCYMAPITTI_H_INCLUDED_
|
---|
13 | // ROS
|
---|
14 | #include <ros/ros.h>
|
---|
15 | #include "image_transport/image_transport.h"
|
---|
16 | #include <cv_bridge/cv_bridge.h>
|
---|
17 | #include <sensor_msgs/image_encodings.h>
|
---|
18 | #include <sensor_msgs/fill_image.h>
|
---|
19 | #include <geometry_msgs/Point.h>
|
---|
20 |
|
---|
21 | // OpenCV
|
---|
22 | #include "cv.h"
|
---|
23 | #include "opencv2/highgui/highgui.hpp"
|
---|
24 |
|
---|
25 | using namespace cv;
|
---|
26 | using namespace std;
|
---|
27 | namespace enc = sensor_msgs::image_encodings;
|
---|
28 |
|
---|
29 | class saliencyMapItti
|
---|
30 | {
|
---|
31 | protected:
|
---|
32 | ros::NodeHandle nh_;
|
---|
33 | ros::Publisher point_pub_;
|
---|
34 | image_transport::ImageTransport it_;
|
---|
35 | image_transport::Subscriber image_sub_;
|
---|
36 | image_transport::Publisher saliencymap_pub_;
|
---|
37 |
|
---|
38 | public:
|
---|
39 | saliencyMapItti() : nh_("~"), it_(nh_)
|
---|
40 | {
|
---|
41 | image_sub_ = it_.subscribe("/rgbimage_in", 1, &saliencyMapItti::imageCB, this);
|
---|
42 | saliencymap_pub_= it_.advertise("/saliency/image", 1);
|
---|
43 | point_pub_ = nh_.advertise<geometry_msgs::Point>("/saliency/salientpoint", 1);
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | ~saliencyMapItti()
|
---|
48 | {
|
---|
49 | nh_.shutdown();
|
---|
50 | }
|
---|
51 |
|
---|
52 | void imageCB(const sensor_msgs::ImageConstPtr& msg_ptr);
|
---|
53 | void calculateSaliencyMap(const Mat* src, Mat* dst, int scaleBase);
|
---|
54 | void combineFeatureMaps(int scale);
|
---|
55 |
|
---|
56 | Mat conspicuityMap_I;
|
---|
57 | Mat conspicuityMap_C;
|
---|
58 | Mat conspicuityMap_O;
|
---|
59 | Mat S;
|
---|
60 |
|
---|
61 | private:
|
---|
62 | Mat r,g,b,R,G,B,Y,I;
|
---|
63 | vector<Mat> gaussianPyramid_I;
|
---|
64 | vector<Mat> gaussianPyramid_R;
|
---|
65 | vector<Mat> gaussianPyramid_G;
|
---|
66 | vector<Mat> gaussianPyramid_B;
|
---|
67 | vector<Mat> gaussianPyramid_Y;
|
---|
68 |
|
---|
69 | void createChannels(const Mat* src);
|
---|
70 | void createScaleSpace(const Mat* src, vector<Mat>* dst, int scale);
|
---|
71 |
|
---|
72 | void normalize_rgb();
|
---|
73 | void create_RGBY();
|
---|
74 | void createIntensityFeatureMaps();
|
---|
75 | void createColorFeatureMaps();
|
---|
76 | void createOrientationFeatureMaps(int orientation);
|
---|
77 | void mapNormalization(Mat* src);
|
---|
78 | void clearBuffers();
|
---|
79 |
|
---|
80 | vector<Mat> featureMaps_I;
|
---|
81 | vector<Mat> featureMaps_RG;
|
---|
82 | vector<Mat> featureMaps_BY;
|
---|
83 | vector<Mat> featureMaps_0;
|
---|
84 | vector<Mat> featureMaps_45;
|
---|
85 | vector<Mat> featureMaps_90;
|
---|
86 | vector<Mat> featureMaps_135;
|
---|
87 | };
|
---|
88 | #endif
|
---|