4 Star 2 Fork 6

Gitee 极速下载 / qtopencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/dbzhang800/QtOpenCV
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cvmatandqimage.h 3.42 KB
一键复制 编辑 原始数据 按行查看 历史
/****************************************************************************
** Copyright (c) 2012-2015 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#ifndef CVMATANDQIMAGE_H
#define CVMATANDQIMAGE_H
#include <QtGui/qimage.h>
#include <opencv2/core/core.hpp>
namespace QtOcv {
enum MatColorOrder {
MCO_BGR,
MCO_RGB,
MCO_BGRA = MCO_BGR,
MCO_RGBA = MCO_RGB,
MCO_ARGB
};
/* Convert QImage to/from cv::Mat
*
* - cv::Mat
* - Supported channels
* - 1 channel
* - 3 channels (B G R), (R G B)
* - 4 channels (B G R A), (R G B A), (A R G B)
* - Supported depth
* - CV_8U [0, 255]
* - CV_16U [0, 65535]
* - CV_32F [0, 1.0]
*
* - QImage
* - All of the formats of QImage are supported.
*/
cv::Mat image2Mat(const QImage &img, int requiredMatType = CV_8UC(0), MatColorOrder requiredOrder=MCO_BGR);
QImage mat2Image(const cv::Mat &mat, MatColorOrder order=MCO_BGR, QImage::Format formatHint = QImage::Format_Invalid);
/* Convert QImage to/from cv::Mat without data copy
*
* - Supported QImage formats and cv::Mat types are:
* - QImage::Format_Indexed8 <==> CV_8UC1
* - QImage::Format_Alpha8 <==> CV_8UC1
* - QImage::Format_Grayscale8 <==> CV_8UC1
* - QImage::Format_RGB888 <==> CV_8UC3 (R G B)
* - QImage::Format_RGB32 <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_ARGB32 <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_ARGB32_Premultiplied <==> CV_8UC4 (A R G B or B G R A)
* - QImage::Format_RGBX8888 <==> CV_8UC4 (R G B A)
* - QImage::Format_RGBA8888 <==> CV_8UC4 (R G B A)
* - QImage::Format_RGBA8888_Premultiplied <==> CV_8UC4 (R G B A)
*
* - For QImage::Format_RGB32 ,QImage::Format_ARGB32
* and QImage::Format_ARGB32_Premultiplied, the
* color channel order of cv::Mat will be (B G R A) in little
* endian system or (A R G B) in big endian system.
*
* - User must make sure that the color channels order is the same as
* the color channels order requried by QImage.
*/
cv::Mat image2Mat_shared(const QImage &img, MatColorOrder *order=0);
QImage mat2Image_shared(const cv::Mat &mat, QImage::Format formatHint = QImage::Format_Invalid);
} //namespace QtOcv
#endif // CVMATANDQIMAGE_H
C/C++
1
https://gitee.com/mirrors/qtopencv.git
git@gitee.com:mirrors/qtopencv.git
mirrors
qtopencv
qtopencv
master

搜索帮助