visual-tracking-control
VisualUpdateParticles.h
Go to the documentation of this file.
1 #ifndef VISUALUPDATEPARTICLES_H
2 #define VISUALUPDATEPARTICLES_H
3 
4 #include <VisualProprioception.h>
5 
6 #include <condition_variable>
7 #include <mutex>
8 #include <thread>
9 
10 #include <BayesFilters/PFVisualCorrection.h>
11 #include <opencv2/core/cuda.hpp>
12 #include <opencv2/cudaobjdetect.hpp>
13 #include <opencv2/objdetect/objdetect.hpp>
14 
15 
16 class VisualUpdateParticles : public bfl::PFVisualCorrection
17 {
18 public:
19  VisualUpdateParticles(std::unique_ptr<VisualProprioception> observation_model) noexcept;
20 
21  VisualUpdateParticles(std::unique_ptr<VisualProprioception> observation_model, const double likelihood_gain) noexcept;
22 
23  VisualUpdateParticles(std::unique_ptr<VisualProprioception> observation_model, const double likelihood_gain, const int num_cuda_stream) noexcept;
24 
25  ~VisualUpdateParticles() noexcept;
26 
27  void innovation(const Eigen::Ref<const Eigen::MatrixXf>& pred_states, cv::InputArray measurements, Eigen::Ref<Eigen::MatrixXf> innovations) override;
28 
29  double likelihood(const Eigen::Ref<const Eigen::MatrixXf>& innovations) override;
30 
31  bfl::VisualObservationModel& getVisualObservationModel() override;
32 
33  void setVisualObservationModel(std::unique_ptr<bfl::VisualObservationModel> visual_observation_model) override;
34 
35 protected:
36  void correctStep(const Eigen::Ref<const Eigen::MatrixXf>& pred_states, const Eigen::Ref<const Eigen::VectorXf>& pred_weights, cv::InputArray measurements,
37  Eigen::Ref<Eigen::MatrixXf> cor_states, Eigen::Ref<Eigen::VectorXf> cor_weights) override;
38 
39  std::unique_ptr<VisualProprioception> observation_model_;
41 
42  cv::Ptr<cv::cuda::HOG> cuda_hog_;
43 
44  const int num_cuda_stream_;
45  const int num_img_stream_;
46  std::vector<cv::cuda::Stream> cuda_stream_;
47  std::vector<cv::Mat> hand_rendered_;
48  std::vector<cv::cuda::GpuMat> cuda_img_;
49  std::vector<cv::cuda::GpuMat> cuda_img_alpha_;
50  std::vector<cv::cuda::GpuMat> cuda_descriptors_;
51  std::vector<cv::Mat> cpu_descriptors_;
52 };
53 
54 #endif /* VISUALUPDATEPARTICLES_H */
void innovation(const Eigen::Ref< const Eigen::MatrixXf > &pred_states, cv::InputArray measurements, Eigen::Ref< Eigen::MatrixXf > innovations) override
VisualUpdateParticles(std::unique_ptr< VisualProprioception > observation_model) noexcept
std::vector< cv::Mat > cpu_descriptors_
std::vector< cv::cuda::Stream > cuda_stream_
void correctStep(const Eigen::Ref< const Eigen::MatrixXf > &pred_states, const Eigen::Ref< const Eigen::VectorXf > &pred_weights, cv::InputArray measurements, Eigen::Ref< Eigen::MatrixXf > cor_states, Eigen::Ref< Eigen::VectorXf > cor_weights) override
cv::Ptr< cv::cuda::HOG > cuda_hog_
void setVisualObservationModel(std::unique_ptr< bfl::VisualObservationModel > visual_observation_model) override
std::vector< cv::Mat > hand_rendered_
std::vector< cv::cuda::GpuMat > cuda_descriptors_
std::unique_ptr< VisualProprioception > observation_model_
std::vector< cv::cuda::GpuMat > cuda_img_
std::vector< cv::cuda::GpuMat > cuda_img_alpha_
double likelihood(const Eigen::Ref< const Eigen::MatrixXf > &innovations) override
bfl::VisualObservationModel & getVisualObservationModel() override