visual-tracking-control
VisualSIS.h
Go to the documentation of this file.
1 #ifndef VISUALSIS_H
2 #define VISUALSIS_H
3 
4 #include <chrono>
5 #include <deque>
6 #include <memory>
7 #include <vector>
8 
9 #include <BayesFilters/EstimatesExtraction.h>
10 #include <BayesFilters/VisualParticleFilter.h>
11 #include <Eigen/Dense>
12 #include <iCub/iKin/iKinFwd.h>
13 #include <opencv2/cudaobjdetect.hpp>
14 #include <thrift/VisualSISParticleFilterIDL.h>
15 #include <yarp/dev/PolyDriver.h>
16 #include <yarp/dev/IAnalogSensor.h>
17 #include <yarp/os/Bottle.h>
18 #include <yarp/os/BufferedPort.h>
19 #include <yarp/os/ConstString.h>
20 #include <yarp/os/Port.h>
21 #include <yarp/sig/Image.h>
22 #include <yarp/sig/Matrix.h>
23 #include <yarp/sig/Vector.h>
24 
25 
26 class VisualSIS: public bfl::VisualParticleFilter,
28 {
29 public:
30  VisualSIS(const yarp::os::ConstString& cam_sel,
31  const int img_width, const int img_height,
32  const int num_particles,
33  const double resample_ratio);
34 
35  ~VisualSIS() noexcept;
36 
37 protected:
38  void initialization() override;
39 
40  void filteringStep() override;
41 
42  void getResult() override;
43 
44  bool runCondition() override { return true; };
45 
46 
47  yarp::os::ConstString cam_sel_;
51  unsigned int descriptor_length_;
53 
54  const int block_size_ = 16;
55  const int bin_number_ = 9;
56 
57  cv::Ptr<cv::cuda::HOG> cuda_hog_;
58 
59 
60  yarp::os::BufferedPort<yarp::sig::Vector> port_estimates_out_;
61  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb>> port_image_in_;
62 
63 
64  yarp::os::Port port_rpc_command_;
65  bool attach(yarp::os::Port &source);
66  bool setCommandPort();
67 
68 
69  bool run_filter() override;
70 
71  bool reset_filter() override;
72 
73  bool stop_filter() override;
74 
75  bool skip_step(const std::string& what_step, const bool status) override;
76 
77  bool use_analogs(const bool status) override;
78 
79  std::vector<std::string> get_info() override;
80 
81  bool quit() override;
82 
83 
84  bool set_estimates_extraction_method(const std::string& method) override;
85 
86  bool set_mobile_average_window(const int16_t window) override;
87 
88 private:
89  Eigen::MatrixXf pred_particle_;
90  Eigen::VectorXf pred_weight_;
91 
92  Eigen::MatrixXf cor_particle_;
93  Eigen::VectorXf cor_weight_;
94 
95 
96  bfl::EstimatesExtraction estimate_extraction_;
97 
98 
99  bool init_img_in_ = false;
100  yarp::sig::ImageOf<yarp::sig::PixelRgb> img_in_;
101 };
102 
103 #endif /* VISUALSIS_H */
int img_width_
Definition: VisualSIS.h:48
bool init_img_in_
Definition: VisualSIS.h:99
Eigen::MatrixXf pred_particle_
Definition: VisualSIS.h:89
bool skip_step(const std::string &what_step, const bool status) override
Enable/Disable skipping the filtering step specified in what_step.
Definition: VisualSIS.cpp:258
bool reset_filter() override
Reset the visual SIR particle filter.
Definition: VisualSIS.cpp:242
int num_particles_
Definition: VisualSIS.h:50
Eigen::VectorXf pred_weight_
Definition: VisualSIS.h:90
bool run_filter() override
Initialize and run the visual SIR particle filter.
Definition: VisualSIS.cpp:234
cv::Ptr< cv::cuda::HOG > cuda_hog_
Definition: VisualSIS.h:57
void getResult() override
Definition: VisualSIS.cpp:206
double resample_ratio_
Definition: VisualSIS.h:52
yarp::os::ConstString cam_sel_
Definition: VisualSIS.h:44
const int block_size_
Definition: VisualSIS.h:54
bool use_analogs(const bool status) override
Use/Don&#39;t use the analog values from the right hand to correct the finger poses.
Definition: VisualSIS.cpp:264
void filteringStep() override
Definition: VisualSIS.cpp:86
const int bin_number_
Definition: VisualSIS.h:55
std::vector< std::string > get_info() override
Get information about recursive Bayesian filter, like it&#39;s status, the available methods, and the current one in use, to extract the state estimate from the particle set.
Definition: VisualSIS.cpp:273
bool runCondition() override
Definition: VisualSIS.h:44
yarp::os::Port port_rpc_command_
Definition: VisualSIS.h:64
bool quit() override
Gently close the application, deallocating resources.
Definition: VisualSIS.cpp:355
int img_height_
Definition: VisualSIS.h:49
VisualSIS(const yarp::os::ConstString &cam_sel, const int img_width, const int img_height, const int num_particles, const double resample_ratio)
Definition: VisualSIS.cpp:32
yarp::sig::ImageOf< yarp::sig::PixelRgb > img_in_
Definition: VisualSIS.h:100
bool attach(yarp::os::Port &source)
Definition: VisualSIS.cpp:209
bfl::EstimatesExtraction estimate_extraction_
Definition: VisualSIS.h:96
~VisualSIS() noexcept
Definition: VisualSIS.cpp:79
Eigen::VectorXf cor_weight_
Definition: VisualSIS.h:93
Eigen::MatrixXf cor_particle_
Definition: VisualSIS.h:92
bool set_estimates_extraction_method(const std::string &method) override
Change the current method to extract the state estimates from the particle set.
Definition: VisualSIS.cpp:291
yarp::os::BufferedPort< yarp::sig::Vector > port_estimates_out_
Definition: VisualSIS.h:60
bool set_mobile_average_window(const int16_t window) override
Change the window size of mobile averages for estimates extraction.
Definition: VisualSIS.cpp:346
unsigned int descriptor_length_
Definition: VisualSIS.h:51
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > > port_image_in_
Definition: VisualSIS.h:61
void initialization() override
Definition: VisualSIS.cpp:61
bool setCommandPort()
Definition: VisualSIS.cpp:215
bool stop_filter() override
Stop and reset the SIR particle filter.
Definition: VisualSIS.cpp:250
VisualSISParticleFilterIDL IDL Interface to VisualSIRParticleFilter options.