Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 将Mat对象用作IplImage对象以及将Mat对象用作IplImage对象的最佳方式是什么?_Opencv_Iplimage - Fatal编程技术网

Opencv 将Mat对象用作IplImage对象以及将Mat对象用作IplImage对象的最佳方式是什么?

Opencv 将Mat对象用作IplImage对象以及将Mat对象用作IplImage对象的最佳方式是什么?,opencv,iplimage,Opencv,Iplimage,在OpenCV中使用Mat和IplImage对象确实让我感到困惑。我在这里读了很多问题和答案,但这两种类型的问题仍然困扰着我 很多时候,我需要将它们相互转换,这就是我在转换中迷失的原因。我所知道和使用的函数有时采用IplImage对象,有时采用Mat对象 例如,“cvThreshold”方法采用IplImages,“threshold”方法采用Mat对象,这里没有问题,但“cvSmooth”方法仅适用于IplImages,我找不到Mat对象的专用方法(有吗?),于是我不情愿地将Mat转换为Ipl

在OpenCV中使用Mat和IplImage对象确实让我感到困惑。我在这里读了很多问题和答案,但这两种类型的问题仍然困扰着我

很多时候,我需要将它们相互转换,这就是我在转换中迷失的原因。我所知道和使用的函数有时采用IplImage对象,有时采用Mat对象

例如,“cvThreshold”方法采用IplImages,“threshold”方法采用Mat对象,这里没有问题,但“cvSmooth”方法仅适用于IplImages,我找不到Mat对象的专用方法(有吗?),于是我不情愿地将Mat转换为IplImage,然后在“cvSmooth”中使用,然后再次转换为Mat。此时,如何将Mat对象与cvSmooth一起使用?我相信这不是处理这个问题的正常方法,还有更好的方法。也许我在理解这些类型时遗漏了一些东西


你能帮我解决这个问题吗?

呼叫
cvSmooth

void callCvSmooth(cv::Mat srcmtx, cv::Mat dstmtx, int smooth_type,
      int param1, int param2, double param3, double param4 )
{
   IplImage src = srcmtx;
   IplImage dst = dstmtx;
   cvSmooth( &src, &dst, smooth_type, param1, param2, param3, param4 );
}
<>但是如果你查看 CVSLASIO/COMG>实现,你会很容易找到C++类似物:

CV_IMPL void
cvSmooth( const void* srcarr, void* dstarr, int smooth_type,
          int param1, int param2, double param3, double param4 )
{
    cv::Mat src = cv::cvarrToMat(srcarr), dst0 = cv::cvarrToMat(dstarr), dst = dst0;

    CV_Assert( dst.size() == src.size() &&
        (smooth_type == CV_BLUR_NO_SCALE || dst.type() == src.type()) );

    if( param2 <= 0 )
        param2 = param1;

    if( smooth_type == CV_BLUR || smooth_type == CV_BLUR_NO_SCALE )
        cv::boxFilter( src, dst, dst.depth(), cv::Size(param1, param2), cv::Point(-1,-1),
            smooth_type == CV_BLUR, cv::BORDER_REPLICATE );
    else if( smooth_type == CV_GAUSSIAN )
        cv::GaussianBlur( src, dst, cv::Size(param1, param2), param3, param4, cv::BORDER_REPLICATE );
    else if( smooth_type == CV_MEDIAN )
        cv::medianBlur( src, dst, param1 );
    else
        cv::bilateralFilter( src, dst, param1, param3, param4, cv::BORDER_REPLICATE );

    if( dst.data != dst0.data )
        CV_Error( CV_StsUnmatchedFormats, "The destination image does not have the proper type" );
}
CV\u IMPL void
cvSmooth(常数void*srcarr,void*dstarr,整型平滑),
int-param1,int-param2,double-param3,double-param4)
{
cv::Mat src=cv::cvarrToMat(srcarr),dst0=cv::cvarrToMat(dstarr),dst=dst0;
CV_断言(dst.size()==src.size()&&
(smooth_type==CV_BLUR_NO_SCALE | | dst.type()==src.type());

if(param2调用
cvSmooth

void callCvSmooth(cv::Mat srcmtx, cv::Mat dstmtx, int smooth_type,
      int param1, int param2, double param3, double param4 )
{
   IplImage src = srcmtx;
   IplImage dst = dstmtx;
   cvSmooth( &src, &dst, smooth_type, param1, param2, param3, param4 );
}
<>但是如果你查看 CVSLASIO/COMG>实现,你会很容易找到C++类似物:

CV_IMPL void
cvSmooth( const void* srcarr, void* dstarr, int smooth_type,
          int param1, int param2, double param3, double param4 )
{
    cv::Mat src = cv::cvarrToMat(srcarr), dst0 = cv::cvarrToMat(dstarr), dst = dst0;

    CV_Assert( dst.size() == src.size() &&
        (smooth_type == CV_BLUR_NO_SCALE || dst.type() == src.type()) );

    if( param2 <= 0 )
        param2 = param1;

    if( smooth_type == CV_BLUR || smooth_type == CV_BLUR_NO_SCALE )
        cv::boxFilter( src, dst, dst.depth(), cv::Size(param1, param2), cv::Point(-1,-1),
            smooth_type == CV_BLUR, cv::BORDER_REPLICATE );
    else if( smooth_type == CV_GAUSSIAN )
        cv::GaussianBlur( src, dst, cv::Size(param1, param2), param3, param4, cv::BORDER_REPLICATE );
    else if( smooth_type == CV_MEDIAN )
        cv::medianBlur( src, dst, param1 );
    else
        cv::bilateralFilter( src, dst, param1, param3, param4, cv::BORDER_REPLICATE );

    if( dst.data != dst0.data )
        CV_Error( CV_StsUnmatchedFormats, "The destination image does not have the proper type" );
}
CV\u IMPL void
cvSmooth(常数void*srcarr,void*dstarr,整型平滑),
int-param1,int-param2,double-param3,double-param4)
{
cv::Mat src=cv::cvarrToMat(srcarr),dst0=cv::cvarrToMat(dstarr),dst=dst0;
CV_断言(dst.size()==src.size()&&
(smooth_type==CV_BLUR_NO_SCALE | | dst.type()==src.type());

如果(PARAM2

粘贴两个代码中的一个。<代码> CV::Mat < /Cord>是C++的方式。该类具有引用计数机制,并处理所有垃圾收集过程。每个<代码> CV*<代码>函数在C++中都有对应的<代码>:::*> /COD>版本(主要是IMO)。



对于cvSmooth等价物,您可以使用
cv::GaussianBlur(…)
cv::medianBlur(…)
cv::blur(…)
。有许多变体。最好还是一如既往地查阅文档。
cvSmooth(…) >只是分成了各种函数。

中的一个。<代码> CV::Mat < /Cord>是C++的方式。该类具有引用计数机制,并处理所有垃圾收集过程。每个<代码> CV*<代码>函数在C++中都有对应的<代码>:::*> /COD>版本(主要是IMO)。


对于cvSmooth等价物,您可以使用
cv::GaussianBlur(…)
cv::medianBlur(…)
cv::blur(…)
。有许多变体。最好还是一如既往地查阅文档。
cvSmooth(…)
只是被拆分为不同的函数