LArOpenCV  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
larcv::ImageClusterBase Class Referenceabstract

An abstract base class for ImageCluster algorithms. More...

#include <ImageClusterBase.h>

Inheritance diagram for larcv::ImageClusterBase:
larcv::laropencv_base larcv::EmptyImageCluster larcv::SBCluster larcv::ToyImageCluster

Public Member Functions

 ImageClusterBase (const std::string name="noname")
 Default constructor: Name is used to identify a configuration parameter set via larcv::ImageClusterManager. More...
 
virtual ~ImageClusterBase ()
 Default destructor. More...
 
const std::string & Name () const
 Name accessor. More...
 
void Configure (const ::fcllite::PSet &pset)
 Configuration method. More...
 
void Profile (bool doit=true)
 Profile flag setter. More...
 
larcv::ContourArray_t Process (const larcv::ContourArray_t &clusters, const ::cv::Mat &img, larcv::ImageMeta &meta)
 wrapper execution method: internally executes Process function (see there for details) More...
 
size_t ProcessCount () const
 Process count. More...
 
double ProcessTime () const
 Process time. More...
 
const larcv::loggerlogger () const
 Logger getter. More...
 
void set_verbosity (::larcv::msg::Level_t level)
 Verbosity level. More...
 

Protected Member Functions

virtual void _Configure_ (const ::fcllite::PSet &pset)=0
 Inherited class configuration method. More...
 
virtual larcv::ContourArray_t _Process_ (const larcv::ContourArray_t &clusters, const ::cv::Mat &img, larcv::ImageMeta &meta)=0
 Execution method: given previous algorithm's output clusters, image, and metadata to be updated, produce clusters. More...
 

Private Attributes

std::string _name
 name identifier, used to fetch configuration More...
 
larcv::Watch _watch
 algorithm profile stopwatch More...
 
double _proc_time
 algorithm execution time record (cumulative) More...
 
size_t _proc_count
 algorithm execution counter (cumulative) More...
 
bool _profile
 measure process time if profile flag is on More...
 

Detailed Description

An abstract base class for ImageCluster algorithms.

Its role is to construct a set of "cluster" given an image.
An algorithm instance is expected to be "configured" and "executed" via larcv::ImageClusterManager, though a user
can perform those actions by hand (which may be useful for development work) as well if wished.

larcv::ImageClusterManager executes a chain of algorithms that inherit from ImageClusterBase. Each algorithm instance
receives an image, information about previous algorithm's clustering result, and meta data to be updated for resulting
clusters from it. See larcv::ImageClusterManager for more details.

Configuration parameters are passed via fhicllite::PSet (which is constructed via larcv::ImageClusterManager)
and a derived class must implement ImageClusterBase::Configure abstruct method. An execution of an algorithm
is done inside an abstract method ImageClusterBase::Process method which must be implemented in a child class.
A cluster is represented as a 2D contour (larcv::Contour_t). The execution method recieves 3 inputs: 0) a set of
pre-defined clusters (typically a set of clusters created by the previous algorithm in a chain executed by
larcv::ImageClusterManager), 1) cv::Mat representing 2D image, and 2) larcv::ImageMeta which contains meta data
of 1) and should be updated to interpret the algorithm's return larcv::Contour_t if needed.

Definition at line 43 of file ImageClusterBase.h.

Constructor & Destructor Documentation

larcv::ImageClusterBase::ImageClusterBase ( const std::string  name = "noname")

Default constructor: Name is used to identify a configuration parameter set via larcv::ImageClusterManager.

Definition at line 8 of file ImageClusterBase.cxx.

References LARCV_DEBUG.

9  : laropencv_base(name)
10  , _name(name)
11  , _proc_time(0.)
12  , _proc_count(0)
13  , _profile(true)
14  {LARCV_DEBUG((*this)) << "Constructed" << std::endl;}
virtual larcv::ImageClusterBase::~ImageClusterBase ( )
inlinevirtual

Default destructor.

Definition at line 51 of file ImageClusterBase.h.

51 {}

Member Function Documentation

virtual void larcv::ImageClusterBase::_Configure_ ( const ::fcllite::PSet &  pset)
protectedpure virtual

Inherited class configuration method.

Implemented in larcv::EmptyImageCluster, larcv::ToyImageCluster, and larcv::SBCluster.

Referenced by Configure().

virtual larcv::ContourArray_t larcv::ImageClusterBase::_Process_ ( const larcv::ContourArray_t clusters,
const ::cv::Mat &  img,
larcv::ImageMeta meta 
)
protectedpure virtual

Execution method: given previous algorithm's output clusters, image, and metadata to be updated, produce clusters.


Each cluster is represented by larcv::Contour_t. The first argument is clusters created by a previous
algorithm's execution (ignore if not needed). The second argumnet is the image to be wokred on. The
third argument is meta data to interpret a returned clusters (i.e. update metadata if return clusters
do not use the same coordinate reference as provided image, else leave unchanged).

Implemented in larcv::EmptyImageCluster, larcv::ToyImageCluster, and larcv::SBCluster.

Referenced by Process().

void larcv::ImageClusterBase::Configure ( const ::fcllite::PSet &  pset)

Configuration method.

Definition at line 16 of file ImageClusterBase.cxx.

References _Configure_(), _profile, LARCV_DEBUG, and larcv::laropencv_base::set_verbosity().

16  {
17 
18  LARCV_DEBUG((*this)) << "start" << std::endl;
19  this->set_verbosity((msg::Level_t)(cfg.get<unsigned short>("Verbosity",(unsigned short)(this->logger().level()))));
20  _profile = cfg.get<bool>("Profile",_profile);
21 
22  this->_Configure_(cfg);
23 
24  LARCV_DEBUG((*this)) << "end" << std::endl;
25  }
const larcv::logger& larcv::laropencv_base::logger ( ) const
inlineinherited

Logger getter.

Definition at line 43 of file laropencv_base.h.

References larcv::laropencv_base::_logger.

Referenced by larcv::ImageClusterManager::Configure().

44  { return *_logger; }
const std::string& larcv::ImageClusterBase::Name ( ) const
inline

Name accessor.

Definition at line 54 of file ImageClusterBase.h.

References _name.

54 { return _name; };
ContourArray_t larcv::ImageClusterBase::Process ( const larcv::ContourArray_t clusters,
const ::cv::Mat &  img,
larcv::ImageMeta meta 
)

wrapper execution method: internally executes Process function (see there for details)

Definition at line 27 of file ImageClusterBase.cxx.

References _proc_count, _proc_time, _Process_(), _profile, _watch, larcv::Watch::Start(), and larcv::Watch::WallTime().

30  {
31  if(!_profile) return this->_Process_(clusters,img,meta);
32  _watch.Start();
33  auto result = this->_Process_(clusters,img,meta);
35  ++_proc_count;
36  return result;
37  }
size_t larcv::ImageClusterBase::ProcessCount ( ) const
inline

Process count.

Definition at line 70 of file ImageClusterBase.h.

References _proc_count.

70 { return _proc_count; }
double larcv::ImageClusterBase::ProcessTime ( ) const
inline

Process time.

Definition at line 72 of file ImageClusterBase.h.

References _proc_time.

72 { return _proc_time; }
void larcv::ImageClusterBase::Profile ( bool  doit = true)
inline

Profile flag setter.

Definition at line 60 of file ImageClusterBase.h.

References _profile.

60 { _profile = doit; }
void larcv::laropencv_base::set_verbosity ( ::larcv::msg::Level_t  level)
inlineinherited

Verbosity level.

Definition at line 47 of file laropencv_base.h.

References larcv::laropencv_base::_logger.

Referenced by Configure(), and larcv::ImageClusterManager::Configure().

48  { _logger->set(level); }

Member Data Documentation

std::string larcv::ImageClusterBase::_name
private

name identifier, used to fetch configuration

Definition at line 92 of file ImageClusterBase.h.

Referenced by Name().

size_t larcv::ImageClusterBase::_proc_count
private

algorithm execution counter (cumulative)

Definition at line 98 of file ImageClusterBase.h.

Referenced by Process(), and ProcessCount().

double larcv::ImageClusterBase::_proc_time
private

algorithm execution time record (cumulative)

Definition at line 96 of file ImageClusterBase.h.

Referenced by Process(), and ProcessTime().

bool larcv::ImageClusterBase::_profile
private

measure process time if profile flag is on

Definition at line 100 of file ImageClusterBase.h.

Referenced by Configure(), Process(), and Profile().

larcv::Watch larcv::ImageClusterBase::_watch
private

algorithm profile stopwatch

Definition at line 94 of file ImageClusterBase.h.

Referenced by Process().


The documentation for this class was generated from the following files: