Loading src/ArmorDetectionApp.cpp +3 −3 Changes for src/ArmorDetectionApp.cpp: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -81,11 +81,11 @@ void VideoArmorDetectionApp::run() { bool hasValidTarget = smoother.smooth(hasTarget, target); if (hasValidTarget) { ArmorDetectionApp::drawTarget(frame, target); std::cout << "Smoothed: " << target << std::endl; std::cout << "Valid Target: " << target << std::endl; } else { std::cout << "No Smoothed" << std::endl; std::cout << "No Valid Target" << std::endl; } std::cout << "--------------------" << std::endl; std::cout << "------------------------" << std::endl; cv::imshow("Aimed", frame); Loading src/ArmorDetectionApp.h +1 −0 Changes for src/ArmorDetectionApp.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ namespace ArmorDetection { } // namespace ArmorDetection using ArmorDetection::ArmorDetectionApp; using ArmorDetection::ImgArmorDetectionApp; using ArmorDetection::VideoArmorDetectionApp; using ArmorDetection::BarColor; Loading src/Detector.cpp +12 −16 Changes for src/Detector.cpp: 12 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -38,24 +38,20 @@ bool Detector::target(const Mat &frame, Point &targetCenter) { void Detector::hsv(const Mat &frame, Mat &lightArea, Mat &haloArea) { Mat hsvFrame; if (color == BarColor::BLUE) { cv::cvtColor(frame, hsvFrame, cv::COLOR_BGR2HSV); if (color == BarColor::RED) { Mat hsvSpace[3]; cv::split(hsvFrame, hsvSpace); Mat &h = hsvSpace[0]; h += 107; h -= (h / 180) * 180; cv::merge(hsvSpace, 3, hsvFrame); addDebugImg("Red2Blue", hsvFrame); Scalar lowerBlueLight(90, 0, 200), upperBlueLight(120, 180, 255); Scalar lowerBlueHalo(90, 120, 185), upperBlueHalo(120, 255, 255); cv::inRange(hsvFrame, lowerBlueLight, upperBlueLight, lightArea); cv::inRange(hsvFrame, lowerBlueHalo, upperBlueHalo, haloArea); } else { // For BarColor::RED // cheat openCV: swap Red and Blue channels implicitly cv::cvtColor(frame, hsvFrame, cv::COLOR_RGB2HSV); Scalar lowerBlueLight(100, 0, 200), upperBlueLight(130, 180, 255); Scalar lowerBlueHalo(100, 120, 185), upperBlueHalo(130, 255, 255); cv::inRange(hsvFrame, lowerBlueLight, upperBlueLight, lightArea); cv::inRange(hsvFrame, lowerBlueHalo, upperBlueHalo, haloArea); } unsigned char lowerLight[3] = {90, 0, 200}; unsigned char upperLight[3] = {120, 180, 255}; unsigned char lowerHalo[3] = {90, 120, 185}; unsigned char upperHalo[3] = {120, 255, 255}; cv::inRange(hsvFrame, Mat(1, 3, CV_8UC1, lowerLight), Mat(1, 3, CV_8UC1, upperLight), lightArea); cv::inRange(hsvFrame, Mat(1, 3, CV_8UC1, lowerHalo), Mat(1, 3, CV_8UC1, upperHalo), haloArea); } Loading src/main.cpp +17 −8 Changes for src/main.cpp: 17 added lines, 8 removed lines. Original line number Diff line number Diff line #include <iostream> #include <memory> #include "ArmorDetectionApp.h" typedef std::unique_ptr<ArmorDetectionApp> Ptr; int main(int argc, char **argv) { Ptr app; // ImgArmorDetectionApp app( try { // app = Ptr(new ImgArmorDetectionApp( // BarColor::BLUE, // cv::Size(640, 480), // "/home/jeeken/Pictures/blue_dark", // "/home/jeeken/Pictures/blue", // "jpg", // false // ); VideoArmorDetectionApp app( // true // )); app = Ptr(new VideoArmorDetectionApp( BarColor::BLUE, cv::Size(640, 480), "/home/jeeken/Videos/live_blue.avi", false ); app.run(); )); app->run(); } catch (std::exception &e) { std::cerr << "Sorry: " << e.what() << std::endl; } return 0; } No newline at end of file Loading
src/ArmorDetectionApp.cpp +3 −3 Changes for src/ArmorDetectionApp.cpp: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -81,11 +81,11 @@ void VideoArmorDetectionApp::run() { bool hasValidTarget = smoother.smooth(hasTarget, target); if (hasValidTarget) { ArmorDetectionApp::drawTarget(frame, target); std::cout << "Smoothed: " << target << std::endl; std::cout << "Valid Target: " << target << std::endl; } else { std::cout << "No Smoothed" << std::endl; std::cout << "No Valid Target" << std::endl; } std::cout << "--------------------" << std::endl; std::cout << "------------------------" << std::endl; cv::imshow("Aimed", frame); Loading
src/ArmorDetectionApp.h +1 −0 Changes for src/ArmorDetectionApp.h: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ namespace ArmorDetection { } // namespace ArmorDetection using ArmorDetection::ArmorDetectionApp; using ArmorDetection::ImgArmorDetectionApp; using ArmorDetection::VideoArmorDetectionApp; using ArmorDetection::BarColor; Loading
src/Detector.cpp +12 −16 Changes for src/Detector.cpp: 12 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -38,24 +38,20 @@ bool Detector::target(const Mat &frame, Point &targetCenter) { void Detector::hsv(const Mat &frame, Mat &lightArea, Mat &haloArea) { Mat hsvFrame; if (color == BarColor::BLUE) { cv::cvtColor(frame, hsvFrame, cv::COLOR_BGR2HSV); if (color == BarColor::RED) { Mat hsvSpace[3]; cv::split(hsvFrame, hsvSpace); Mat &h = hsvSpace[0]; h += 107; h -= (h / 180) * 180; cv::merge(hsvSpace, 3, hsvFrame); addDebugImg("Red2Blue", hsvFrame); Scalar lowerBlueLight(90, 0, 200), upperBlueLight(120, 180, 255); Scalar lowerBlueHalo(90, 120, 185), upperBlueHalo(120, 255, 255); cv::inRange(hsvFrame, lowerBlueLight, upperBlueLight, lightArea); cv::inRange(hsvFrame, lowerBlueHalo, upperBlueHalo, haloArea); } else { // For BarColor::RED // cheat openCV: swap Red and Blue channels implicitly cv::cvtColor(frame, hsvFrame, cv::COLOR_RGB2HSV); Scalar lowerBlueLight(100, 0, 200), upperBlueLight(130, 180, 255); Scalar lowerBlueHalo(100, 120, 185), upperBlueHalo(130, 255, 255); cv::inRange(hsvFrame, lowerBlueLight, upperBlueLight, lightArea); cv::inRange(hsvFrame, lowerBlueHalo, upperBlueHalo, haloArea); } unsigned char lowerLight[3] = {90, 0, 200}; unsigned char upperLight[3] = {120, 180, 255}; unsigned char lowerHalo[3] = {90, 120, 185}; unsigned char upperHalo[3] = {120, 255, 255}; cv::inRange(hsvFrame, Mat(1, 3, CV_8UC1, lowerLight), Mat(1, 3, CV_8UC1, upperLight), lightArea); cv::inRange(hsvFrame, Mat(1, 3, CV_8UC1, lowerHalo), Mat(1, 3, CV_8UC1, upperHalo), haloArea); } Loading
src/main.cpp +17 −8 Changes for src/main.cpp: 17 added lines, 8 removed lines. Original line number Diff line number Diff line #include <iostream> #include <memory> #include "ArmorDetectionApp.h" typedef std::unique_ptr<ArmorDetectionApp> Ptr; int main(int argc, char **argv) { Ptr app; // ImgArmorDetectionApp app( try { // app = Ptr(new ImgArmorDetectionApp( // BarColor::BLUE, // cv::Size(640, 480), // "/home/jeeken/Pictures/blue_dark", // "/home/jeeken/Pictures/blue", // "jpg", // false // ); VideoArmorDetectionApp app( // true // )); app = Ptr(new VideoArmorDetectionApp( BarColor::BLUE, cv::Size(640, 480), "/home/jeeken/Videos/live_blue.avi", false ); app.run(); )); app->run(); } catch (std::exception &e) { std::cerr << "Sorry: " << e.what() << std::endl; } return 0; } No newline at end of file