qianmo / opencv3-intro-book-src Goto Github PK
View Code? Open in Web Editor NEW:blue_book:《OpenCV3编程入门》书本配套源码 |《Introduction to OpenCV3 Programming》Book Source Code
:blue_book:《OpenCV3编程入门》书本配套源码 |《Introduction to OpenCV3 Programming》Book Source Code
OpenCV3.4下:
OpenCV3-examples的第16个示例程序第31行Mat image= imread("dota.jpg",199);
会导致44行imageROI构造出错。
具体出错原因分析如下:
在文件/opencv-3.4/modules/imgcodecs/include/opencv2/imgcodecs.hpp
的第64行起,找到如下定义:
//! Imread flags
enum ImreadModes {
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
IMREAD_LOAD_GDAL = 8, //!< If set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2 = 16, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2 = 17, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4 = 32, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
};
也就是说imread()函数的flag值为199会使图片变小,导致44行imageROI构造出错。
报错信息:
OpenCV(3.4.2) Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat, file c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp, line 465
catch1: OpenCV(3.4.2) c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\matrix.cpp:465: error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'cv::Mat::Mat'
OpenCV(3.4.2) Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in cv::arithm_op, file c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\arithm.cpp, line 659
catch2: OpenCV(3.4.2) c:\build\3_4_winpack-build-win64-vc15\opencv\modules\core\src\arithm.cpp:659: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'
try-catch捕获位置:
imageROI = image(Rect(800, 350, logo.cols, logo.rows)); //catch1
addWeighted(imageROI, 0.5, logo, 0.3, 0., imageROI); //catch2
opencv3.0 支持alpha 合成图片么?
我尝试合成图片 .png 效果很差
Canny函数是不是自带高斯滤波,在使用之前不用在滤波吧
因为我看作者把本书分为四大部分,目前第四部分是 深入feature2d组件;那有没有calib3d等其它组件继续扩充本书?
非常感谢浅墨烈士
Hi,
我在运行“示例程序73 创建包围轮廓的矩形边界”的时候,遇到了如下的程序编译错误。所以,请您帮忙看看这些编译问题是否是缺少了什么头文件没有include,还是其他的什么原因?
1、undefined reference to cv::theRNG()' 2、Multiple markers at this line - undefined reference to
cv::minAreaRect(cv::InputArray const&)'
- undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)' 3、undefined reference to
cv::RotatedRect::points(cv::Point*) const'
4、undefined reference to cv::Mat::operator=(cv::Scalar_<double> const&)' 5、undefined reference to
cv::circle(cv::Mat&, cv::Point_, int, cv::Scalar_ const&, int, int, int)'
6、undefined reference to cv::line(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' 7、Multiple markers at this line - undefined reference to
cv::imshow(std::string const&, cv::_InputArray
const&)'
8、undefined reference to `cv::waitKey(int)'
我已经在程序中include了如下这些头文件:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
刚看完您的《OpenCV3编程入门》,讲解浅显易懂还附代码,太适合学生党了,希望世界上像您这样乐于分享知识的人越来越多。
感激不尽🙏
为啥在vs2010出现乱码呢
🕯️🕯️🕯️
第62行:
Mat dstImage(size * scale, size, CV_8U, Scalar(0));
我感觉有错误,应该是
Mat dstImage(size, size * scale, CV_8U, Scalar(0));
scale表示的是x方向的扩大倍数,而Mat构造函数第一个参数是rows,是y方向上的扩大倍数。今天晚上看着书调试时,将scale置为2,发现了这个问题。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.