何があっても使える静的関数だけを組み込んだ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;
}
そして、ここに私が受け取っているエラーがあります。
誰かが私が間違っていることを指摘できますか? 私は何が欠けていますか?