求高手~~
我的程序在编译时出现错误
>cl: 命令行 error D8016 :“/MTd”和“/clr”命令行选项不兼容
1>项目 : error PRJ0002 : 错误的结果 2 (从“D:\Microsoft Visual Studio 9.0\VC\bin\cl.exe”返回)。
请问这要怎么解决啊~~
是哪里出了问题
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include "disjoint-set.h"
#include <algorithm>
#include <vector>
using namespace System;
using namespace std;
#define width 512
#define height 512
#define cons 300//k
#define THRESHOLD(size, c) (c/size)
struct edgenode
{
int weight;
long int begin,end;
bool operator <(const edgenode& other) const
{
return weight<other.weight;
}
};
vector<edgenode> edge;
int colors[width*height];
int main(array<System::String ^> ^args)
{
edgenode a;
//nodevetex b;
IplImage *pImg,*fImg;
IplImage *newImg;
long int i,j,s,t;
fImg=cvLoadImage("ff.jpg",0);
if(!fImg){
printf("cannot load the file.\n");
return -1;
}
//filter to erase noise
float k[9]={1.f/16,2.f/16,1.f/16,2.f/16,4.f/16,2.f/16,1.f/16,2.f/16,1.f/16};
CvMat Km;
Km=cvMat(3,3,CV_32F,k);
pImg=cvCloneImage(fImg);
cvFilter2D(fImg,pImg,&Km,cvPoint(-1,-1));
uchar *data,*newdata;
int channels, step,depth;
depth=pImg->depth;
step=pImg->widthStep;
channels=pImg->nChannels;
data=(uchar *) pImg->imageData;
printf("constructing graph....\n");
for(i=1;i<height-1;i++)
{
for(j=1;j<width-1;j++)
{
a.weight=abs(data[i*step+j]-data[i*step+j-1]);
a.begin=i*width+j;
a.end=i*width+j-1;
edge.push_back(a);
a.weight=abs(data[i*step+j]-data[i*step+j+1]);
a.begin=i*width+j;
a.end=i*width+j+1;
edge.push_back(a);
a.weight=abs(data[i*step+j]-data[(i-1)*step+j]);
a.begin=(i-1)*width+j;
a.end=i*width+j;
edge.push_back(a);
a.weight=abs(data[i*step+j]-data[(i+1)*step+j]);
a.begin=i*width+j;
a.end=(i+1)*width+j;
edge.push_back(a);
}
}
printf("sorting the edges...\n");
sort(edge.begin(),edge.end());
int num_edge=edge.size();
int num_vertex=(width)*(height);
printf("make a disjoint-set forest......\n");
universe *u = new universe(num_vertex);
float *threshold = new float[num_vertex];
for (int i = 0; i < num_vertex; i++)
threshold[i] = THRESHOLD(1,cons);
printf("processing......\n");
for (int i = 0; i < num_edge; i++) {
long int a = u->find(edge[i].begin);
int b = u->find(edge[i].end);
if (a != b)
{
if ((edge[i].weight <= threshold[a]) && (edge[i].weight<= threshold[b]))
{
u->join(a, b);
a = u->find(a);
threshold[a] = edge[i].weight + THRESHOLD(u->size(a), cons);
}
}
}
printf("creating new graph......\n");
newImg=cvCreateImage(cvSize(width,height),depth,channels);//生成空图
newdata=(uchar *)newImg->imageData;
for (i = 0; i < width*height; i++)
colors[i] = rand() % 256;
for (i = 1; i < height-1; i++)
{
for (int j = 1; j < width-1; j++)
{
long int comp = u->find(i * width + j);
newdata[i*step+j]=colors[comp];
}
}
//delete [] colors;
//delete u;
cvSaveImage("ffbeforevolt.jpg",newImg);
cvNamedWindow("image",1);
cvShowImage("image",pImg);
cvNamedWindow("newimage",1);
cvShowImage("newimage",newImg);
cvWaitKey(0);
cvDestroyWindow("image");
cvReleaseImage(&pImg);
cvDestroyWindow("newimage");
cvReleaseImage(&newImg);
}
这是代码,代码应该没有错误吧
[解决办法]
项目属性里面改