00001 #include "Component/ModelManager.H" 00002 #include "Component/OptionManager.H" 00003 00004 #include "Component/ModelComponent.H" 00005 #include "Component/ModelParam.H" 00006 #include "Media/FrameSeries.H" 00007 #include "Transport/FrameInfo.H" 00008 #include "Raster/GenericFrame.H" 00009 #include "Image/Image.H" 00010 #include "GUI/XWinManaged.H" 00011 #include "GUI/ImageDisplayStream.H" 00012 #include "Image/Image.H" 00013 #include "Image/Pixels.H" 00014 #include "Robots/SeaBeeIII/VisionBrainComponentI.H" 00015 00016 #include "Ice/RobotBrainObjects.ice.H" 00017 #include "Ice/RobotSimEvents.ice.H" 00018 #include "Ice/IceImageUtils.H" 00019 #include <opencv/cv.h> 00020 #include <IceUtil/Thread.h> 00021 00022 #include "Image/Point2D.H" 00023 #include "MBARI/Geometry2D.H" 00024 #include "VFAT/segmentImageTrackMC.H" 00025 00026 #ifndef STRAIGHT_EDGE_FINDER_H 00027 #define STRAIGHT_EDGE_FINDER_H 00028 00029 00030 class StraightEdgeFinder : public VisionBrainComponentI 00031 { 00032 public: 00033 00034 StraightEdgeFinder(OptionManager& mgr, 00035 const std::string& descrName = "StraightEdgeFinder", 00036 const std::string& tagName = "StraightEdgeFinder"); 00037 00038 ~StraightEdgeFinder(); 00039 00040 virtual void updateFrame(Image<PixRGB<byte> > img, std::string cameraId); 00041 00042 virtual void registerTopics(); 00043 00044 enum PipeRecognizeMethod { HOUGH, LINE_BEST_FIT, CONTOUR }; 00045 00046 private: 00047 00048 std::vector<LineSegment2D> getPipeLocation 00049 (rutz::shared_ptr<Image<byte> > colorSegmentedImage, 00050 rutz::shared_ptr<Image<PixRGB <byte> > > outputImage, 00051 PipeRecognizeMethod method); 00052 00053 std::vector<LineSegment2D> calculateHoughTransform 00054 (Image<byte>& colorSegmentedImage, 00055 rutz::shared_ptr<Image<PixRGB<byte> > > outputImage); 00056 00057 uint calculateLineBestFit 00058 (Image<byte> &colorSegmentedImage, 00059 Image<PixRGB <byte> > &outputImage, 00060 Point2D<int> &pipeCenter, 00061 double &pipeAngle); 00062 00063 uint calculateContours 00064 (Image<byte> &colorSegmentedImage, 00065 Image<PixRGB <byte> > &outputImage, 00066 Point2D<int> &pipeCenter, 00067 double &pipeAngle); 00068 00069 std::vector<LineSegment2D> getHoughLines 00070 ( IplImage cannyImage ); 00071 00072 IplImage getCannyImage 00073 ( Image<byte> colorSegmentedImage ); 00074 00075 std::vector<LineSegment2D> pruneHoughLines 00076 (const std::vector<LineSegment2D> lineSegments); 00077 00078 float isolateOrange3 00079 (Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage); 00080 00081 float isolateOrange4 00082 (Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage); 00083 00084 float isolateOrange5 00085 (Image< PixRGB<byte> > &inputImage, Image<byte> &outputImage); 00086 00087 float normalizeAngle(float angleInRads); 00088 00089 Image<PixRGB<byte> > itsCurrentImg; 00090 bool itsCurrentImgFwdCam; 00091 00092 // segmentImageTrackMC<float,unsigned int,4> *segmenter; 00093 00094 00095 00096 Image<PixRGB<byte> > itsDispImg; // display image 00097 uint itsWidth; 00098 uint itsHeight; 00099 }; 00100 00101 #endif