本文整理汇总了C++中vecI类的典型用法代码示例。如果您正苦于以下问题:C++ vecI类的具体用法?C++ vecI怎么用?C++ vecI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vecI类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gtBndBoxSampling
int Objectness::gtBndBoxSampling(const Vec4i &bbgt, vector<Vec4i> &samples, vecI &bbR)
{
double wVal = bbgt[2] - bbgt[0] + 1, hVal = (bbgt[3] - bbgt[1]) + 1;
wVal = log(wVal)/_logBase, hVal = log(hVal)/_logBase;
int wMin = max((int)(wVal - 0.5), _minT), wMax = min((int)(wVal + 1.5), _maxT);
int hMin = max((int)(hVal - 0.5), _minT), hMax = min((int)(hVal + 1.5), _maxT);
for (int h = hMin; h <= hMax; h++) for (int w = wMin; w <= wMax; w++) {
int wT = tLen(w) - 1, hT = tLen(h) - 1;
Vec4i bb(bbgt[0], bbgt[1], bbgt[0] + wT, bbgt[1] + hT);
if (DataSetVOC::interUnio(bb, bbgt) >= 0.5) {
samples.push_back(bb);
bbR.push_back(sz2idx(w, h));
//if (bbgt[3] > hT){
// bb = Vec4i(bbgt[0], bbgt[3] - hT, bbgt[0] + wT, bbgt[3]);
// CV_Assert(DataSetVOC::interUnio(bb, bbgt) >= 0.5);
// samples.push_back(bb);
// bbR.push_back(sz2idx(w, h));
//}
//if (bbgt[2] > wT){
// bb = Vec4i(bbgt[2] - wT, bbgt[1], bbgt[2], bbgt[1] + hT);
// CV_Assert(DataSetVOC::interUnio(bb, bbgt) >= 0.5);
// samples.push_back(bb);
// bbR.push_back(sz2idx(w, h));
//}
//if (bbgt[2] > wT && bbgt[3] > hT){
// bb = Vec4i(bbgt[2] - wT, bbgt[3] - hT, bbgt[2], bbgt[3]);
// CV_Assert(DataSetVOC::interUnio(bb, bbgt) >= 0.5);
// samples.push_back(bb);
// bbR.push_back(sz2idx(w, h));
//}
}
}
return samples.size();
}
开发者ID:MasazI,项目名称:BING-Objectness,代码行数:34,代码来源:Objectness.cpp
示例2: trainSVM
// Training SVM with feature vector X and label Y.
// Each row of X is a feature vector, with corresponding label in Y.
// Return a CV_32F weight Mat
Mat Objectness::trainSVM(CMat &X1f, const vecI &Y, int sT, double C, double bias, double eps)
{
// Set SVM parameters
parameter param; {
param.solver_type = sT; // L2R_L2LOSS_SVC_DUAL;
param.C = C;
param.eps = eps; // see setting below
param.p = 0.1;
param.nr_weight = 0;
param.weight_label = NULL;
param.weight = NULL;
set_print_string_function(print_null);
CV_Assert(X1f.rows == Y.size() && X1f.type() == CV_32F);
}
// Initialize a problem
feature_node *x_space = NULL;
problem prob;{
prob.l = X1f.rows;
prob.bias = bias;
prob.y = Malloc(double, prob.l);
prob.x = Malloc(feature_node*, prob.l);
const int DIM_FEA = X1f.cols;
prob.n = DIM_FEA + (bias >= 0 ? 1 : 0);
x_space = Malloc(feature_node, (prob.n + 1) * prob.l);
int j = 0;
for (int i = 0; i < prob.l; i++){
prob.y[i] = Y[i];
prob.x[i] = &x_space[j];
const float* xData = X1f.ptr<float>(i);
for (int k = 0; k < DIM_FEA; k++){
x_space[j].index = k + 1;
x_space[j++].value = xData[k];
}
if (bias >= 0){
x_space[j].index = prob.n;
x_space[j++].value = bias;
}
x_space[j++].index = -1;
}
CV_Assert(j == (prob.n + 1) * prob.l);
}
// Training SVM for current problem
const char* error_msg = check_parameter(&prob, ¶m);
if(error_msg){
fprintf(stderr,"ERROR: %s\n",error_msg);
exit(1);
}
model *svmModel = train(&prob, ¶m);
Mat wMat(1, prob.n, CV_64F, svmModel->w);
wMat.convertTo(wMat, CV_32F);
free_and_destroy_model(&svmModel);
destroy_param(¶m);
free(prob.y);
free(prob.x);
free(x_space);
return wMat;
}
开发者ID:terrychenism,项目名称:Objectness_Detection,代码行数:62,代码来源:Objectness.cpp
示例3: loadBox
void DataSetVOC::loadBox(const FileNode &fn, vector<Vec4i> &boxes, vecI &clsIdx){
string isDifficult;
fn["difficult"]>>isDifficult;
if (isDifficult == "1")
return;
string strXmin, strYmin, strXmax, strYmax;
fn["bndbox"]["xmin"] >> strXmin;
fn["bndbox"]["ymin"] >> strYmin;
fn["bndbox"]["xmax"] >> strXmax;
fn["bndbox"]["ymax"] >> strYmax;
boxes.push_back(Vec4i(atoi(_S(strXmin)), atoi(_S(strYmin)), atoi(_S(strXmax)), atoi(_S(strYmax))));
string clsName;
fn["name"]>>clsName;
clsIdx.push_back(findFromList(clsName, classNames));
CV_Assert_(clsIdx[clsIdx.size() - 1] >= 0, ("Invalidate class name\n"));
}
开发者ID:DraculaIII,项目名称:Objectness,代码行数:18,代码来源:DataSetVOC.cpp
示例4: isLucky
bool isLucky(vecI mv){
int cont;
int n = mv.size();
for(int i = 0; i < n; i++)
{
if(mv[i]== 4 or mv[i] == 7)
cont++;
}
if(cont == n) return true;
else return false;
}
开发者ID:jairxserfer,项目名称:CompetitiveProgramming,代码行数:11,代码来源:luckydivision.cpp
示例5: newIdx
int CmAPCluster::ReMapIdx(vecI &mapIdx)
{
int N = (int)mapIdx.size(), newCount = 0;
map<int, int> idxCount, oldNewIdx;
vecI newIdx(N);
for (int i = 0; i < N; i++){
if (idxCount.find(mapIdx[i]) == idxCount.end())
oldNewIdx[mapIdx[i]] = newCount++, idxCount[mapIdx[i]]++;
mapIdx[i] = oldNewIdx[mapIdx[i]];
}
return (int)idxCount.size();
}
开发者ID:20083017,项目名称:CmCode,代码行数:12,代码来源:CmAPCluster.cpp
示例6: predictBBoxSI
void Objectness::predictBBoxSI(CMat &img3u, ValStructVec<float, Vec4i> &valBoxes, vecI &sz, int NUM_WIN_PSZ, bool fast)
{
const int numSz = _svmSzIdxs.size();
const int imgW = img3u.cols, imgH = img3u.rows;
valBoxes.reserve(10000);
sz.clear();
sz.reserve(10000);
for (int ir = numSz - 1; ir >= 0; ir--) {
int r = _svmSzIdxs[ir];
int height = cvRound(pow(_base, r/_numT + _minT)), width = cvRound(pow(_base, r%_numT + _minT));
if (height > imgH * _base || width > imgW * _base)
continue;
height = min(height, imgH), width = min(width, imgW);
Mat im3u, matchCost1f, mag1u;
resize(img3u, im3u, Size(cvRound(_W*imgW*1.0/width), cvRound(_W*imgH*1.0/height)));
gradientMag(im3u, mag1u);
matchCost1f = _tigF.matchTemplate(mag1u);
ValStructVec<float, Point> matchCost;
nonMaxSup(matchCost1f, matchCost, _NSS, NUM_WIN_PSZ, fast);
// Find true locations and match values
double ratioX = width/_W, ratioY = height/_W;
int iMax = min(matchCost.size(), NUM_WIN_PSZ);
for (int i = 0; i < iMax; i++) {
float mVal = matchCost(i);
Point pnt = matchCost[i];
Vec4i box(cvRound(pnt.x * ratioX), cvRound(pnt.y*ratioY));
box[2] = cvRound(min(box[0] + width, imgW));
box[3] = cvRound(min(box[1] + height, imgH));
box[0] ++;
box[1] ++;
valBoxes.pushBack(mVal, box);
sz.push_back(ir);
}
}
//exit(0);
}
开发者ID:MasazI,项目名称:BING-Objectness,代码行数:40,代码来源:Objectness.cpp
示例7: loadBBoxes
bool DataSetVOC::loadBBoxes(CStr &nameNE, vector<Vec4i> &boxes, vecI &clsIdx)
{
string fName = format(_S(annoPathW), _S(nameNE));
FileStorage fs(fName, FileStorage::READ);
FileNode fn = fs["annotation"]["object"];
boxes.clear();
clsIdx.clear();
if (fn.isSeq()){
for (FileNodeIterator it = fn.begin(), it_end = fn.end(); it != it_end; it++)
loadBox(*it, boxes, clsIdx);
}
else
loadBox(fn, boxes, clsIdx);
return true;
}
开发者ID:songzheng,项目名称:BING,代码行数:15,代码来源:DataSetVOC.cpp
示例8: S_BinInf
// src3f are BGR, color3f are 1xBinDim matrix represent color fore each histogram bin
int CmColorQua::S_BinInf(CMat& idx1i, Mat &color3f, vecI &colorNum, int method, CMat &src3f)
{
int totalBinNum = 0;
CV_Assert(idx1i.data != NULL && idx1i.type() == CV_32S && method >= 0 && method < S_Q_NUM);
// Find colors for each bin
color3f = Mat::zeros(1, binNum[method], CV_32FC3);
Vec3f* color = (Vec3f*)(color3f.data);
vector<Vec3d> colorD(color3f.cols, 0);
colorNum.resize(color3f.cols, 0);
if (src3f.size() != Size() && src3f.data != NULL) {
for (int r = 0; r < idx1i.rows; r++) {
const int *idx = idx1i.ptr<int>(r);
const Vec3f *src = src3f.ptr<Vec3f>(r);
for (int c = 0; c < idx1i.cols; c++) {
colorD[idx[c]] += src[c];
colorNum[idx[c]] ++;
}
}
}
S_RECOVER_FUNC SR_Function = srFuns[method];
for (int i = 0; i < color3f.cols; i++) {
if (colorNum[i] == 0)
(*SR_Function)(i, color[i]);
else
totalBinNum += colorNum[i];
}
if (method == 1)
cvtColor(color3f, color3f, CV_HSV2BGR);
else if (method == 2)
cvtColor(color3f, color3f, CV_Lab2BGR);
for (int i = 0; i < color3f.cols; i++)
if (colorNum[i] > 0)
color[i] = Vec3f((float)(colorD[i][0]/colorNum[i]), (float)(colorD[i][1]/colorNum[i]), (float)(colorD[i][2]/colorNum[i]));
return totalBinNum;
}
开发者ID:20083017,项目名称:CmCode,代码行数:40,代码来源:CmColorQua.cpp
示例9: divisores
void divisores(int n)
{
mv.clear();
int a;
while(a!=n)
{
if(n%a == 0)
{
mv.push_back(a);
a++;
}
}
}
开发者ID:jairxserfer,项目名称:CompetitiveProgramming,代码行数:13,代码来源:luckydivision.cpp
示例10: MergeLM
void CBuild::MergeLM()
{
vecDefl Layer;
vecDefl deflNew;
vecDefl SEL;
Status("Processing...");
for (u32 light_layer=0; light_layer<pBuild->lights.size(); light_layer++)
{
// Select all deflectors, which contain this light-layer
Layer.clear ();
b_light* L_base = pBuild->lights[light_layer].original;
for (int it=0; it<(int)g_deflectors.size(); it++)
{
if (g_deflectors[it].bMerged) continue;
if (0==g_deflectors[it].GetLayer(L_base)) continue;
Layer.push_back (g_deflectors[it]);
}
if (Layer.empty()) continue;
// Resort layer
// Merge this layer
while (Layer.size())
{
// Sort layer (by material and distance from "base" deflector)
Deflector = Layer[0];
std::sort (Layer.begin()+1,Layer.end(),cmp_defl);
// Select first deflectors which can fit
int maxarea = lmap_size*lmap_size*6; // Max up to 6 lm selected
int curarea = 0;
for (it=1; it<(int)Layer.size(); it++)
{
int defl_area = Layer[it]->GetLayer(L_base)->Area();
if (curarea + defl_area > maxarea) break;
curarea += defl_area;
SEL.push_back(Layer[it]);
}
if (SEL.empty())
{
// No deflectors found to merge
// Simply transfer base deflector to _new list
deflNew.push_back(Deflector);
g_deflectors.erase(g_deflectors.begin());
} else {
// Transfer rects
SEL.push_back(Deflector);
for (int K=0; K<(int)SEL.size(); K++)
{
_rect T;
T.a.set (0,0);
T.b.set (SEL[K]->lm.dwWidth+2*BORDER-1, SEL[K]->lm.dwHeight+2*BORDER-1);
T.iArea = SEL[K]->iArea;
selected.push_back (T);
perturb.push_back (K);
}
// Sort by size decreasing and startup
std::sort (perturb.begin(),perturb.end(),cmp_rect);
InitSurface ();
int id = perturb[0];
_rect &First = selected[id];
_rect_register (First,SEL[id],FALSE);
best.push_back (First);
best_seq.push_back (id);
brect.set (First);
// Process
collected.reserve (SEL.size());
for (int R=1; R<(int)selected.size(); R++)
{
int ID = perturb[R];
if (_rect_place(selected[ID],SEL[ID]))
{
brect.Merge (collected.back());
best.push_back (collected.back());
best_seq.push_back (ID);
}
Progress(float(R)/float(selected.size()));
}
R_ASSERT (brect.a.x==0 && brect.a.y==0);
// Analyze resuls
clMsg("%3d / %3d - [%d,%d]",best.size(),selected.size(),brect.SizeX(),brect.SizeY());
CDeflector* pDEFL = new CDeflector();
pDEFL->lm.bHasAlpha = FALSE;
pDEFL->lm.dwWidth = lmap_size;
pDEFL->lm.dwHeight = lmap_size;
for (K = 0; K<(int)best.size(); K++)
{
int iRealIndex = best_seq [K];
_rect& Place = best [K];
_point& Offset = Place.a;
BOOL bRotated;
b_texture& T = SEL[iRealIndex]->lm;
int T_W = (int)T.dwWidth + 2*BORDER;
int T_H = (int)T.dwHeight + 2*BORDER;
if (Place.SizeX() == T_W) {
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:xray,代码行数:101,代码来源:xrMergeLM.cpp
注:本文中的vecI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论