LArOpenCV
1
|
Class to execute a chain of algorithms to a given image input. More...
#include <ImageClusterManager.h>
Public Member Functions | |
ImageClusterManager (const std::string name="ImageClusterManager") | |
Default constructor. More... | |
~ImageClusterManager () | |
Default destructor. More... | |
const std::string & | Name () const |
Name accessor, used to identify a block of configuration parameters via fhicl. More... | |
void | Reset () |
Clears attributes except for _name. More... | |
ImageClusterBase * | GetAlg (const AlgorithmID_t id) const |
Algorithm adder: returns a unique identifier with which you can retrieve back. More... | |
ImageClusterBase * | GetAlg (const std::string name) const |
Algorithm getter via unique identifier (string name) More... | |
AlgorithmID_t | GetAlgID (const std::string name) const |
Algorithm ID getter via unique identifier (string name) More... | |
void | Configure (const ::fcllite::PSet &main_cfg) |
Read-in configuration object & enforce configurations to algorithms. More... | |
void | Process (const ::cv::Mat &img, const larcv::ImageMeta &meta) |
Execute algorithms to construct clusters + corresponding meta data. More... | |
const ImageMeta & | MetaData (const AlgorithmID_t alg_id) const |
Accessor to a specific meta data constructed by an algorithm (via algorithm id) More... | |
const Contour_t & | Cluster (const ClusterID_t cluster_id, const AlgorithmID_t alg_id=kINVALID_ALGO_ID) const |
Accessor to a specific cluster constructed by an algorithm (via algorithm + cluster id) More... | |
const ContourArray_t & | Clusters (const AlgorithmID_t alg_id=kINVALID_ALGO_ID) const |
Accessor to a set of clusters constructed by an algorithm (via algorithm id) More... | |
ClusterID_t | ClusterID (const double x, const double y, AlgorithmID_t alg_id=kINVALID_ALGO_ID) const |
For a specified algorithm, find a cluster that contains coordinate (x,y). By default "last algorithm" is used. More... | |
void | Report () const |
Report process summary. More... | |
const larcv::logger & | logger () const |
Logger getter. More... | |
void | set_verbosity (::larcv::msg::Level_t level) |
Verbosity level. More... | |
Private Attributes | |
std::string | _name |
Name identifier: used to fetch a block of configuration parameters. More... | |
bool | _configured |
Boolean flag to enforce Configure method to be called before Process. More... | |
std::vector < larcv::ImageClusterBase * > | _alg_v |
Array of algorithms to be executed. More... | |
std::map< std::string, larcv::AlgorithmID_t > | _alg_m |
Map of algorithm instance name to ID. More... | |
std::vector < larcv::ContourArray_t > | _clusters_v |
Array of resulting clusters per algorithms. More... | |
std::vector< larcv::ImageMeta > | _meta_v |
Array of meta data: one per set of clusters (updated by each algorithm) More... | |
larcv::ImageMeta | _orig_meta |
Original meta data. More... | |
bool | _profile |
Boolean flag to measure process time + report. More... | |
Watch | _watch |
Stopwatch. More... | |
size_t | _process_count |
Process counter (cumulative) More... | |
double | _process_time |
Process time (cumulative) More... | |
Class to execute a chain of algorithms to a given image input.
larcv::ImageClusterManager executes a chain of algorithms (ImageClusterBase inherit class instances)
to a provided cv::Mat image object. Each algorithm receives an image, clusters from a previous algorithm
(for the 1st algorithm this is empty), and a meta data that needs to be modified by each algorithm to interpret
the returning clusters' coordinate. After execution of algorithms it stores resulting clusters (many per algorithm)
and a meta data (one per algorithm) that are accessible via unique id (larcv::AlgorithmID_t and larcv::ClusterID_t).
At the execution of algorithms, a user must provide both image (cv::Mat) and image meta data (larcv::ImageMeta).
Each cluster is represented as a 2D contour (larcv::Contour_t), and the class provides a utility method to identify
a cluster that contains a specific 2D point (x,y) in original coordinate system. This is possible via provided
meta data for an original image that contains image origin (left bottom corner) in the original coordinate, the width
and height of an image, etc. + updated meta data from each algorithm execution.
Definition at line 34 of file ImageClusterManager.h.
larcv::ImageClusterManager::ImageClusterManager | ( | const std::string | name = "ImageClusterManager" ) |
Default constructor.
Definition at line 10 of file ImageClusterManager.cxx.
References LARCV_DEBUG, and Reset().
|
inline |
const Contour_t & larcv::ImageClusterManager::Cluster | ( | const ClusterID_t | cluster_id, |
const AlgorithmID_t | alg_id = kINVALID_ALGO_ID |
||
) | const |
Accessor to a specific cluster constructed by an algorithm (via algorithm + cluster id)
Definition at line 174 of file ImageClusterManager.cxx.
References Clusters().
ClusterID_t larcv::ImageClusterManager::ClusterID | ( | const double | x, |
const double | y, | ||
AlgorithmID_t | alg_id = kINVALID_ALGO_ID |
||
) | const |
For a specified algorithm, find a cluster that contains coordinate (x,y). By default "last algorithm" is used.
Definition at line 188 of file ImageClusterManager.cxx.
References _clusters_v, _meta_v, larcv::kINVALID_ALGO_ID, and larcv::kINVALID_CLUSTER_ID.
const ContourArray_t & larcv::ImageClusterManager::Clusters | ( | const AlgorithmID_t | alg_id = kINVALID_ALGO_ID ) | const |
Accessor to a set of clusters constructed by an algorithm (via algorithm id)
Definition at line 181 of file ImageClusterManager.cxx.
References _clusters_v, and larcv::kINVALID_ALGO_ID.
Referenced by Cluster().
void larcv::ImageClusterManager::Configure | ( | const ::fcllite::PSet & | main_cfg) |
Read-in configuration object & enforce configurations to algorithms.
Definition at line 60 of file ImageClusterManager.cxx.
References _alg_m, _alg_v, _configured, _profile, larcv::ImageClusterFactory::get(), LARCV_CRITICAL, LARCV_DEBUG, larcv::laropencv_base::logger(), and larcv::laropencv_base::set_verbosity().
ImageClusterBase * larcv::ImageClusterManager::GetAlg | ( | const AlgorithmID_t | id) | const |
Algorithm adder: returns a unique identifier with which you can retrieve back.
Algorithm getter via unique identifier (AlgorithmID_t)
Definition at line 32 of file ImageClusterManager.cxx.
References _alg_v.
Referenced by GetAlg().
ImageClusterBase * larcv::ImageClusterManager::GetAlg | ( | const std::string | name) | const |
Algorithm getter via unique identifier (string name)
Definition at line 38 of file ImageClusterManager.cxx.
References GetAlg(), and GetAlgID().
AlgorithmID_t larcv::ImageClusterManager::GetAlgID | ( | const std::string | name) | const |
Algorithm ID getter via unique identifier (string name)
Definition at line 43 of file ImageClusterManager.cxx.
References _alg_m, and larcv::kINVALID_ALGO_ID.
Referenced by GetAlg().
|
inlineinherited |
Logger getter.
Definition at line 43 of file laropencv_base.h.
References larcv::laropencv_base::_logger.
Referenced by Configure().
const ImageMeta & larcv::ImageClusterManager::MetaData | ( | const AlgorithmID_t | alg_id) | const |
Accessor to a specific meta data constructed by an algorithm (via algorithm id)
Definition at line 167 of file ImageClusterManager.cxx.
References _meta_v.
|
inline |
Name accessor, used to identify a block of configuration parameters via fhicl.
Definition at line 45 of file ImageClusterManager.h.
References _name.
Referenced by Report().
void larcv::ImageClusterManager::Process | ( | const ::cv::Mat & | img, |
const larcv::ImageMeta & | meta | ||
) |
Execute algorithms to construct clusters + corresponding meta data.
Definition at line 112 of file ImageClusterManager.cxx.
References _alg_v, _clusters_v, _configured, _meta_v, _orig_meta, _process_count, _process_time, _watch, LARCV_DEBUG, larcv::Watch::Start(), and larcv::Watch::WallTime().
void larcv::ImageClusterManager::Report | ( | ) | const |
Report process summary.
Definition at line 99 of file ImageClusterManager.cxx.
References _alg_v, _process_count, _process_time, and Name().
void larcv::ImageClusterManager::Reset | ( | ) |
Clears attributes except for _name.
Definition at line 21 of file ImageClusterManager.cxx.
References _alg_v, _clusters_v, _configured, _process_count, _process_time, and LARCV_DEBUG.
Referenced by ImageClusterManager().
|
inlineinherited |
Verbosity level.
Definition at line 47 of file laropencv_base.h.
References larcv::laropencv_base::_logger.
Referenced by larcv::ImageClusterBase::Configure(), and Configure().
|
private |
Map of algorithm instance name to ID.
Definition at line 79 of file ImageClusterManager.h.
Referenced by Configure(), and GetAlgID().
|
private |
Array of algorithms to be executed.
Definition at line 77 of file ImageClusterManager.h.
Referenced by Configure(), GetAlg(), Process(), Report(), and Reset().
|
private |
Array of resulting clusters per algorithms.
Definition at line 81 of file ImageClusterManager.h.
Referenced by ClusterID(), Clusters(), Process(), and Reset().
|
private |
Boolean flag to enforce Configure method to be called before Process.
Definition at line 75 of file ImageClusterManager.h.
Referenced by Configure(), Process(), and Reset().
|
private |
Array of meta data: one per set of clusters (updated by each algorithm)
Definition at line 83 of file ImageClusterManager.h.
Referenced by ClusterID(), MetaData(), and Process().
|
private |
Name identifier: used to fetch a block of configuration parameters.
Definition at line 73 of file ImageClusterManager.h.
Referenced by Name().
|
private |
|
private |
Process counter (cumulative)
Definition at line 91 of file ImageClusterManager.h.
|
private |
Process time (cumulative)
Definition at line 93 of file ImageClusterManager.h.
|
private |
Boolean flag to measure process time + report.
Definition at line 87 of file ImageClusterManager.h.
Referenced by Configure().
|
private |