seg.h 头文件导入至 Cpig.cpp文件后出现如下错误:
1>------ 已启动生成: 项目: AnimalsFatMeasure, 配置: Release x64 ------
1>Cpig.cpp
1>seg.cpp
1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_srcImage" (?g_srcImage@@3VMat@cv@@A)
1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_grayImage" (?g_grayImage@@3VMat@cv@@A)
1>D:\AnimalsFatMeasure\AnimalsFatMeasure\x64\Release\AnimalsFatMeasure.exe : fatal error LNK1120: 2 个无法解析的外部命令
//seg.h
#ifndef __SEG_H__
#define __SEG_H__
#include"stdafx.h"
#include <iostream>
#include<opencv2\opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<vector>
#include<math.h>
#include<algorithm>
#include<time.h>
#include<io.h>
#include<stdio.h>
#include<string>
using namespace cv;
using namespace std;
extern Mat g_srcImage;
extern Mat g_grayImage;
inline void ImageLoad(string imagefile) {
Mat ori_image = imread(imagefile, 0);
Rect rect(100, 100, 540, 400);
ori_image = ori_image(rect);//截取图像
threshold(ori_image, ori_image, 1, 255, CV_THRESH_BINARY);//二值化
//threshold(ori_image, ori_image, g_nThresh, g_nMaxThresh, CV_THRESH_BINARY);//二值化
//waitKey(0);
imwrite("binaryimg.jpg", ori_image);
g_srcImage = imread("binaryimg.jpg", 1);
if (!g_srcImage.data)
{
printf("读取错误,图片不存在");
}
//得到原图的灰度图并进行平滑
//Point point;
cvtColor(g_srcImage, g_grayImage, COLOR_BGR2GRAY);
blur(g_grayImage, g_grayImage, Size(3, 3));
on_ContourChange(0, 0);
}
// Cpig.cpp: 实现文件
#include <opencv2/opencv.hpp>
#include "stdafx.h"
#include "Cpig.h"
#include "afxdialogex.h"
#include "resource.h"
#include <algorithm>
#include <fstream>
#include <string>
#include <windows.h>
#include <iostream>
#include "INFOR.h"
#include "seg.h"