71 m_pSegmentedImage = 0;
79 delete m_pObjectColorSegmenter;
81 if (m_pSegmentedImage)
82 delete m_pSegmentedImage;
97 if (m_pSegmentedImage && (m_pSegmentedImage->
width != pImage->
width || m_pSegmentedImage->
height != pImage->
height))
99 delete m_pSegmentedImage;
100 m_pSegmentedImage = 0;
103 if (!m_pSegmentedImage)
106 m_bUseROI = fROIFactor != -1;
124 m_ROIList.push_back(entry);
128 if (bCalculateHSVImage)
129 m_pObjectColorSegmenter->
SetImage(pImage, &m_ROIList);
142 m_pObjectColorSegmenter->
FindColoredRegions(m_pSegmentedImage, regionList, nMinPointsPerRegion);
148 if (bShowSegmentedImage && pResultImage)
152 CheckRegionsForObjects(pImage, m_pSegmentedImage, pResultImage, regionList, color);
163 m_pObjectColorSegmenter->
FindColoredRegions(pResultSegmentedImage, regionList, nMinPointsPerRegion);
166 m_pObjectColorSegmenter->
FindRegionsOfGivenColor(pResultSegmentedImage, color, regionList, nMinPointsPerRegion);
170 CheckRegionsForObjects(pImage, pResultSegmentedImage, pResultImage, regionList, color);
173 void CObjectFinder::FindObjects(
const CByteImage *pImage,
CByteImage *pResultImage,
ObjectColor color,
int hue,
int hue_tol,
int min_sat,
int max_sat,
int min_v,
int max_v,
int nMinPointsPerRegion,
bool bShowSegmentedImage)
178 m_pObjectColorSegmenter->
FindRegionsOfGivenColor(m_pSegmentedImage, color, hue, hue_tol, min_sat, max_sat, min_v, max_v, regionList, nMinPointsPerRegion);
180 if (bShowSegmentedImage)
184 CheckRegionsForObjects(pImage, m_pSegmentedImage, pResultImage, regionList, color);
194 if (bShowSegmentedImage)
198 CheckRegionsForObjects(0, pSegmentedImage, pResultImage, regionList, color);
203 const int nRegions = (int) regionList.size();
205 for (
int i = 0; i < nRegions; i++)
207 const MyRegion ®ion = regionList.at(i);
209 if (!m_pRegionFilter || m_pRegionFilter->
CheckRegion(pColorImage, pSegmentedImage, region))
212 objectEntry.
color = color;
213 objectEntry.
region = region;
215 objectEntry.
sName =
"CompactObject";
220 for (
int j = 0; j < (int) m_ROIList.size(); j++)
226 if (entry.
color == color && fRatio > 0.75f && fDistance < min)
234 objectEntry.
id = m_nIDCounter++;
236 objectEntry.
id = best_id;
void SetImage(const CByteImage *pImage, const Object2DList *pROIList=0)
void DrawRegion(CByteImage *pImage, const MyRegion ®ion, int r=255, int g=255, int b=255, int thickness=1)
Draws a rectangle into a CByteImage.
void FindObjects(const CByteImage *pImage, CByteImage *pResultImage, ObjectColor color, int nMinPointsPerRegion, bool bShowSegmentedImage)
void SetColorParameterSet(const CColorParameterSet *pColorParameterSet)
void PrepareImages(const CByteImage *pImage, float fROIFactor=-1, bool bCalculateHSVImage=true)
bool ConvertImage(const CByteImage *pInputImage, CByteImage *pOutputImage, bool bFast=false, const MyRegion *pROI=0)
Converts a grayscale CByteImage to an RGB CByteImage image and vice versa.
void FindColoredRegions(CByteImage *pResultImage, RegionList ®ionList, int nMinPointsPerRegion)
std::vector< MyRegion > RegionList
void FindObjectsInSegmentedImage(const CByteImage *pSegmentedImage, CByteImage *pResultImage, ObjectColor color, int nMinPointsPerRegion, bool bShowSegmentedImage)
void FindRegionsOfGivenColor(CByteImage *pResultImage, ObjectColor color, RegionList ®ionList, int nMinPointsPerRegion)
int width
The width of the image in pixels.
int height
The height of the image in pixels.
Object2DList m_objectList
void SetColorParameterSet(const CColorParameterSet *pColorParameterSet)
float Distance(const Vec2d &vector1, const Vec2d &vector2)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
virtual bool CheckRegion(const CByteImage *pColorImage, const CByteImage *pSegmentedImage, const MyRegion ®ion)=0
bool FindRegions(const CByteImage *pImage, RegionList ®ionList, int nMinimumPointsPerRegion=0, int nMaximumPointsPerRegion=0, bool bCalculateBoundingBox=true, bool bStorePixels=false)
Performs region growing on a binary CByteImage, segmenting all regions in the image.
void AddObject(const Object2DEntry &entry)