From 2c65d2dcf2d1c0373be6706b3fa668c422d7e046 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 14:03:20 +0300 Subject: [PATCH 1/6] add my sample, but not ready --- CMakeLists.txt | 4 +- sample_ekaterina_maljutina/CMakeLists.txt | 7 ++ sample_ekaterina_maljutina/application.cpp | 123 +++++++++++++++++++++ sample_ekaterina_maljutina/application.hpp | 49 ++++++++ sample_ekaterina_maljutina/main.cpp | 44 ++++++++ sample_ekaterina_maljutina/processing.cpp | 18 +++ sample_ekaterina_maljutina/processing.hpp | 9 ++ 7 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 sample_ekaterina_maljutina/CMakeLists.txt create mode 100644 sample_ekaterina_maljutina/application.cpp create mode 100644 sample_ekaterina_maljutina/application.hpp create mode 100644 sample_ekaterina_maljutina/main.cpp create mode 100644 sample_ekaterina_maljutina/processing.cpp create mode 100644 sample_ekaterina_maljutina/processing.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1949c..8ada8ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ set(LIBRARY_DEPS ${OpenCV_LIBS}) # BUILD add_subdirectory(sample_template) -# Add you directory here -# add_subdirectory(sample_YOUR_NAME) +add_subdirectory(sample_ekaterina_maljutina) + # REPORT message( STATUS "") diff --git a/sample_ekaterina_maljutina/CMakeLists.txt b/sample_ekaterina_maljutina/CMakeLists.txt new file mode 100644 index 0000000..006e7f1 --- /dev/null +++ b/sample_ekaterina_maljutina/CMakeLists.txt @@ -0,0 +1,7 @@ +set(target "sample_ekaterina_maljutina") + +file(GLOB hdrs "*.hpp") +file(GLOB srcs "*.cpp") + +add_executable(${target} ${srcs} ${hdrs}) +target_link_libraries(${target} ${LIBRARY_DEPS}) diff --git a/sample_ekaterina_maljutina/application.cpp b/sample_ekaterina_maljutina/application.cpp new file mode 100644 index 0000000..4cc18d1 --- /dev/null +++ b/sample_ekaterina_maljutina/application.cpp @@ -0,0 +1,123 @@ +#include "application.hpp" +#include "processing.hpp" + +#include + +using namespace cv; + +int Application::parseArguments(int argc, const char **argv, + Application::Parameters ¶ms) +{ + if (argc < 2) + { + return 1; + } + params.imgFileName = std::string(argv[1]); + return 0; +} + +int Application::getFrame(const std::string &fileName, Mat& src) +{ + src = imread(fileName); + if (src.empty()) + { + return 1; + } + return 0; +} + +int Application::processFrame(const Mat& src, Mat& dst) +{ + processor.processFrame(src, dst); + + if (dst.empty()) + { + return 1; + } + + return 0; +} + +int Application::drawButtons(Mat &display) +{ + guiState.onButtonPlace = Rect(20, display.rows - 60, 120, 40); + guiState.offButtonPlace = Rect(160, display.rows - 60, 120, 40); + rectangle(display, guiState.onButtonPlace, + Scalar(128, 128, 128), CV_FILLED); + rectangle(display, guiState.offButtonPlace, + Scalar(128, 128, 128), CV_FILLED); + + putText(display, "on", + Point(guiState.onButtonPlace.x + guiState.onButtonPlace.width / 2 - 15, + guiState.onButtonPlace.y + guiState.onButtonPlace.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + putText(display, "off", + Point(guiState.offButtonPlace.x + guiState.offButtonPlace.width / 2 - 20, + guiState.offButtonPlace.y + guiState.offButtonPlace.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + return 0; +} + +int Application::showFrame(const std::string &caption, + const Mat& src, Mat& dst) +{ + if (guiState.state == OffFilter) + { + src.copyTo(dst); + } + else if (guiState.state == OnFilter) + { + processFrame(src, dst); + } + else + { + return 1; + } + + Mat display(src.rows, src.cols + dst.cols, src.type()); + Mat srcRoi = display(Rect(0, 0, src.cols, src.rows)); + src.copyTo(srcRoi); + Mat dstRoi = display(Rect(src.cols, 0, dst.cols, dst.rows)); + dst.copyTo(dstRoi); + + drawButtons(display); + + namedWindow(caption); + imshow(caption, display); + setMouseCallback(caption, onButtonsOnOffClick, &guiState); + char key = waitKey(1); + + return key; +} + +void onButtonsOnOffClick(int eventId, int x, int y, int flags, void *userData) +{ + if (eventId != EVENT_LBUTTONDOWN) + { + return; + } + Application::GUIElementsState *elems = + (Application::GUIElementsState *)userData; + if (onButtonClicked(elems->onButtonPlace, x, y)) + { + elems->state = Application::OnFilter; + return; + } + if (onButtonClicked(elems->offButtonPlace, x, y)) + { + elems->state = Application::OffFilter; + return; + } +} + +bool onButtonClicked(cv::Rect buttonPlace, int x, int y) +{ + if (x < buttonPlace.x || x > buttonPlace.x + buttonPlace.width || + y < buttonPlace.y || y > buttonPlace.y + buttonPlace.height) + { + return false; + } + return true; +} + diff --git a/sample_ekaterina_maljutina/application.hpp b/sample_ekaterina_maljutina/application.hpp new file mode 100644 index 0000000..862cc3f --- /dev/null +++ b/sample_ekaterina_maljutina/application.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include + +#include "processing.hpp" + +bool onButtonClicked(cv::Rect buttonPlace, int x, int y); +void onButtonsOnOffClick(int eventId, int x, int y, int flags, void *userData); + +class Application +{ + public: + enum WindowState + { + OnFilter, + OffFilter + }; + struct Parameters + { + std::string imgFileName; + }; + struct GUIElementsState + { + WindowState state; + cv::Rect onButtonPlace; + cv::Rect offButtonPlace; + }; + int parseArguments(int argc, const char **argv, Parameters ¶ms); + int getFrame(const std::string &fileName, cv::Mat& src); + int processFrame(const cv::Mat& src, cv::Mat& dst); + int showFrame(const std::string &caption, + const cv::Mat& src, cv::Mat& dst); + friend void onButtonsOnOffClick(int eventId, int x, int y, + int flags, void *userData); + Application() + { + guiState.state = OnFilter; + }; + + private: + Processing processor; + GUIElementsState guiState; + + int drawButtons(cv::Mat &display); + + friend bool onButtonClicked(cv::Rect buttonPlace, int x, int y); +}; diff --git a/sample_ekaterina_maljutina/main.cpp b/sample_ekaterina_maljutina/main.cpp new file mode 100644 index 0000000..43ff041 --- /dev/null +++ b/sample_ekaterina_maljutina/main.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include "application.hpp" + +using namespace std; +using namespace cv; + +enum ErrorCode { + OK, + WRONG_ARGUMENTS, + WRONG_INPUT, + CANT_PROCESS +}; + +int main(int argc, const char **argv) +{ + Application app; + Application::Parameters params; + + if (app.parseArguments(argc, argv, params) != 0) + { + cout << "sample_template " << endl; + cout << " - image name for filtering" << endl; + return WRONG_ARGUMENTS; + } + + Mat src; + if (app.getFrame(params.imgFileName, src) != 0) + { + cout << "Error: \'src\' image is null or empty!" << endl; + return WRONG_INPUT; + } + + const std::string caption = "OpenCV Sample"; + char key = 0; + Mat dst(src.rows, src.cols, src.type()); + while (key != 27) // Esc + { + key = app.showFrame(caption, src, dst); + } + + return OK; +} diff --git a/sample_ekaterina_maljutina/processing.cpp b/sample_ekaterina_maljutina/processing.cpp new file mode 100644 index 0000000..bd51a88 --- /dev/null +++ b/sample_ekaterina_maljutina/processing.cpp @@ -0,0 +1,18 @@ +#include "processing.hpp" + +#include + +using namespace cv; + +void Processing::processFrame(const cv::Mat& src, cv::Mat& dst) +{ + src.copyTo(dst); + + cv::Rect region(src.rows/4, src.cols/4, src.rows/2, src.cols/2); + Mat roi = dst(region); + + const int kSize = 11; + medianBlur(roi, roi, kSize); + + rectangle(dst, region, Scalar(255, 0, 0)); +} diff --git a/sample_ekaterina_maljutina/processing.hpp b/sample_ekaterina_maljutina/processing.hpp new file mode 100644 index 0000000..65f29fc --- /dev/null +++ b/sample_ekaterina_maljutina/processing.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include + +class Processing +{ + public: + void processFrame(const cv::Mat& src, cv::Mat& dst); +}; From 62f9cb486e44c13fafce3ae32dabd7456dd96343 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 14:52:34 +0300 Subject: [PATCH 2/6] add moving region on image --- sample_ekaterina_maljutina/processing.cpp | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sample_ekaterina_maljutina/processing.cpp b/sample_ekaterina_maljutina/processing.cpp index bd51a88..af0c220 100644 --- a/sample_ekaterina_maljutina/processing.cpp +++ b/sample_ekaterina_maljutina/processing.cpp @@ -4,15 +4,45 @@ using namespace cv; +int step = 0; +int size = 0; + +int x = 0; +int y = 0; + void Processing::processFrame(const cv::Mat& src, cv::Mat& dst) { + size +=2; src.copyTo(dst); + cv::Rect region; + + if (( x + step + src.rows/2 + size < src.rows) + && (y + step + src.cols/2 + size < src.cols)) + { + + cv::Rect r(x + step , y + step, src.rows/2 + size, src.cols/2 + size); + region =r; + + } + else + { + //size = size - 5; + if (step != 0) + step = 0; + x=0; + y=0; + cv::Rect r(x ,y , src.rows/2 + size, src.cols/2 + size ); + region =r; + size = 0; + } - cv::Rect region(src.rows/4, src.cols/4, src.rows/2, src.cols/2); Mat roi = dst(region); const int kSize = 11; medianBlur(roi, roi, kSize); rectangle(dst, region, Scalar(255, 0, 0)); + + step = step + 2 ; + } From dd266cf466df383ba4baf8ef1e0cd639283e5885 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 14:59:21 +0300 Subject: [PATCH 3/6] add my buttom --- sample_ekaterina_maljutina/application.cpp | 11 +++++++++++ sample_ekaterina_maljutina/application.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/sample_ekaterina_maljutina/application.cpp b/sample_ekaterina_maljutina/application.cpp index 4cc18d1..4c8b4f2 100644 --- a/sample_ekaterina_maljutina/application.cpp +++ b/sample_ekaterina_maljutina/application.cpp @@ -42,6 +42,10 @@ int Application::drawButtons(Mat &display) { guiState.onButtonPlace = Rect(20, display.rows - 60, 120, 40); guiState.offButtonPlace = Rect(160, display.rows - 60, 120, 40); + guiState.newButtom = Rect(300,display.rows - 60, 120,40); + + rectangle(display, guiState.newButtom, + Scalar(128, 128, 128), CV_FILLED); rectangle(display, guiState.onButtonPlace, Scalar(128, 128, 128), CV_FILLED); rectangle(display, guiState.offButtonPlace, @@ -56,6 +60,13 @@ int Application::drawButtons(Mat &display) guiState.offButtonPlace.y + guiState.offButtonPlace.height / 2 + 10), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + putText(display, "my_but", + Point(guiState.newButtom.x + guiState.newButtom.width / 2 - 55, + guiState.newButtom.y + guiState.newButtom.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + return 0; } diff --git a/sample_ekaterina_maljutina/application.hpp b/sample_ekaterina_maljutina/application.hpp index 862cc3f..ec8909d 100644 --- a/sample_ekaterina_maljutina/application.hpp +++ b/sample_ekaterina_maljutina/application.hpp @@ -26,6 +26,7 @@ class Application WindowState state; cv::Rect onButtonPlace; cv::Rect offButtonPlace; + cv::Rect newButtom; }; int parseArguments(int argc, const char **argv, Parameters ¶ms); int getFrame(const std::string &fileName, cv::Mat& src); From a559bf391ba98032341b32b4a2c83525a7124093 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 15:37:36 +0300 Subject: [PATCH 4/6] add saveButtom click --- sample_ekaterina_maljutina/application.cpp | 39 ++++++++++++++++++++-- sample_ekaterina_maljutina/application.hpp | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/sample_ekaterina_maljutina/application.cpp b/sample_ekaterina_maljutina/application.cpp index 4c8b4f2..eefa30c 100644 --- a/sample_ekaterina_maljutina/application.cpp +++ b/sample_ekaterina_maljutina/application.cpp @@ -1,6 +1,6 @@ #include "application.hpp" #include "processing.hpp" - +#include "ctime" #include using namespace cv; @@ -73,6 +73,7 @@ int Application::drawButtons(Mat &display) int Application::showFrame(const std::string &caption, const Mat& src, Mat& dst) { + if (guiState.state == OffFilter) { src.copyTo(dst); @@ -90,8 +91,35 @@ int Application::showFrame(const std::string &caption, Mat srcRoi = display(Rect(0, 0, src.cols, src.rows)); src.copyTo(srcRoi); Mat dstRoi = display(Rect(src.cols, 0, dst.cols, dst.rows)); - dst.copyTo(dstRoi); - + dst.copyTo(dstRoi); + + if (guiState.save) + { + + // �������� ������� ����� + time_t rawtime; + struct tm * timeinfo; + //char buffer[80]; + + time (&rawtime); + timeinfo = localtime(&rawtime); + + //strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo); + //std::string str(buffer); + // ������������� �������� ����������� + string str = std::to_string(rawtime); // = asctime(timeinfo); + string name_img = "image_sample_ekaterina_maljutina_" ; //str + + + // - ��������������� �������� ����������� + // � ������ �������� ������� + + imwrite(name_img +str + ".jpg" , display); + + guiState.save = false; + // ������� ������� ���������� imwrite(, display) + // �������� �������� guiState.saveState � false + } + drawButtons(display); namedWindow(caption); @@ -120,6 +148,11 @@ void onButtonsOnOffClick(int eventId, int x, int y, int flags, void *userData) elems->state = Application::OffFilter; return; } + if (onButtonClicked(elems->newButtom, x, y)) + { + elems->save = true; + return; + } } bool onButtonClicked(cv::Rect buttonPlace, int x, int y) diff --git a/sample_ekaterina_maljutina/application.hpp b/sample_ekaterina_maljutina/application.hpp index ec8909d..8272ed0 100644 --- a/sample_ekaterina_maljutina/application.hpp +++ b/sample_ekaterina_maljutina/application.hpp @@ -27,6 +27,7 @@ class Application cv::Rect onButtonPlace; cv::Rect offButtonPlace; cv::Rect newButtom; + bool save; }; int parseArguments(int argc, const char **argv, Parameters ¶ms); int getFrame(const std::string &fileName, cv::Mat& src); @@ -38,6 +39,7 @@ class Application Application() { guiState.state = OnFilter; + guiState.save = false; }; private: From 2746ac72678f51468766a6363bdd88db878b24ec Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 16:48:23 +0300 Subject: [PATCH 5/6] add other filters --- sample_ekaterina_maljutina/application.cpp | 73 ++++++++++++++++-- sample_ekaterina_maljutina/application.hpp | 11 +++ sample_ekaterina_maljutina/processing.cpp | 89 +++++++++++++++++++++- sample_ekaterina_maljutina/processing.hpp | 14 +++- 4 files changed, 177 insertions(+), 10 deletions(-) diff --git a/sample_ekaterina_maljutina/application.cpp b/sample_ekaterina_maljutina/application.cpp index eefa30c..27d5e48 100644 --- a/sample_ekaterina_maljutina/application.cpp +++ b/sample_ekaterina_maljutina/application.cpp @@ -28,7 +28,9 @@ int Application::getFrame(const std::string &fileName, Mat& src) int Application::processFrame(const Mat& src, Mat& dst) { - processor.processFrame(src, dst); + + + processor.processFrame(src, dst, guiState.filter); if (dst.empty()) { @@ -43,6 +45,11 @@ int Application::drawButtons(Mat &display) guiState.onButtonPlace = Rect(20, display.rows - 60, 120, 40); guiState.offButtonPlace = Rect(160, display.rows - 60, 120, 40); guiState.newButtom = Rect(300,display.rows - 60, 120,40); + guiState.FilterMEDIAN = Rect(450,display.rows - 60, 120,40); + + guiState.FilterCVT_CONVERT_GRAY = Rect(600,display.rows - 60, 120,40); + guiState.FilterPIXELIZED = Rect(750,display.rows - 60, 120,40); + guiState.FilterCANNY = Rect(900 ,display.rows - 60, 120,40); rectangle(display, guiState.newButtom, Scalar(128, 128, 128), CV_FILLED); @@ -50,6 +57,17 @@ int Application::drawButtons(Mat &display) Scalar(128, 128, 128), CV_FILLED); rectangle(display, guiState.offButtonPlace, Scalar(128, 128, 128), CV_FILLED); + rectangle(display, guiState.FilterMEDIAN, + Scalar(128, 128, 128), CV_FILLED); + + + rectangle(display, guiState.FilterCVT_CONVERT_GRAY, + Scalar(128, 128, 128), CV_FILLED); + rectangle(display, guiState.FilterPIXELIZED, + Scalar(128, 128, 128), CV_FILLED); + rectangle(display, guiState.FilterCANNY, + Scalar(128, 128, 128), CV_FILLED); + putText(display, "on", Point(guiState.onButtonPlace.x + guiState.onButtonPlace.width / 2 - 15, @@ -67,6 +85,27 @@ int Application::drawButtons(Mat &display) FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + putText(display, "median", + Point(guiState.FilterMEDIAN.x + guiState.FilterMEDIAN.width / 2 -50, + guiState.FilterMEDIAN.y + guiState.FilterMEDIAN.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + putText(display, "gray", + Point(guiState.FilterCVT_CONVERT_GRAY.x + guiState.FilterCVT_CONVERT_GRAY.width / 2-45, + guiState.FilterCVT_CONVERT_GRAY.y + guiState.FilterCVT_CONVERT_GRAY.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + putText(display, "pixel", + Point(guiState.FilterPIXELIZED.x + guiState.FilterPIXELIZED.width / 2 - 60, + guiState.FilterPIXELIZED.y + guiState.FilterPIXELIZED.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + putText(display, "canny", + Point(guiState.FilterPIXELIZED.x + guiState.FilterPIXELIZED.width / 2 + 85, + guiState.FilterPIXELIZED.y + guiState.FilterPIXELIZED.height / 2 + 10), + FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2); + + return 0; } @@ -99,16 +138,14 @@ int Application::showFrame(const std::string &caption, // �������� ������� ����� time_t rawtime; struct tm * timeinfo; - //char buffer[80]; time (&rawtime); timeinfo = localtime(&rawtime); - //strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo); - //std::string str(buffer); + // ������������� �������� ����������� - string str = std::to_string(rawtime); // = asctime(timeinfo); - string name_img = "image_sample_ekaterina_maljutina_" ; //str + + string str = std::to_string(rawtime); + string name_img = "image_sample_ekaterina_maljutina_" ; // - ��������������� �������� ����������� // � ������ �������� ������� @@ -153,6 +190,30 @@ void onButtonsOnOffClick(int eventId, int x, int y, int flags, void *userData) elems->save = true; return; } + if (onButtonClicked(elems->FilterMEDIAN, x, y)) + { + elems->state = Application::OnFilter; + elems->filter = Processing::MEDIAN; + return; + } + if (onButtonClicked(elems->FilterCVT_CONVERT_GRAY, x, y)) + { + elems->state = Application::OnFilter; + elems->filter = Processing::CVT_CONVERT_GRAY; + return; + } + if (onButtonClicked(elems->FilterPIXELIZED, x, y)) + { + elems->state = Application::OnFilter; + elems->filter = Processing::PIXELIZED; + return; + } + if (onButtonClicked(elems->FilterCANNY, x, y)) + { + elems->state = Application::OnFilter; + elems->filter = Processing::CANNY; + return; + } } bool onButtonClicked(cv::Rect buttonPlace, int x, int y) diff --git a/sample_ekaterina_maljutina/application.hpp b/sample_ekaterina_maljutina/application.hpp index 8272ed0..539b71a 100644 --- a/sample_ekaterina_maljutina/application.hpp +++ b/sample_ekaterina_maljutina/application.hpp @@ -27,6 +27,14 @@ class Application cv::Rect onButtonPlace; cv::Rect offButtonPlace; cv::Rect newButtom; + + cv::Rect FilterMEDIAN; + cv::Rect FilterCVT_CONVERT_GRAY; + cv::Rect FilterPIXELIZED; + cv::Rect FilterCANNY; + + Processing::FilterType filter; + bool save; }; int parseArguments(int argc, const char **argv, Parameters ¶ms); @@ -40,6 +48,9 @@ class Application { guiState.state = OnFilter; guiState.save = false; + + guiState.filter = Processing::MEDIAN; + }; private: diff --git a/sample_ekaterina_maljutina/processing.cpp b/sample_ekaterina_maljutina/processing.cpp index af0c220..1041d5e 100644 --- a/sample_ekaterina_maljutina/processing.cpp +++ b/sample_ekaterina_maljutina/processing.cpp @@ -10,7 +10,7 @@ int size = 0; int x = 0; int y = 0; -void Processing::processFrame(const cv::Mat& src, cv::Mat& dst) +void Processing::processFrame(const cv::Mat& src, cv::Mat& dst,FilterType filter) { size +=2; src.copyTo(dst); @@ -26,7 +26,6 @@ void Processing::processFrame(const cv::Mat& src, cv::Mat& dst) } else { - //size = size - 5; if (step != 0) step = 0; x=0; @@ -39,7 +38,91 @@ void Processing::processFrame(const cv::Mat& src, cv::Mat& dst) Mat roi = dst(region); const int kSize = 11; - medianBlur(roi, roi, kSize); + + switch(filter) + { + case MEDIAN: + { + medianBlur(roi, roi, kSize); + break; + } + case CVT_CONVERT_GRAY: + { + Mat tmp; + cvtColor( roi, tmp , CV_BGR2GRAY ); + + vector ch; + ch.push_back(tmp); + ch.push_back(tmp); + ch.push_back(tmp); + + merge(ch,roi); + + break; + } + case PIXELIZED: + { + + Mat dst = Mat::zeros(roi.size(), CV_8UC3); + Mat cir = Mat::zeros(roi.size(), CV_8UC1); + int bsize = 10; + + for (int i = 0; i < roi.rows; i += bsize) + { + for (int j = 0; j < roi.cols; j += bsize) + { + Rect rect = Rect(j, i, bsize, bsize) & + Rect(0, 0, roi.cols, roi.rows); + + Mat sub_dst(dst, rect); + sub_dst.setTo(mean(roi(rect))); + + circle( + cir, + Point(j+bsize/2, i+bsize/2), + bsize/2-1, + CV_RGB(255,255,255), -1, CV_AA); + } + } + + Mat cir_32f; + cir.convertTo(cir_32f, CV_32F); + normalize(cir_32f, cir_32f, 0, 1, NORM_MINMAX); + + Mat dst_32f; + dst.convertTo(dst_32f, CV_32F); + + std::vector channels; + split(dst_32f, channels); + for (int i = 0; i < channels.size(); ++i) + channels[i] = channels[i].mul(cir_32f); + + merge(channels, dst_32f); + dst_32f.convertTo(dst, CV_8U); + + dst.copyTo(roi); + + break; + } + case CANNY: + { + Mat tmp; + Canny(roi,tmp,50,150,3); + vector ch; + ch.push_back(tmp); + ch.push_back(tmp); + ch.push_back(tmp); + + merge(ch,roi); + + break; + } + default: + { + medianBlur(roi, roi, kSize); + break; + } + } rectangle(dst, region, Scalar(255, 0, 0)); diff --git a/sample_ekaterina_maljutina/processing.hpp b/sample_ekaterina_maljutina/processing.hpp index 65f29fc..96bc2e8 100644 --- a/sample_ekaterina_maljutina/processing.hpp +++ b/sample_ekaterina_maljutina/processing.hpp @@ -2,8 +2,20 @@ #include + + class Processing { public: - void processFrame(const cv::Mat& src, cv::Mat& dst); + enum FilterType + { + MEDIAN, + CVT_CONVERT_GRAY, + PIXELIZED, + CANNY + }; + + void processFrame(const cv::Mat& src, cv::Mat& dst,FilterType filter); + + }; From 1a0313ff3c354cba925e737f375e90651ff0a788 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Aug 2015 16:58:32 +0300 Subject: [PATCH 6/6] update_time --- sample_ekaterina_maljutina/application.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sample_ekaterina_maljutina/application.cpp b/sample_ekaterina_maljutina/application.cpp index 27d5e48..6fc2bd2 100644 --- a/sample_ekaterina_maljutina/application.cpp +++ b/sample_ekaterina_maljutina/application.cpp @@ -144,7 +144,9 @@ int Application::showFrame(const std::string &caption, // ������������� �������� ����������� - string str = std::to_string(rawtime); + std::ostringstream oss; + oss << rawtime; + string str = oss.str(); string name_img = "image_sample_ekaterina_maljutina_" ; // - ��������������� �������� �����������