Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
Timestamp in console
Browse files Browse the repository at this point in the history
  • Loading branch information
brian8544 committed Jun 8, 2023
1 parent 59a6c63 commit 2446ce0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Main.cpp
Expand Up @@ -47,6 +47,7 @@ void readSettings()
{
if (settingsFile.peek() == std::ifstream::traits_type::eof())
{
printCurrentTime();
std::cout << "settings.conf is empty or corrupt." << std::endl;
settingsFile.close();
}
Expand All @@ -66,6 +67,7 @@ void readSettings()
}
else
{
printCurrentTime();
std::cout << "Failed to open settings.conf file." << std::endl;
system("pause");
exit(1); // Use exit(1) to indicate an error
Expand Down Expand Up @@ -107,6 +109,7 @@ void detectAndDraw(cv::Mat& img, cv::CascadeClassifier& cascade, double scale)
cv::Mat compareImg = cv::imread(entry.path().string());
if (compareImg.empty())
{
printCurrentTime();
std::cout << "Failed to read image: " << entry.path().filename().string() << std::endl;
continue; // Skip to the next image
}
Expand All @@ -125,12 +128,13 @@ void detectAndDraw(cv::Mat& img, cv::CascadeClassifier& cascade, double scale)
}
catch (const cv::Exception& e)
{
printCurrentTime();
std::cout << "Error occurred during template matching: " << e.what() << std::endl;
continue; // Skip to the next image
}

// Set a threshold for the match
double threshold = 0.1; // 0.8 = default
double threshold = 0.8; // 0.8 = default
double minVal; // double maxVal;
cv::Point minLoc; // cv::Point maxLoc;
cv::minMaxLoc(result, &minVal, &maxVal, &minLoc); // cv::minMaxLoc(result, nullptr, &maxVal, nullptr, &maxLoc);
Expand Down Expand Up @@ -161,6 +165,7 @@ void detectAndDraw(cv::Mat& img, cv::CascadeClassifier& cascade, double scale)
cv::Mat compareImg = cv::imread(entry.path().string());
if (compareImg.empty())
{
printCurrentTime();
std::cout << "Failed to read image: " << entry.path().filename().string() << std::endl;
continue; // Skip to the next image
}
Expand All @@ -179,18 +184,20 @@ void detectAndDraw(cv::Mat& img, cv::CascadeClassifier& cascade, double scale)
}
catch (const cv::Exception& e)
{
printCurrentTime();
std::cout << "Error occurred during template matching: " << e.what() << std::endl;
continue; // Skip to the next image
}

// Set a threshold for the match
double threshold = 0.1; // 0.8 = default
double threshold = 0.8; // 0.8 = default
double maxVal;
cv::Point maxLoc;
cv::minMaxLoc(result, nullptr, &maxVal, nullptr, &maxLoc);

if (maxVal > threshold && entry.path().filename().string() != bestMatchName)
{
printCurrentTime();
// Print other matches to the console
std::cout << "Other match: " << entry.path().filename().string() << std::endl;
}
Expand All @@ -210,6 +217,7 @@ int main(int argc, char** argv)
{
// Face cascade could not be found
std::system("cls");
printCurrentTime();
std::cout << "Could not find the face cascade." << std::endl;
std::system("pause");
return -1;
Expand All @@ -222,6 +230,7 @@ int main(int argc, char** argv)
if (!capture.isOpened())
{
std::system("cls");
printCurrentTime();
std::cout << "Error opening camera." << std::endl;
std::system("pause");
return -1;
Expand Down

0 comments on commit 2446ce0

Please sign in to comment.