12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /**
- * @file LFSegmentation.cpp
- * @brief Local Features are connected components of a arbitrary segmentation
- * @author Erik Rodner
- * @date 01/21/2008
- */
- #ifdef NICE_USELIB_ICE
- #include <vislearning/nice.h>
- #include <image_nonvis.h>
- #include <core/image/RectangleT.h>
- #include <iostream>
- #include "vislearning/features/localfeatures/LFSegmentation.h"
- #include "vislearning/segmentation/SegLocal.h"
- #include <core/iceconversion/convertice.h>
- using namespace OBJREC;
- using namespace std;
- using namespace NICE;
- LFSegmentation::LFSegmentation( const Config *conf )
- {
- segmentation = new SegLocal ( conf );
- }
- LFSegmentation::~LFSegmentation()
- {
- delete segmentation;
- }
- int LFSegmentation::getDescSize () const
- {
- return 1;
- }
- int LFSegmentation::extractFeatures ( const NICE::Image & img, VVector & features,
- VVector & positions ) const
- {
- std::vector<ice::Contur> contours;
- segmentation->getContours ( img, contours );
- ice::Matrix xcoordinate (0,4);
- for ( vector<ice::Contur>::const_iterator i = contours.begin();
- i != contours.end();
- i++ )
- {
- int xi, yi, xa, ya;
- i->GetRect(xi, yi, xa, ya);
- if ( (ya == yi) || (xa == xi) ) continue;
- xcoordinate.Append ( ice::Vector(xi,yi,xa-xi,ya-yi) );
- }
- xcoordinate.Sort();
- for ( int i = 0 ; i < xcoordinate.rows() ; i++ )
- {
- NICE::Vector f (1);
- f.set(0.0);
- features.push_back(f);
- positions.push_back( NICE::makeEVector(xcoordinate[i]) );
- }
- return positions.size();
- }
- void LFSegmentation::visualizeFeatures ( NICE::Image & mark,
- const VVector & positions,
- size_t color ) const
- {
- for ( size_t i = 0 ; i < positions.size() ; i++ )
- {
- const NICE::Vector & pos = positions[i];
- int x = (int)pos[0];
- int y = (int)pos[1];
- int w = (int)pos[2];
- int h = (int)pos[3];
- RectangleT<Ipp8u> rect ( Coord(x, y), Coord(x+w, y+w) );
- mark.draw ( rect, (unsigned char)color );
- }
- }
- #endif
|