bool PLDynVarVector3iTreeItem::Vector3iValueBaseTreeItem::setData(const int column, const QVariant &value, const int role) { if (role != Qt::EditRole || column != 1) return false; float floatVal = value.value<float>(); SetVectorData(m_parentItem->m_Vector3i, floatVal); m_parentItem->UpdateDataToVar(); return true; }
bool OCVLbp::CalculateOpenCV(int /*f*/, int l) { static const string msg = "OCVLbp::CalculateOpenCV() : "; featureVector fv; if (LabelVerbose()) cout << msg << "starting" << endl; bool ok = true; if (spoints.empty()) CreateSPoints(); if (!ok || spoints.empty() || (spoints.size() != options.nneighbors)) { cerr << msg << "Missing or wrong pixel neighborhood." << endl; return false; } if (options.lbptype == CSLBP) { if (options.neighborhood != LBP_CIRCULAR) { cerr << msg << "CS-LBP requires (currently) a circular neighborhood" << endl; return false; } else if (options.mapping != LBP_MAPPING_NONE) { cerr << msg << "CS-LBP is not compatible with any mappings" << endl; return false; } } if ((options.mapping != LBP_MAPPING_NONE) && lbp_map.mapsize == 0) CreateMap(); // lbp_image = // ocv_image_(Rect(options.crop.x0, options.crop.y0, // ocv_image_.cols-options.crop.x0-options.crop.x1, // ocv_image_.rows-options.crop.y0-options.crop.y1)); lbp_image = ocv_image_; if (options.write_image) { string sn; if ((size_t)l<RegionDescriptorCount()) sn = RegionDescriptor(l).first; else sn = ToStr(l); //string oname = "lbp-"+BaseFileName()+"-"+ToStr(f)+"-"+ToStr(l)+".jpg"; string oname = "lbp-"+BaseFileName()+"_"+sn+".jpg"; imwrite(oname, lbp_image); } if (blocktypes.empty()) blocktypes.push_back(BLOCKS_1x1); CreateBlocks(); MatND storedhist; list<pair<Rect,lbp_block_type> >::const_iterator i; for (i = lbp_blocks.begin(); i!=lbp_blocks.end(); i++) { MatND hist; Mat blockimg = lbp_image(i->first); CalculateLbp(blockimg, hist); if (i->second == BLOCK_STORE) storedhist = hist; else if (i->second == BLOCK_SUBTRACT) hist -= storedhist; if (options.normalize_histogram != HISTNORM_NONE) { Scalar sumhist = sum(hist); hist /= sumhist[0]; } if (options.normalize_histogram == HISTNORM_CAPPED) { for (int ii=0; ii<hist.rows; ii++) if (hist.at<float>(ii)>0.2) hist.at<float>(ii) = 0.2; Scalar sumhist = sum(hist); hist /= sumhist[0]; } for (int ii=0; ii<hist.rows; ii++) fv.push_back(hist.at<float>(ii)); } SetVectorData(l, fv); if (LabelVerbose()) cout << msg << "ending" << endl; return true; }