我想创建一个 C++ 类,它只包含我无论如何都可以使用的静态函数。我已经创建了一个.h
带有声明的.cpp
文件和一个带有定义的文件。但是,当我在我的代码中使用它时,我会收到一些奇怪的错误消息,我不知道如何解决。
这是我的Utils.h
文件的内容:
#include <iostream>
#include <fstream>
#include <sstream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
#include <vector>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
class Utils
{
public:
static void drawPoint(Mat &img, int R, int G, int B, int x, int y);
};
这是我的Utils.cpp
文件的内容:
#include "Utils.h"
void Utils::drawPoint(Mat &img, int R, int G, int B, int x, int y)
{
img.at<Vec3b>(x, y)[0] = R;
img.at<Vec3b>(x, y)[1] = G;
img.at<Vec3b>(x, y)[2] = B;
}
这就是我想在我的main
函数中使用它的方式:
#include <iostream>
#include <fstream>
#include <sstream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
#include <vector>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include "CThinPlateSpline.h"
#include "Utils.h"
int main()
{
Mat img = imread("D:\\image.png");
if (img.empty())
{
cout << "Cannot load image!" << endl;
system("PAUSE");
return -1;
}
Utils.drawPoint(img, 0, 255, 0, 20, 20);
imshow("Original Image", img);
waitKey(0);
return 0;
}
这是我收到的错误。
有人可以指出我做错了什么吗?我错过了什么?