Skip to content

Commit

Permalink
Added objects type
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhny007 committed Dec 16, 2017
1 parent da22d84 commit 5eb01cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Detector/DNNDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void DNNDetector::Detect(cv::UMat& colorFrame)
cv::Mat detection = m_net.forward("detection_out"); //compute output

std::vector<double> layersTimings;
double freq = cv::getTickFrequency() / 1000;
double time = m_net.getPerfProfile(layersTimings) / freq;
//double freq = cv::getTickFrequency() / 1000;
//double time = m_net.getPerfProfile(layersTimings) / freq;

cv::Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr<float>());

Expand All @@ -98,12 +98,12 @@ void DNNDetector::Detect(cv::UMat& colorFrame)

cv::Rect object((int)xLeftBottom, (int)yLeftBottom, (int)(xRightTop - xLeftBottom), (int)(yRightTop - yLeftBottom));

m_regions.push_back(object);
m_regions.push_back(CRegion(object, classNames[objectClass], confidence));

//cv::rectangle(frame, object, Scalar(0, 255, 0));
std::string label = classNames[objectClass] + ": " + std::to_string(confidence);
int baseLine = 0;
cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
//std::string label = classNames[objectClass] + ": " + std::to_string(confidence);
//int baseLine = 0;
//cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
//cv::rectangle(frame, cv::Rect(cv::Point(xLeftBottom, yLeftBottom - labelSize.height), cv::Size(labelSize.width, labelSize.height + baseLine)), cv::Scalar(255, 255, 255), CV_FILLED);
//cv::putText(frame, label, Point(xLeftBottom, yLeftBottom), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,0,0));
}
Expand Down
7 changes: 7 additions & 0 deletions VideoExample.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,13 @@ class DNNDetectorExample : public VideoExample
)
{
DrawTrack(frame, 1, *track);

std::string label = track->m_lastRegion.m_type + ": " + std::to_string(track->m_lastRegion.m_confidence);
int baseLine = 0;
cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
auto rect(track->GetLastRect());
cv::rectangle(frame, cv::Rect(cv::Point(rect.x, rect.y - labelSize.height), cv::Size(labelSize.width, labelSize.height + baseLine)), cv::Scalar(255, 255, 255), CV_FILLED);
cv::putText(frame, label, cv::Point(rect.x, rect.y), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 0));
}
}

Expand Down
10 changes: 10 additions & 0 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CRegion
{
public:
CRegion()
: m_type(""), m_confidence(-1)
{
}

Expand All @@ -27,8 +28,17 @@ class CRegion

}

CRegion(const cv::Rect& rect, const std::string& type, float confidence)
: m_rect(rect), m_type(type), m_confidence(confidence)
{

}

cv::Rect m_rect;
std::vector<cv::Point2f> m_points;

std::string m_type;
float m_confidence;
};

typedef std::vector<CRegion> regions_t;
Expand Down

0 comments on commit 5eb01cd

Please sign in to comment.