Changes have been pushed for the repository "fawkesrobotics/fawkes".
Clone: https://github.com/fawkesrobotics/fawkes.git Gitweb: https://github.com/fawkesrobotics/fawkes The branch, neltester/cvmatadapter has been updated to 19f6b514d1ed9ea4c51a9e1cc3a8f8d1cbd2a73f (commit) from 7a0e6fd383194908bf19ab4b6bb6e381f5b667e5 (commit) https://github.com/fawkesrobotics/fawkes/tree/neltester/cvmatadapter Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - *Log* --------------------------------------------------------------- commit 19f6b514d1ed9ea4c51a9e1cc3a8f8d1cbd2a73f Author: Niklas Sebastian Eltester <[email protected]> AuthorDate: Wed May 19 15:54:57 2021 +0200 Commit: Niklas Sebastian Eltester <[email protected]> CommitDate: Wed May 19 15:56:59 2021 +0200 libs: remove OpenCV C Api https://github.com/fawkesrobotics/fawkes/commit/19f6b514d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *Summary* ----------------------------------------------------------- src/libs/fvclassifiers/faces.cpp | 46 +++++-------- src/libs/fvclassifiers/faces.h | 19 +++--- src/libs/fvclassifiers/qa/qa_facesclassifier.cpp | 19 +++--- src/libs/fvfilters/gauss.cpp | 5 +- src/libs/fvfilters/hipass.cpp | 5 +- src/libs/fvfilters/laplace.cpp | 5 +- src/libs/fvfilters/median.cpp | 5 +- src/libs/fvfilters/morphology/dilation.cpp | 5 +- src/libs/fvfilters/morphology/erosion.cpp | 5 +- src/libs/fvfilters/or.cpp | 5 +- src/libs/fvfilters/qa/qa_erode.cpp | 2 +- src/libs/fvfilters/qa/qa_gauss.cpp | 2 +- src/libs/fvfilters/qa/qa_sharpen.cpp | 2 +- src/libs/fvfilters/qa/qa_sobel.cpp | 2 +- src/libs/fvfilters/sharpen.cpp | 5 +- src/libs/fvfilters/sobel.cpp | 5 +- src/libs/fvfilters/threshold.cpp | 5 +- src/libs/fvutils/adapters/iplimage.cpp | 82 ------------------------ src/libs/fvutils/adapters/iplimage.h | 44 ------------- 19 files changed, 48 insertions(+), 220 deletions(-) delete mode 100644 src/libs/fvutils/adapters/iplimage.cpp delete mode 100644 src/libs/fvutils/adapters/iplimage.h - *Diffs* ------------------------------------------------------------- - *commit* 19f6b514d1ed9ea4c51a9e1cc3a8f8d1cbd2a73f - - - - - - - - - - Author: Niklas Sebastian Eltester <[email protected]> Date: Wed May 19 15:54:57 2021 +0200 Subject: libs: remove OpenCV C Api src/libs/fvclassifiers/faces.cpp | 46 +++++-------- src/libs/fvclassifiers/faces.h | 19 +++--- src/libs/fvclassifiers/qa/qa_facesclassifier.cpp | 19 +++--- src/libs/fvfilters/gauss.cpp | 5 +- src/libs/fvfilters/hipass.cpp | 5 +- src/libs/fvfilters/laplace.cpp | 5 +- src/libs/fvfilters/median.cpp | 5 +- src/libs/fvfilters/morphology/dilation.cpp | 5 +- src/libs/fvfilters/morphology/erosion.cpp | 5 +- src/libs/fvfilters/or.cpp | 5 +- src/libs/fvfilters/qa/qa_erode.cpp | 2 +- src/libs/fvfilters/qa/qa_gauss.cpp | 2 +- src/libs/fvfilters/qa/qa_sharpen.cpp | 2 +- src/libs/fvfilters/qa/qa_sobel.cpp | 2 +- src/libs/fvfilters/sharpen.cpp | 5 +- src/libs/fvfilters/sobel.cpp | 5 +- src/libs/fvfilters/threshold.cpp | 5 +- src/libs/fvutils/adapters/iplimage.cpp | 82 ------------------------ src/libs/fvutils/adapters/iplimage.h | 44 ------------- 19 files changed, 48 insertions(+), 220 deletions(-) _Diff for modified files_: diff --git a/src/libs/fvclassifiers/faces.cpp b/src/libs/fvclassifiers/faces.cpp index 2e7fd782c..880a4d974 100644 --- a/src/libs/fvclassifiers/faces.cpp +++ b/src/libs/fvclassifiers/faces.cpp @@ -24,10 +24,9 @@ #include <core/exception.h> #include <core/exceptions/software.h> #include <fvclassifiers/faces.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/color/conversions.h> -#include <opencv/cv.h> #include <cstddef> @@ -60,32 +59,25 @@ namespace firevision { FacesClassifier::FacesClassifier(const char * haarcascade_file, unsigned int pixel_width, unsigned int pixel_height, - IplImage * image, + cv::Mat & image, float haar_scale_factor, int min_neighbours, int flags) : Classifier("FacesClassifier") { - haar_scale_factor_ = haar_scale_factor; - min_neighbours_ = min_neighbours; - flags_ = flags; - - cascade_ = (CvHaarClassifierCascade *)cvLoad(haarcascade_file); - if (!cascade_) { + haar_scale_factor_ = haar_scale_factor; + min_neighbours_ = min_neighbours; + flags_ = flags; + std::string tmp_str = std::string(haarcascade_file); + if (!cascade_.load(tmp_str)) { throw fawkes::Exception("Could not load Haar casca via OpenCV"); } - storage_ = cvCreateMemStorage(0); - if (!storage_) { - cvReleaseHaarClassifierCascade(&cascade_); - throw fawkes::Exception("Could not initialize OpenCV memory"); - } - - if (image) { + if (!image.empty()) { image_ = image; own_image_ = false; } else { - image_ = cvCreateImage(cvSize(pixel_width, pixel_height), IPL_DEPTH_8U, 3); + image_ = cv::Mat(cv::Size(pixel_width, pixel_height), CV_8UC1, 3); own_image_ = true; } } @@ -93,11 +85,7 @@ FacesClassifier::FacesClassifier(const char * haarcascade_file, /** Destructor. */ FacesClassifier::~FacesClassifier() { - cvReleaseHaarClassifierCascade(&cascade_); - cvReleaseMemStorage(&storage_); - if (own_image_) { - cvReleaseImage(&image_); - } + image_.release(); } std::list<ROI> * @@ -106,16 +94,16 @@ FacesClassifier::classify() std::list<ROI> *rv = new std::list<ROI>(); if (own_image_) { - IplImageAdapter::convert_image_bgr(_src, image_); + CvMatAdapter::convert_image_bgr(_src, image_); } - CvSeq *face_seq = - cvHaarDetectObjects(image_, cascade_, storage_, haar_scale_factor_, min_neighbours_, flags_); + std::vector<cv::Rect> face_seq; + cascade_.detectMultiScale(image_, face_seq, haar_scale_factor_, min_neighbours_, flags_); - for (int i = 0; i < face_seq->total; ++i) { - CvAvgComp el = *(CvAvgComp *)cvGetSeqElem(face_seq, i); - ROI r(el.rect.x, el.rect.y, el.rect.width, el.rect.height, _width, _height); - r.num_hint_points = el.rect.width * el.rect.height; + for (int i = 0; i < int(face_seq.size()); ++i) { + cv::Rect el = face_seq[i]; + ROI r(el.x, el.y, el.width, el.height, _width, _height); + r.num_hint_points = el.width * el.height; rv->push_back(r); } diff --git a/src/libs/fvclassifiers/faces.h b/src/libs/fvclassifiers/faces.h index 6153cc8c8..ac21e48ad 100644 --- a/src/libs/fvclassifiers/faces.h +++ b/src/libs/fvclassifiers/faces.h @@ -26,9 +26,7 @@ #include <fvclassifiers/classifier.h> -struct CvHaarClassifierCascade; -struct CvMemStorage; -typedef struct _IplImage IplImage; +#include <opencv2/objdetect.hpp> namespace firevision { @@ -38,7 +36,7 @@ public: FacesClassifier(const char * haarcascade_file, unsigned int pixel_width, unsigned int pixel_height, - IplImage * image = 0, + cv::Mat & image, float haar_scale_factor = 1.1, int min_neighbours = 3, int flags = 0); @@ -48,13 +46,12 @@ public: virtual std::list<ROI> *classify(); private: - CvHaarClassifierCascade *cascade_; - CvMemStorage * storage_; - IplImage * image_; - float haar_scale_factor_; - int min_neighbours_; - int flags_; - bool own_image_; + cv::CascadeClassifier cascade_; + cv::Mat image_; + float haar_scale_factor_; + int min_neighbours_; + int flags_; + bool own_image_; }; } // end namespace firevision diff --git a/src/libs/fvclassifiers/qa/qa_facesclassifier.cpp b/src/libs/fvclassifiers/qa/qa_facesclassifier.cpp index 213b2ddc9..55b788883 100644 --- a/src/libs/fvclassifiers/qa/qa_facesclassifier.cpp +++ b/src/libs/fvclassifiers/qa/qa_facesclassifier.cpp @@ -27,18 +27,18 @@ #include <cams/factory.h> #include <classifiers/faces.h> #include <filters/roidraw.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/draw/drawer.h> #include <fvutils/readers/jpeg.h> #include <fvwidgets/image_display.h> -#include <opencv/cv.h> #include <utils/system/argparser.h> #include <utils/time/tracker.h> #include <SDL.h> #include <cstdio> #include <cstdlib> +#include <opencv2/opencv.hpp> using namespace fawkes; @@ -115,11 +115,10 @@ main(int argc, char **argv) unsigned int ttc_recognition = tt->add_class("Face recognition"); unsigned int loop_count = 0; - IplImage *image = - cvCreateImage(cvSize(camera->pixel_width(), camera->pixel_height()), IPL_DEPTH_8U, 3); + cv::Mat image = cv::Mat(cv::Size(camera->pixel_width(), camera->pixel_height()), CV_8UC1, 3); - IplImage *scaled_image = - cvCreateImage(cvSize(camera->pixel_width() / 2, camera->pixel_height() / 2), IPL_DEPTH_8U, 3); + cv::Mat scaled_image = + cv::Mat(cv::Size(camera->pixel_width() / 2, camera->pixel_height() / 2), CV_8UC1, 3); FacesClassifier *classifier = new FacesClassifier(cascade_file, camera->pixel_width(), @@ -155,8 +154,8 @@ main(int argc, char **argv) camera->capture(); if (camera->buffer() != NULL) { - IplImageAdapter::convert_image_bgr(camera->buffer(), image); - cvResize(image, scaled_image, CV_INTER_LINEAR); + CvMatAdapter::convert_image_bgr(camera->buffer(), image); + image.resize(scaled_image.rows, cv::INTER_LINEAR); memcpy(display_buffer, camera->buffer(), camera->buffer_size()); tt->ping_start(ttc_recognition); @@ -204,8 +203,8 @@ main(int argc, char **argv) delete display; delete drawer; free(display_buffer); - cvReleaseImage(&image); - cvReleaseImage(&scaled_image); + image.release(); + scaled_image.release(); delete tt; } diff --git a/src/libs/fvfilters/gauss.cpp b/src/libs/fvfilters/gauss.cpp index 503e6326f..202df6a5d 100644 --- a/src/libs/fvfilters/gauss.cpp +++ b/src/libs/fvfilters/gauss.cpp @@ -27,10 +27,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/hipass.cpp b/src/libs/fvfilters/hipass.cpp index 63f8153c1..199aa5a06 100644 --- a/src/libs/fvfilters/hipass.cpp +++ b/src/libs/fvfilters/hipass.cpp @@ -26,10 +26,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/laplace.cpp b/src/libs/fvfilters/laplace.cpp index 26f9e4ed8..5a1dc5fb4 100644 --- a/src/libs/fvfilters/laplace.cpp +++ b/src/libs/fvfilters/laplace.cpp @@ -29,10 +29,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/median.cpp b/src/libs/fvfilters/median.cpp index 77fffa25b..aeca925c1 100644 --- a/src/libs/fvfilters/median.cpp +++ b/src/libs/fvfilters/median.cpp @@ -26,10 +26,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/morphology/dilation.cpp b/src/libs/fvfilters/morphology/dilation.cpp index aec14ed43..57ba43d2e 100644 --- a/src/libs/fvfilters/morphology/dilation.cpp +++ b/src/libs/fvfilters/morphology/dilation.cpp @@ -30,10 +30,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/morphology/erosion.cpp b/src/libs/fvfilters/morphology/erosion.cpp index d4002b1a1..7c071c2f6 100644 --- a/src/libs/fvfilters/morphology/erosion.cpp +++ b/src/libs/fvfilters/morphology/erosion.cpp @@ -29,10 +29,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/or.cpp b/src/libs/fvfilters/or.cpp index 8cd8fb52a..74ef7ced9 100644 --- a/src/libs/fvfilters/or.cpp +++ b/src/libs/fvfilters/or.cpp @@ -28,10 +28,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/qa/qa_erode.cpp b/src/libs/fvfilters/qa/qa_erode.cpp index a66930ce8..3ec521c1a 100644 --- a/src/libs/fvfilters/qa/qa_erode.cpp +++ b/src/libs/fvfilters/qa/qa_erode.cpp @@ -23,7 +23,7 @@ /// @cond QA #include <fvfilters/morphology/erosion.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/draw/drawer.h> #include <fvutils/readers/jpeg.h> diff --git a/src/libs/fvfilters/qa/qa_gauss.cpp b/src/libs/fvfilters/qa/qa_gauss.cpp index d6b7be4b3..ebec2193f 100644 --- a/src/libs/fvfilters/qa/qa_gauss.cpp +++ b/src/libs/fvfilters/qa/qa_gauss.cpp @@ -23,7 +23,7 @@ /// @cond QA #include <fvfilters/gauss.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/draw/drawer.h> #include <fvutils/readers/jpeg.h> diff --git a/src/libs/fvfilters/qa/qa_sharpen.cpp b/src/libs/fvfilters/qa/qa_sharpen.cpp index 9f9c5751a..4ad1e8d18 100644 --- a/src/libs/fvfilters/qa/qa_sharpen.cpp +++ b/src/libs/fvfilters/qa/qa_sharpen.cpp @@ -23,7 +23,7 @@ /// @cond QA #include <fvfilters/sharpen.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/draw/drawer.h> #include <fvutils/readers/jpeg.h> diff --git a/src/libs/fvfilters/qa/qa_sobel.cpp b/src/libs/fvfilters/qa/qa_sobel.cpp index 5ccb62097..92baa87b9 100644 --- a/src/libs/fvfilters/qa/qa_sobel.cpp +++ b/src/libs/fvfilters/qa/qa_sobel.cpp @@ -23,7 +23,7 @@ /// @cond QA #include <fvfilters/sobel.h> -#include <fvutils/adapters/iplimage.h> +#include <fvutils/adapters/cvmatadapter.h> #include <fvutils/color/colorspaces.h> #include <fvutils/draw/drawer.h> #include <fvutils/readers/jpeg.h> diff --git a/src/libs/fvfilters/sharpen.cpp b/src/libs/fvfilters/sharpen.cpp index 92d191a03..c77bee671 100644 --- a/src/libs/fvfilters/sharpen.cpp +++ b/src/libs/fvfilters/sharpen.cpp @@ -26,10 +26,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/sobel.cpp b/src/libs/fvfilters/sobel.cpp index 715910035..141615a7f 100644 --- a/src/libs/fvfilters/sobel.cpp +++ b/src/libs/fvfilters/sobel.cpp @@ -26,10 +26,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif diff --git a/src/libs/fvfilters/threshold.cpp b/src/libs/fvfilters/threshold.cpp index 3735ef3ca..a06136bc9 100644 --- a/src/libs/fvfilters/threshold.cpp +++ b/src/libs/fvfilters/threshold.cpp @@ -31,10 +31,7 @@ #ifdef HAVE_IPP # include <ippi.h> #elif defined(HAVE_OPENCV) -# if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) -# include <opencv/cv.h> -# endif -# include <opencv/cv.hpp> +# include <opencv2/opencv.hpp> #else # error "Neither IPP nor OpenCV available" #endif _______________________________________________ fawkes-commits mailing list [email protected] https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits
