简体   繁体   English

为opencv调整大小功能设置src和dst img相同

[英]Set src and dst img the same for opencv resize function

I am trying to resize an cv::Mat img with OpenCV. 我正在尝试使用OpenCV调整cv::Mat img大小。 When I am using function cv::resize() , I set src and dst img to be the same as input img like cv::resize(img, img) . 当我使用函数cv::resize() ,我将srcdst img设置为与输入img相同,例如cv::resize(img, img) And when I test the program, so far it works correctly. 而当我测试该程序时,到目前为止它可以正常工作。 But I am a bit confused how the resize function is implemented cause when I read the documentation it said we need to pre-allocate the dst img before resizing. 但是,当我阅读文档中所说的调整大小功能的实现方式时,我有点困惑,因为它说我们需要在调整大小之前预先分配dst img。

Can anyone explain it to me? 谁能向我解释? Thanks. 谢谢。

As pointed out by @Micka, you don't need to pre-allocate dst . 正如@Micka指出的那样,您无需预先分配dst But you can, if you want to, with different calling conventions. 但是,如果需要,可以使用不同的调用约定。

From OpenCV documentation : OpenCV文档中

  • The function resize resizes the image src down to or up to the specified size. 函数resize大小可将图像src调整为指定大小或最大。 Note that the initial dst type or size are not taken into account. 请注意,未考虑初始dst类型或大小。 Instead, the size and type are derived from the src , dsize , fx , and fy . 而是从srcdsizefxfy派生大小和类型。 If you want to resize src so that it fits the pre-created dst , you may call the function as follows: 如果要调整src大小以使其适合预先创建的dst ,则可以按以下方式调用该函数:

     // explicitly specify dsize=dst.size(); fx and fy will be computed from that. resize(src, dst, dst.size(), 0, 0, interpolation); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 断言失败<dst.data != src.data >在未知函数 ../../ocv/opencv/modules/imgproc/src/imgwarp.cpp - Assertion failed <dst.data != src.data > in unknown function ../../ocv/opencv/modules/imgproc/src/imgwarp.cpp OpenCV在调整大小功能时崩溃 - OpenCV crashing at resize function OpenCV错误:cvInRangeS中的断言失败(src1.size == dst.size &amp;&amp; dst.type()== CV_8U) - OpenCV Error: Assertion failed (src1.size == dst.size && dst.type() == CV_8U) in cvInRangeS opencv调整大小函数执行时间慢 - Slow opencv resize function execution time OpenCV:断言失败“dst.data == widget-&gt;original_image-&gt;data.ptr in function &#39;cvImageWidgetSetImage&#39;” - OpenCV: Assertion failed " dst.data == widget->original_image->data.ptr in function 'cvImageWidgetSetImage' " 调试::gdb::什么是src2dst? - debugging:: gdb :: what is src2dst? opencv - cvCvtColor中的断言失败(dst.data == dst0.data) - opencv - Assertion failed (dst.data == dst0.data) in cvCvtColor 使 OpenCV 调整大小与 Matlab/Octave imresize 相同 - Make OpenCV resize do the same as Matlab/Octave imresize OpenCV C ++调整大小功能:新宽度应乘以3 - Opencv c++ resize function: new Width should be multiplied by 3 OpenCV CUDA 函数缺失 - 命名空间“cv:cuda”没有成员“resize” - OpenCV CUDA Function Missing - namespace "cv:cuda" has no member "resize"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM