Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef PROCESSINGCHAIN_HPP_
00035 #define PROCESSINGCHAIN_HPP_
00036 #include <labust/blueview/trackerfwd.hpp>
00037 #include <labust/blueview/CConverter.hpp>
00038 #include <labust/blueview/PrefilterPolicy.hpp>
00039 #include <labust/blueview/ThresholdPolicy.hpp>
00040 #include <labust/blueview/LabelPolicy.hpp>
00041 #include <labust/blueview/AssociatePolicy.hpp>
00042 #include <labust/blueview/TrackerROI.hpp>
00043
00044 #include <opencv2/highgui/highgui.hpp>
00045
00046 namespace labust
00047 {
00048 namespace blueview
00049 {
00054 template<
00055 class Prefilter = SimpleAdjust,
00056 class Threshold = SimpleThreshold,
00057 class Label = SimpleLabel,
00058 class Associate = DirectAssociate>
00059 class ProcessingChain
00060 {
00061 public:
00065 ProcessingChain():
00066 tracklet(new TrackedFeature),
00067 hasTarget(false),
00068 foundVehicle(false){};
00069
00074 TrackedFeaturePtr processROI(const TrackerROI& roi)
00075 {
00076 if (true)
00077 {
00078
00079
00080 this->ccon.llz2xy(roi.headData,this->tracklet);
00081 CConverter::meter2pixel(roi,this->tracklet);
00082
00083 if (this->hasTarget)
00084 {
00085 this->ccon.llz2xy(roi.headData,target);
00086 CConverter::meter2pixel(roi,target);
00087 }
00088
00089 cv::Mat disp = roi.roi.clone();
00090 cv::circle(disp,this->tracklet->pposition,10,cv::Scalar(65536));
00091 cv::imshow("Expected",disp*500);
00092
00093
00094
00095 MatPtr roiImg(new cv::Mat(roi.roi));
00096
00097 MatPtr prefiltered = Prefilter::prefilter(roiImg);
00098 MatPtr binary = Threshold::threshold(prefiltered,0.65);
00099 TrackedFeatureVecPtr features = Label::label(binary);
00100
00101 this->foundVehicle = Associate::associate(features, roi.headData, tracklet.get(), target.get());
00102
00103 cv::imshow("Adjusted",*prefiltered);
00104 cv::imshow("Binary",*binary);
00105
00106 CConverter::pixel2meter(roi,tracklet);
00107 this->ccon.xy2llz(roi.headData,tracklet);
00108
00109 return TrackedFeaturePtr(new TrackedFeature(*tracklet));
00110 }
00111
00112 return TrackedFeaturePtr();
00113 }
00114
00115 inline bool isTracking(){return foundVehicle;};
00116
00117 void setPosition(const SonarHead& cnt)
00118 {
00119 tracklet->position.x = cnt.range*cos((cnt.bearing - cnt.panAngle)*M_PI/180);
00120 tracklet->position.y = cnt.range*sin((cnt.bearing - cnt.panAngle)*M_PI/180);
00121 this->ccon.xy2llz(cnt,tracklet);
00122 foundVehicle = true;
00123 }
00124
00125 private:
00129 CConverter ccon;
00133 TrackedFeaturePtr tracklet, target;
00137 bool hasTarget, foundVehicle;
00138 };
00139 }
00140 }
00141
00142
00143 #endif