嗨我错误地将cv210d.lib,cxcore210d.lib和highgui210d.lib添加为项目配置 - >链接器 - >输入 - >附加依赖项设置下的继承值.
但我似乎无法将它们从"继承的"附加依赖项中删除.因此,每次我开始一个新项目时都会收到错误,因为无法找到这些自由.
有一个选项可以忽略继承的依赖项,但我不能这样做,因为它包含我需要的值.
所以我正在寻找一种方法从"继承的"附加依赖项中删除这些不需要的值.
我在运行下面的代码,基本上做的很少.它只增加2和4亿次并输出运行时.
#include "time.h"
#include <iostream>
using namespace std;
void add (){
int tot = 2+4;
}
void main(){
int t = clock();
int count = 0;
while(count<100000000){
int tot = 2+4;
count++;
}
cout <<endl<< "runtime = " << fixed <<(double) (clock() - t) / CLOCKS_PER_SEC <<"s" << endl;
Run Code Online (Sandbox Code Playgroud)
}
但是当我做同样的事情但是调用一个函数时,我有兴趣看到时差.所以我用"add()"替换了"int tot = 2 + 4"这一行.
我期待第二个运行时稍微长一点,但是要长一点.第一个实现= .3s和第二个实现= 3s.
我理解调用该函数需要使用堆栈来存储返回地址并存储本地数据.但它必须做得更多呢?
如果有人可以向我解释究竟是什么导致运行时间的巨大差异,或者我正在做些傻事,那将会很棒.
我在下面的代码中使用normalize函数.我的理解是,对直方图进行标准化会导致这些箱子总和为一个?但是当我把它们全部添加起来时,我会得到比一个更高的结果.我不知道我做错了什么或者误解了这个功能是做什么的?
//read in image
Mat img = imread("image.jpg",1);
vector<Mat> planes;
split(img, planes);
//calculate hist
MatND hist;
int nbins = 256; // hold 256 levels
int hsize[] = { nbins }; // one dimension
float range[] = { 0, 255 };
const float *ranges[] = { range };
int chnls[] = {0};
calcHist(&planes[0], 1, chnls, Mat(), hist,1,hsize,ranges);
//normalise
normalize(hist,hist,1);
float tot = 0;
for( int n = 0;n < nbins; n++ )
{
float binVal = hist.at<float>(n);
tot+=binVal;
}
cout<<tot;
Run Code Online (Sandbox Code Playgroud)