Skip to content

Commit

Permalink
Just some minor readability changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr-deref committed Feb 1, 2022
1 parent 3c7458f commit 3a1a24a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Serial/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ void SerialPort::open()
{
m_hCom = CreateFileA(name.c_str(), static_cast<unsigned long>(mode), false, nullptr, CREATE_NEW, OPEN_EXISTING, nullptr);

if (INVALID_HANDLE_VALUE == m_hCom) throw std::runtime_error("Cannot connect to serial port [" + name + ']');
if (INVALID_HANDLE_VALUE == m_hCom)
throw std::runtime_error("Cannot connect to serial port [" + name + ']');

DCB m_serialParams { 0 };
m_serialParams.DCBlength = sizeof(m_serialParams);

const bool currComStatusRetrieved = GetCommState(m_hCom, &m_serialParams);

if (!currComStatusRetrieved) throw std::runtime_error("Could not retrieve serial port status.");
if (!currComStatusRetrieved)
throw std::runtime_error("Could not retrieve serial port status.");

m_serialParams.BaudRate = baudrate;
m_serialParams.fBinary = true;
Expand Down Expand Up @@ -52,7 +54,6 @@ void SerialPort::write(const char *data, uint32_t count)
if (!isWritten) throw std::runtime_error("Could not write to serial port.");
}


SerialReadData SerialPort::read()
{
SerialReadData readData;
Expand Down
14 changes: 10 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ int main(int argc, char **argv) {
try {
spdlog::info("Reading model from file...");
PROFC(EASY_BLOCK("Reading model from file"));
cv::dnn::Net nnet = cv::dnn::readNetFromCaffe(am.at("prototxt").get<std::string>(), am.at("model").get<std::string>());
cv::dnn::Net nnet = cv::dnn::readNetFromCaffe(
am.at("prototxt").get<std::string>(),
am.at("model").get<std::string>());
PROFC(EASY_END_BLOCK);

const float defaultConfidence = 0.8f;
Expand All @@ -245,8 +247,11 @@ int main(int argc, char **argv) {
// size[3] - something like data per detection (especially for detections
// produced by cv::Net)

const cv::Mat detections = cv::Mat(detection.size[2], detection.size[3], CV_32F, (void *)detection.ptr<float>());
if (!faceRects.empty()) faceRects.clear();
const cv::Mat detections = cv::Mat(detection.size[2], detection.size[3],
CV_32F,
(void *)detection.ptr<float>());
if (!faceRects.empty())
faceRects.clear();

for (int i = 0; i < detections.rows; i++) {
const float confidence = detections.at<float>(i, 2);
Expand All @@ -269,7 +274,8 @@ int main(int argc, char **argv) {
humansWatched = faceRects.size();
}
catch (const std::exception &e) {
spdlog::warn("Dropping detection frame, something is wrong.\n{}", e.what());
spdlog::warn("Dropping detection frame, something is wrong.\n{}",
e.what());
continue;
}
}
Expand Down

0 comments on commit 3a1a24a

Please sign in to comment.