QianMo / OpenCV3-Intro-Book-Src

:blue_book:《OpenCV3编程入门》书本配套源码 |《Introduction to OpenCV3 Programming》Book Source Code
1.82k stars 939 forks source link

OpenCV3.4.2下使用VS2017运行3.1.9图像混合程序崩溃报错? #12

Closed erikaemma closed 4 years ago

erikaemma commented 4 years ago

报错信息:

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
erikaemma commented 4 years ago

已解决:imread函数删除第二个参数flags值199后正常