Lane and Object Detection
Using OpenCV and YOLOv7
Loading...
Searching...
No Matches
LaneAndObjectDetection::ObjectDetector Class Reference

YOLOv7 based object detector. More...

#include "ObjectDetector.hpp"

Public Member Functions

 ObjectDetector ()
 Construct a new ObjectDetector object.
void SetProperties (const std::string &p_yoloFolderPath, const Globals::ObjectDetectorTypes &p_objectDetectorTypes, const Globals::ObjectDetectorBackEnds &p_objectDetectorBackEnds, const Globals::ObjectDetectorBlobSizes &p_objectDetectorBlobSizes)
 Set the properties of the ObjectDetector object.
void RunObjectDetector (const cv::Mat &p_frame)
 Run the object detector against p_frame.
ObjectDetectionInformation GetInformation ()
 Get the ObjectDetectionInformation struct.

Private Attributes

cv::dnn::Net m_net
 OpenCV object which allows the use of pre-trained neural networks.
ObjectDetectionInformation m_objectDetectionInformation
 The ObjectDetectionInformation struct containing all object detection-related information.
std::vector< std::string > m_unconnectedOutputLayerNames
 The names of layers with unconnected outputs.
int32_t m_blobSize
 The spatial size for the output image used by the cv::dnn::blobFromImage function.
bool m_skipObjectDetection
 Whether to skip object detection.

Detailed Description

YOLOv7 based object detector.

Definition at line 23 of file ObjectDetector.hpp.

Constructor & Destructor Documentation

◆ ObjectDetector()

LaneAndObjectDetection::ObjectDetector::ObjectDetector ( )
explicit

Construct a new ObjectDetector object.

Definition at line 18 of file ObjectDetector.cpp.

Member Function Documentation

◆ SetProperties()

void LaneAndObjectDetection::ObjectDetector::SetProperties ( const std::string & p_yoloFolderPath,
const Globals::ObjectDetectorTypes & p_objectDetectorTypes,
const Globals::ObjectDetectorBackEnds & p_objectDetectorBackEnds,
const Globals::ObjectDetectorBlobSizes & p_objectDetectorBlobSizes )

Set the properties of the ObjectDetector object.

Parameters
p_yoloFolderPathThe folder containing the .cfg and .weights YOLO files.
p_objectDetectorTypesThe type of object detector to use with an option to disable object detection. The tiny version is more performant at the cost of accuracy.
p_objectDetectorBackEndsThe supported backends for the object detector to run on. In theory, GPU should be significantly more performant. For maximum performance CUDA should be used as the backend, however, this requires building OpenCV with CUDA which is not supported with this projects built-in installation script.
p_objectDetectorBlobSizesThe supported blob sizes for the object detector to run with. The larger the blob size the more performant the detector at the cost of performance.

Definition at line 23 of file ObjectDetector.cpp.

◆ RunObjectDetector()

void LaneAndObjectDetection::ObjectDetector::RunObjectDetector ( const cv::Mat & p_frame)

Run the object detector against p_frame.

Parameters
p_frameThe frame to run the object detector against.

Definition at line 78 of file ObjectDetector.cpp.

◆ GetInformation()

ObjectDetectionInformation LaneAndObjectDetection::ObjectDetector::GetInformation ( )

Get the ObjectDetectionInformation struct.

Returns
ObjectDetectionInformation The ObjectDetectionInformation struct.

Definition at line 140 of file ObjectDetector.cpp.

Member Data Documentation

◆ m_net

cv::dnn::Net LaneAndObjectDetection::ObjectDetector::m_net
private

OpenCV object which allows the use of pre-trained neural networks.

Definition at line 66 of file ObjectDetector.hpp.

◆ m_objectDetectionInformation

ObjectDetectionInformation LaneAndObjectDetection::ObjectDetector::m_objectDetectionInformation
private

The ObjectDetectionInformation struct containing all object detection-related information.

Definition at line 71 of file ObjectDetector.hpp.

◆ m_unconnectedOutputLayerNames

std::vector<std::string> LaneAndObjectDetection::ObjectDetector::m_unconnectedOutputLayerNames
private

The names of layers with unconnected outputs.

Definition at line 76 of file ObjectDetector.hpp.

◆ m_blobSize

int32_t LaneAndObjectDetection::ObjectDetector::m_blobSize
private

The spatial size for the output image used by the cv::dnn::blobFromImage function.

Definition at line 81 of file ObjectDetector.hpp.

◆ m_skipObjectDetection

bool LaneAndObjectDetection::ObjectDetector::m_skipObjectDetection
private

Whether to skip object detection.

Definition at line 86 of file ObjectDetector.hpp.


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