我是C ++编程的老师,但我通常用Java开发。
我在计算机视觉课程中,我们在C ++中使用opencv。我们还使用Visual Studio v2012。
我尝试使用类和Test cpp文件进行Otsu umbralization,但是我有链接错误。
如果问题很严重,我很抱歉,但我找不到任何解决方案:
Preproceso.h
#ifndef _H_
#define _H_
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
class Preproceso
{
public:
Preproceso(void);
~Preproceso(void);
cv::Mat Otsu(cv::Mat imagen);
cv::Mat HistCalc(cv::Mat imagen);
};
#endif
Preproceso.cpp
#include "stdafx.h"
#include "Preproceso.h"
Preproceso::Preproceso(void)
{
}
Preproceso::~Preproceso(void)
{
}
cv::Mat Otsu(cv::Mat imagen) {
cv::Mat img_bw;
cv::threshold(imagen, img_bw, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
return img_bw;
}
cv::Mat HistCalc(cv::Mat imagen) {
float rangeColor[] = {0, 256};
const float* ranges = {rangeColor};
int channels[] = {0};
cv::Mat hist;
int bins = 255;
int histSize = {bins};
cv::calcHist(&imagen, 1, channels, cv::Mat(), hist, 1, &bins, &ranges, true, false);
return hist;
}
Test.cpp的
#include "stdafx.h"
#include "Preproceso.h"
int main(int argc, _TCHAR* argv[])
{
Preproceso prep = Preproceso();
cv::Mat image = cv::imread("Crotal1.TIF", 0);
cv::Mat bw_img = prep.Otsu(image);
cv::namedWindow( "Otsu", CV_WINDOW_AUTOSIZE );
cv::imshow( "Otsu", bw_img );
cv::waitKey(0);
return EXIT_SUCCESS;
}
错误是这个(在我的西班牙语版本中):
错误LNK2019:símboloexterno“public:class cv :: Mat __thiscall Preproceso :: Otsu(class cv :: Mat)“ (?umbralizarImage @ Preproceso @@ QAE?AVMat @ cv @@ V23 @@ Z)sin resolver al que se hace referencia enlafunción_main致命错误LNK1120:1 externos sin resolver
感谢您的帮助和对不起的英语:(