AURobotServers
4
|
#include <uimana.h>
Public Member Functions | |
bool | findRoadPoly (bool debug, UImage *img, double balance, double limit, int x1, int y1, int x2, int y2, bool colorCorrect) |
double | getCromaTraceSD () |
CvPoint * | getFloorPolygon () |
int | getFloorPolygonCnt () |
int * | getFloorPolygonCntP () |
char * | getImageName (const char *list, const char *subdir, int n, char *buff, int buffLng) |
bool * | getObstacleFlags () |
bool | imageContourMaha (UImage *img, UImage *imgC, unsigned int row, unsigned int col, UPixLinked *outlineBuffer, int *outlineBufferCnt, UMatrix4 *averageSeed, UMatrix4 *covarianceInv, double diff, double diffa) |
bool | imageContourMahaCroma (UImage *img, UImage *imgC, unsigned int row, unsigned int col, int x1, int y1, int x2, int y2, int maxH, UPixLinked *outlineBuffer, int *outlineBufferCnt, UMatrix4 *averageCroma, UMatrix4 *covarCromaInv, UMatrix4 *averageRgb, UMatrix4 *covarRgbInv, double ballance, double limit) |
bool | imageUsable (UImage *img) |
double | polygonArea (CvPoint *poly, int elements) |
bool | polygonReduce (UPixLinked *outlineBuffer, int *outlineBufferCnt, double tollerance, int topLine) |
bool | polygonReduce2 (UPixLinked *outlineBuffer, int *outlineBufferCnt, double tollerance, int topLine) |
void | setImagePool (UImagePool *imagePool) |
void | setStorage (CvMemStorage *mem) |
UImAna () | |
~UImAna () | |
Protected Member Functions | |
double | getMahalonobisDist (UPixel *pix, UMatrix4 *average, UMatrix4 *covarianceInv) |
double | getMahalonobisDistCroma (UPixel *pix, UMatrix4 *average, UMatrix4 *covarianceInv, double averageY, bool useShadow) |
Private Member Functions | |
int | countContourEdges (CvSeq *contours) |
int | countContourLimits (CvSeq *contours, int *left, int *right, int *top, int *bottom, bool lookingLeft) |
bool | distFilt (UImage *simg, UImage *dimg, unsigned int maxW, unsigned int minW, unsigned int minR, unsigned int maxR) |
bool | distFiltH (UImage *simg, UImage *dimg, unsigned int maxW, unsigned int minW, unsigned int minR, unsigned int maxR, unsigned int maxMaskHeight) |
int | findContour (UImage *img, UImage *imgMask, UImage *dest, CvPoint *flp, int flpMax, bool *tooHigh, bool *tooSmall, bool lookingLeft) |
int | findContourPoly (UImage *img, UImage *imgM, UImage *imgC, bool *tooSmall, double lookingLeft, double pct1, double pct2) |
int | findContourPolyCroma (UImage *img, UImage *imgM, UImage *imgC, UImage *imgCroma, bool *tooSmall, int x1, int y1, int x2, int y2, int maxH, double ballance, double limit) |
void | findVertex (const UPixLinked *end1, const UPixLinked *end2, const int count, const int startNum, int **vertexList, int *vertexListCnt, const int listLength, const float toll, const int topLine) |
bool | getAvgVar (UImage *img, unsigned int x, unsigned int y, unsigned int w, unsigned int h, UMatrix4 *mE, UMatrix4 *mC) |
double | getRoadProbability (int r, int c, UImage *img, UImage *imgC, UMatrix4 *vECroma, UMatrix4 *averageCroma, UMatrix4 *covarCromaInv, double ballance, double averageY, bool useShadow) |
bool | paintRoadImage (int seedR, int seedC, UImage *img, UImage *imgC, UMatrix4 *vCroma, UMatrix4 *mCromaInv, UMatrix4 *vRgb, UMatrix4 *mRgbInv, double dyn, double abs) |
int | pixCmp (UPixel *p1, UPixel *p2) |
UPixel * | pixSort (UPixel ***ps, int pixCnt) |
Private Attributes | |
double | cromaTrace |
CvPoint * | floorArea |
int | floorAreaCnt |
UPixLinked * | floorOutline |
int | floorOutlineCnt |
UImagePool * | imgPool |
bool * | obst |
CvMemStorage * | storage |
Class for image analysis. Initially color statistics only.
UImAna::UImAna | ( | ) |
Constructor
UImAna::~UImAna | ( | ) |
Destructor
|
private |
Count edges in contour sequebnce
|
private |
Find square limits of found contour returns the point cont, and if limit pointers != NULL the left, right, top and bottol limits of the points in the sequence.
References UPixLinked::r.
|
private |
Filter image based on row number
References UPixLinked::c, UImage::copy(), UImage::getLine(), UPixLinked::r, and UImage::width().
|
private |
Median filter with variable mask width and maximum mask height. Mask height must be smaller than or equal to 5 (od number). Mask width must be smaller than or equal to 40.
References UPixLinked::c, UImage::copy(), UImage::getLine(), UImage::height(), mini(), UPixLinked::r, and UImage::width().
|
private |
Find contour of maksked area. and paint result in destination image.
References UImage::cvArr(), UImage::height(), mini(), UTime::Now(), and UImage::width().
|
private |
Find contour of area, using own routine, and reduction using Douglas-Peucker. LookingLeft decides seed-point 1.0 seed is full right, -1.0 seed is full left. Parameters are pct1 is dynamic edge size and pct2 is absolute from reference point. Resulting polygon is returned in floorArea with floorAreaCnt points. floorOutline buffer is used during calculation and holds the same information on return. too-small is set trus if outline is less that 100 pixels. Returns true if a proper area is found.
References UPixLinked::c, UImage::copy(), UImage::getLine(), UImage::getPixRef(), UImage::height(), UImage::imgTime, UMatrix4::inversed(), MAX_POLYGON_OUTLINE_POINTS, MAX_POLYGON_POINTS, maxi(), mini(), UTime::Now(), UPixel::p1, UPixel::p2, UPixel::p3, UMatrix::print(), UPixLinked::r, roundi(), UImage::setNameAndExt(), UMatrix::setRow(), UMatrix::setSize(), and UImage::width().
|
private |
Find contour polygon using cromaticity
img | is source image |
imgM | ?? image |
imgC | contour image |
imgCroma | cromaticity source image |
tooSmall | is ??? |
x1,y1,x2,y2 | is seed area top-left to button right |
balance | is ??? |
limit | is ?? |
References UPixLinked::c, UImage::copyMeta(), UImage::cvArr(), UTime::GetDateString(), UImage::getLine(), UImage::getPixRef(), UTime::GetTimeAsString(), UImage::height(), UImage::imgTime, UMatrix::init(), UMatrix4::inversed(), MAX_POLYGON_OUTLINE_POINTS, MAX_POLYGON_POINTS, maxi(), mini(), UMatrix::mult(), UImage::name, UTime::Now(), UPixel::p1, UPixel::p2, UPixel::p3, UPixel::pixRGB(), UMatrix::print(), UPixLinked::px, UPixLinked::r, roundi(), UImage::setNameAndExt(), UImage::setPix(), UMatrix::setRC(), UMatrix::setRow(), UMatrix::setSize(), SHADOW_COMPENSATION_FACTOR, sqr(), UMatrix::trace(), and UImage::width().
bool UImAna::findRoadPoly | ( | bool | debug, |
UImage * | img, | ||
double | balance, | ||
double | limit, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
bool | colorCorrect | ||
) |
Find road using new outline search algorithem
debug | produce more debug messages and images |
cam | dev is number of camera device (to be found in camera pool |
imgN | is image number to analyze |
balance | is ?? [0..1] |
limit | is ?? [0..2] |
x1,y1,x2,y2 | is seed area |
colorCorrect | is ? |
References UImage::copy(), UImage::copyMeta(), UImage::cvArr(), UImage::getLine(), UImage::height(), img, UImage::imgUpdated(), maxi(), mini(), UImage::name, UTime::Now(), UPixel::p1, UPixel::p2, UPixel::p3, UImage::setNameAndExt(), UImage::toBGR(), and UImage::width().
Referenced by UFuncImSeg::findSegments().
|
private |
Find the most distant vertex from the line between these endpoints and recursively find all vertexes in between. Adds the index to the found verteces to the vertex list. This needs to be sorted at the end.
References UPixLinked::c, mini(), UPixLinked::r, sqr(), and sqri().
|
private |
Clear openCv storeage area Get average and covariance matrix for this part of image. Returns true if image is valid.
References UMatrix::add(), UPixLinked::c, UMatrix::clear(), UImage::getLine(), UMatrix::mult(), UPixel::p1, UPixel::p2, UPixel::p3, UPixLinked::r, UMatrix::set(), UMatrix::sub(), and UMatrix::transpose().
|
inline |
Get the cromaticity SD from the seed area.
|
inline |
Get estimated floor polygon
|
inline |
Get number of vertexes in floor polygon .
|
inline |
Get pointer to number of vertexes in floor polygon .
char * UImAna::getImageName | ( | const char * | list, |
const char * | subdir, | ||
int | n, | ||
char * | buff, | ||
int | buffLng | ||
) |
Set image Get image name - static for test purpose only Get image name from a 'ls *.bmp >imgListLog' list in file 'list' in subdirectory 'subdir' in the imagePath. The n'th filename in the list is extracted and stored in 'buff'. The buffer 'buffer' has space for buffCnt characters. If no name is found, then the returned string is empty, and NULL is returned. else a pointer to the filename is returned. The filename must be a *.bmp file and the '.bmp' is removed from the filename. There is no path (imagePath nor subdir) in the filename.
References imagePath.
|
protected |
Find the distance weighted (sqr) distance from this pixel value (RGB) using the provided covariance matrix as weight (Mahalonibis) Average must be a 1x3 vector and covariance must be 3x3 vector.
References UMatrix::get(), UPixel::p1, UPixel::p2, UPixel::p3, UMatrix::setRow(), and UMatrix::setSize().
|
protected |
Find the distance weighted (sqr) distance from this pixel value (CROMATICITY) using the provided covariance matrix as weight (Mahalonibis). Average must be a 1x2 vector and covariance must be 2x2 vector. If useShadow then the red value is shadow compensated.
References UMatrix::get(), UPixel::p1, UPixel::p2, UPixel::p3, UPixLinked::r, UMatrix::setRow(), UMatrix::setSize(), and SHADOW_COMPENSATION_FACTOR.
|
inline |
Get boolean flag array to indicate that the vertex is part of an obstacle.
|
private |
Get road probability value for pixel at (r, c). If useShadow then a compensation for shadow is attempted.
References UImage::getPixRef(), UPixel::getSum(), UImage::height(), maxi(), mini(), and UImage::width().
bool UImAna::imageContourMaha | ( | UImage * | img, |
UImage * | imgC, | ||
unsigned int | row, | ||
unsigned int | col, | ||
UPixLinked * | outlineBuffer, | ||
int * | outlineBufferCnt, | ||
UMatrix4 * | averageSeed, | ||
UMatrix4 * | covarianceInv, | ||
double | diff, | ||
double | diffa | ||
) |
Find contour of image 'img' from a seed point by traversing from seedpoint clockwise until seedpoint is again reached. NB! must start at an bottom or right edge, as first test is down and there must be no way to loop back to start point clockwise. Finds an outline of area, but discards islands, that is only connected to "mainland" with one pixel. Buffer size should be at least 4000 points for a 320x240 image. Returns true if images are valid Same as above, but using Mahalonobis distance
References bool2str(), UPixLinked::c, UPixLinked::getNext(), UImage::getPixRef(), UImage::height(), UPixLinked::nx, UPixel::p1, UPixel::p2, UPixel::p3, UPixLinked::px, UPixLinked::r, UImage::setPix(), and UImage::width().
bool UImAna::imageContourMahaCroma | ( | UImage * | img, |
UImage * | imgC, | ||
unsigned int | row, | ||
unsigned int | col, | ||
int | x1, | ||
int | y1, | ||
int | x2, | ||
int | y2, | ||
int | maxH, | ||
UPixLinked * | outlineBuffer, | ||
int * | outlineBufferCnt, | ||
UMatrix4 * | averageCroma, | ||
UMatrix4 * | covarCromaInv, | ||
UMatrix4 * | averageRgb, | ||
UMatrix4 * | covarRgbInv, | ||
double | ballance, | ||
double | limit | ||
) |
Same as above, but using Mahalonobis cromaticity distance Ballance is range [0..1] - default = 0.5. limit range 2.0 (no road) to 0.0 (all road) .
References bool2str(), UPixLinked::c, UMatrix::get(), UPixLinked::getNext(), UImage::getPixRef(), UPixLinked::nx, UPixel::p1, UPixel::p2, UPixel::p3, UPixLinked::px, UPixLinked::r, and UImage::width().
bool UImAna::imageUsable | ( | UImage * | img | ) |
Test image for illumination sanity Returns true if statistics seems OK
References UPixLinked::c, UImage::getPix(), UImage::height(), UImage::isValid(), UImage::isYUV(), UImage::isYUV420(), UPixel::p1, UPixel::p2, UPixel::p3, UPixLinked::px, UPixLinked::r, UImage::width(), and UPixel::y.
|
private |
Paint base image with road detection
References UPixLinked::c, UMatrix::copy(), UImage::height(), UPixLinked::r, and UImage::width().
Compare pixels for intensity. Returns positive if p1 > p2, and 0 if equal, and negative if p2 > p1.
References a, UPixel::p1, UPixel::p2, and UPixel::p3.
Order this number of pixels after intensity in all channels (try), Returns the center element. NB! no range checks
double UImAna::polygonArea | ( | CvPoint * | poly, |
int | elements | ||
) |
Finds area of a polygon. The area is signed - positive if clockwise. Calculated as A = 0.5 * sum(a(i)) over all i in [0, n-1], where a(i) = x(i) * y(i-1) - x(i-1) * y(i), where the first element (i=0) uses the last element (n-1) i.s.f. (i-1). http://homepages.borland.com/efg2lab/Graphics/PolygonArea.htm.
References a.
bool UImAna::polygonReduce | ( | UPixLinked * | outlineBuffer, |
int * | outlineBufferCnt, | ||
double | tollerance, | ||
int | topLine | ||
) |
Reduce vertex count using a Douglas-Peuker reduction method. Method from: http://geometryalgorithms.com/Archive/algorithm_0205
References MAX_POLYGON_POINTS, and sqr().
bool UImAna::polygonReduce2 | ( | UPixLinked * | outlineBuffer, |
int * | outlineBufferCnt, | ||
double | tollerance, | ||
int | topLine | ||
) |
Remove closed appendix areas
References a, UPixLinked::c, mini(), and UPixLinked::r.
|
inline |
Set image pool
References UPixLinked::c, and UPixLinked::r.
Referenced by UFuncImSeg::findSegments().
|
inline |
Set storage pointer
References img.
|
private |
Seed area cromaticity standard deviation
|
private |
Array of CvPoint, that holds the the floor contour
|
private |
Number of points in contour
|
private |
Array of points and directions in floor outline
|
private |
Count of elements in outline
|
private |
Reference to image pool
|
private |
List of obstacle vertex. If two connected vertwx are non obstacle the the line between are not a detected obstacle, if on vertex is an obstacle, then it mustbe assumed to be so.
|
private |
Image to be analized Storage used by openCV