我试图用pyrDown()
来缩小所需的图像。为此我使用了一个函数调用void downscale(Mat *p,int *scale)
。我发送了ref到图像的函数。因此,在函数完成了下采样我的原始图像的图像会发生改变,因为我发送了指针。图像在函数调用中得到缩放。但令我惊讶的是主程序中的图像没有变化。我不明白我出错的地方。出我的错误? 这里是我的代码通过函数调用使用pyrdown
#include <opencv2/core/core.hpp>
#include<opencv2/opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<stdio.h>
#include<conio.h>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/objdetect/objdetect.hpp>
#include<opencv2/features2d/features2d.hpp>
#include<opencv2/nonfree/nonfree.hpp>
using namespace std;
using namespace cv;
void downscale(Mat *p,int scale)
{
\t int s=scale;
\t Mat ref=*p;
\t
\t imshow("received",ref);
\t vector<int> param;
\t param.push_back(CV_IMWRITE_PNG_COMPRESSION) ;
\t param.push_back(9);
\t while(s){
\t pyrDown(ref,ref,Size(),4);
\t s--;
\t }
\t imshow("sending",ref);
}
int main()
{
\t Mat ref,in,ref_out,in_out;
\t int s=2;
\t ref=imread("C:\\Users\\vamsidhar muthireddy\\Pictures\\Camera Roll\\WIN_20151003_18_47_55_Pro.jpg");
\t cvtColor(ref,ref,CV_BGR2GRAY);
\t
\t imshow("original ref",ref);
\t downscale(&ref,s);
\t imshow("scaled ref",ref);
waitKey();
\t return 0;
}
使用通过引用传递...为什么你需要一个指针 – basav