Compute Library
 21.08
DetectionOutputAccessor Class Referencefinal

Detection output accessor class. More...

#include <GraphUtils.h>

Collaboration diagram for DetectionOutputAccessor:
[legend]

Public Member Functions

 DetectionOutputAccessor (const std::string &labels_path, std::vector< TensorShape > &imgs_tensor_shapes, std::ostream &output_stream=std::cout)
 Constructor. More...
 
 DetectionOutputAccessor (DetectionOutputAccessor &&)=default
 Allow instances of this class to be move constructed. More...
 
 DetectionOutputAccessor (const DetectionOutputAccessor &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
DetectionOutputAccessoroperator= (const DetectionOutputAccessor &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
bool access_tensor (ITensor &tensor) override
 Interface to be implemented to access a given tensor. More...
 
- Public Member Functions inherited from ITensorAccessor
virtual ~ITensorAccessor ()=default
 Default virtual destructor. More...
 

Detailed Description

Detection output accessor class.

Definition at line 346 of file GraphUtils.h.

Constructor & Destructor Documentation

◆ DetectionOutputAccessor() [1/3]

DetectionOutputAccessor ( const std::string &  labels_path,
std::vector< TensorShape > &  imgs_tensor_shapes,
std::ostream &  output_stream = std::cout 
)

Constructor.

Parameters
[in]labels_pathPath to labels text file.
[in]imgs_tensor_shapesNetwork input images tensor shapes.
[out]output_stream(Optional) Output stream

Definition at line 513 of file GraphUtils.cpp.

References ARM_COMPUTE_ERROR_VAR, ITensor::buffer(), ITensor::info(), ITensorInfo::offset_first_element_in_bytes(), ValidRegion::shape, ITensorInfo::valid_region(), and Dimensions< T >::y().

514  : _labels(), _tensor_shapes(std::move(imgs_tensor_shapes)), _output_stream(output_stream)
515 {
516  _labels.clear();
517 
518  std::ifstream ifs;
519 
520  try
521  {
522  ifs.exceptions(std::ifstream::badbit);
523  ifs.open(labels_path, std::ios::in | std::ios::binary);
524 
525  for(std::string line; !std::getline(ifs, line).fail();)
526  {
527  _labels.emplace_back(line);
528  }
529  }
530  catch(const std::ifstream::failure &e)
531  {
532  ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", labels_path.c_str(), e.what());
533  }
534 }
#define ARM_COMPUTE_ERROR_VAR(msg,...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:346

◆ DetectionOutputAccessor() [2/3]

Allow instances of this class to be move constructed.

◆ DetectionOutputAccessor() [3/3]

Prevent instances of this class from being copied (As this class contains pointers)

Member Function Documentation

◆ access_tensor()

bool access_tensor ( ITensor tensor)
overridevirtual

Interface to be implemented to access a given tensor.

Parameters
[in]tensorTensor to be accessed
Returns
True if access is successful else false

Implements ITensorAccessor.

Definition at line 568 of file GraphUtils.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ITensorInfo::data_type(), arm_compute::F32, and ITensor::info().

569 {
571 
572  switch(tensor.info()->data_type())
573  {
574  case DataType::F32:
575  access_predictions_tensor<float>(tensor);
576  break;
577  default:
578  ARM_COMPUTE_ERROR("NOT SUPPORTED!");
579  }
580 
581  return false;
582 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:786

◆ operator=()

DetectionOutputAccessor& operator= ( const DetectionOutputAccessor )
delete

Prevent instances of this class from being copied (As this class contains pointers)


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