From 16814f6c6f4836eecc8e7409e081d0429ecd5c84 Mon Sep 17 00:00:00 2001 From: masayume <1936714878@qq.com> Date: Thu, 16 Dec 2021 17:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8B=86=E5=88=86=E7=AE=97?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opencv/include/opencv2/core/async.hpp | 105 ++++++++++++++++++ huagao/ImageProcess/ImageApplySplit.cpp | 36 ++++++ huagao/ImageProcess/ImageApplySplit.h | 28 +++++ 3 files changed, 169 insertions(+) create mode 100644 3rdparty/opencv/include/opencv2/core/async.hpp create mode 100644 huagao/ImageProcess/ImageApplySplit.cpp create mode 100644 huagao/ImageProcess/ImageApplySplit.h diff --git a/3rdparty/opencv/include/opencv2/core/async.hpp b/3rdparty/opencv/include/opencv2/core/async.hpp new file mode 100644 index 00000000..54560c7d --- /dev/null +++ b/3rdparty/opencv/include/opencv2/core/async.hpp @@ -0,0 +1,105 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#ifndef OPENCV_CORE_ASYNC_HPP +#define OPENCV_CORE_ASYNC_HPP + +#include + +#ifdef CV_CXX11 +//#include +#include +#endif + +namespace cv { + +/** @addtogroup core_async + +@{ +*/ + + +/** @brief Returns result of asynchronous operations + +Object has attached asynchronous state. +Assignment operator doesn't clone asynchronous state (it is shared between all instances). + +Result can be fetched via get() method only once. + +*/ +class CV_EXPORTS_W AsyncArray +{ +public: + ~AsyncArray() CV_NOEXCEPT; + CV_WRAP AsyncArray() CV_NOEXCEPT; + AsyncArray(const AsyncArray& o) CV_NOEXCEPT; + AsyncArray& operator=(const AsyncArray& o) CV_NOEXCEPT; + CV_WRAP void release() CV_NOEXCEPT; + + /** Fetch the result. + @param[out] dst destination array + + Waits for result until container has valid result. + Throws exception if exception was stored as a result. + + Throws exception on invalid container state. + + @note Result or stored exception can be fetched only once. + */ + CV_WRAP void get(OutputArray dst) const; + + /** Retrieving the result with timeout + @param[out] dst destination array + @param[in] timeoutNs timeout in nanoseconds, -1 for infinite wait + + @returns true if result is ready, false if the timeout has expired + + @note Result or stored exception can be fetched only once. + */ + bool get(OutputArray dst, int64 timeoutNs) const; + + CV_WRAP inline + bool get(OutputArray dst, double timeoutNs) const { return get(dst, (int64)timeoutNs); } + + bool wait_for(int64 timeoutNs) const; + + CV_WRAP inline + bool wait_for(double timeoutNs) const { return wait_for((int64)timeoutNs); } + + CV_WRAP bool valid() const CV_NOEXCEPT; + +#ifdef CV_CXX11 + inline AsyncArray(AsyncArray&& o) { p = o.p; o.p = NULL; } + inline AsyncArray& operator=(AsyncArray&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; } + + template + inline bool get(OutputArray dst, const std::chrono::duration<_Rep, _Period>& timeout) + { + return get(dst, (int64)(std::chrono::nanoseconds(timeout).count())); + } + + template + inline bool wait_for(const std::chrono::duration<_Rep, _Period>& timeout) + { + return wait_for((int64)(std::chrono::nanoseconds(timeout).count())); + } + +#if 0 + std::future getFutureMat() const; + std::future getFutureUMat() const; +#endif +#endif + + + // PImpl + struct Impl; friend struct Impl; + inline void* _getImpl() const CV_NOEXCEPT { return p; } +protected: + Impl* p; +}; + + +//! @} +} // namespace +#endif // OPENCV_CORE_ASYNC_HPP diff --git a/huagao/ImageProcess/ImageApplySplit.cpp b/huagao/ImageProcess/ImageApplySplit.cpp new file mode 100644 index 00000000..569471a1 --- /dev/null +++ b/huagao/ImageProcess/ImageApplySplit.cpp @@ -0,0 +1,36 @@ +#include "ImageApplySplit.h" +#include + +CImageApplySplit::CImageApplySplit() +{ +} + +CImageApplySplit::~CImageApplySplit(void) +{ +} + + +std::vector CImageApplySplit::apply(cv::Mat& pDib) +{ + if (pDib.empty()) + return std::vector(); + std::vector retMats; + int heigth = pDib.rows; + int width = pDib.cols; + if (heigth > width) + { + cv::Mat matF = pDib(cv::Rect(0, 0, width, (int)(0.5 * heigth))); + cv::Mat matB = pDib(cv::Rect(0, (int)(0.5 * heigth), width, (int)(0.5 * heigth))); + retMats.push_back(matF); + retMats.push_back(matB); + } + else + { + cv::Mat matF = pDib(cv::Rect(0, 0, (int)(width*0.5), heigth)); + cv::Mat matB = pDib(cv::Rect((int)(width*0.5), 0, (int)(width * 0.5), heigth)); + retMats.push_back(matF); + retMats.push_back(matB); + } + return retMats; +} + diff --git a/huagao/ImageProcess/ImageApplySplit.h b/huagao/ImageProcess/ImageApplySplit.h new file mode 100644 index 00000000..1607adb8 --- /dev/null +++ b/huagao/ImageProcess/ImageApplySplit.h @@ -0,0 +1,28 @@ +/* + * ==================================================== + + * 功能:图像拆分 + * 作者:刘丁维 + * 生成时间:2020/4/21 + * 最近修改时间:2020/4/21 + * 版本号:v1.0 + + * ==================================================== + */ + +#ifndef IMAGE_APPLY_SPLIT_H +#define IMAGE_APPLY_SPLIT_H +#include +#include + +class CImageApplySplit +{ +public: + CImageApplySplit(); + + ~CImageApplySplit(void); + + std::vector apply(cv::Mat& pDib); +}; + +#endif // !IMAGE_APPLY_SPLIT_H