status_t _GlReplicateAlgo::Process( const GlPlanes* pixels, uint8* data, int32 w, int32 h, GlProcessStatus* status) { if (!data) return B_OK; /* 0.5 is 2 replications -- anything below that is obviously meaningless. */ if (mDepth.rel < 0.50 && mDepth.abs < 1) return B_OK; /* Figure the total number of replications I can do, then use that * and the depth to figure how many I'm actually going to do. */ int32 count = 0; int32 n = 0; int32 div = 2; while (w / div > 2 && h / div > 2) { count++; div += 2; } if (mDepth.rel >= 0.50) n = ARP_ROUND(((mDepth.rel - 0.5) * (count - 1)) / 0.5) + 1; n += mDepth.abs; if (n < 1) return B_OK; else if (n > count) n = count; int16* bigDest = new int16[w * h]; if (!bigDest) return B_OK; int32 pix; for (pix = 0; pix < w * h; pix++) bigDest[pix] = data[pix]; GlAlgo1d* algo = Algo1dAt(_ALGO_INDEX); GlCache1d* cache = (algo) ? algo->NewCache(n) : 0; //printf("_GlReplicateAlgo depth %ld\n", n); int32 dataW = w, dataH = h; div = 2; for (int32 k = 0; k < n; k++) { int32 newDataW = w / div, newDataH = h / div; if (MakeData(data, dataW, dataH, newDataW, newDataH) != B_OK) break; dataW = newDataW; dataH = newDataH; int32 low = 255, high = 0; for (int32 pix = 0; pix < dataW * dataH; pix++) { if (data[pix] < low) low = data[pix]; if (data[pix] > high) high = data[pix]; } FillOffsets(k, n, low, high, cache); Tile(data, dataW, dataH, bigDest, w, h); div += 2; } for (pix = 0; pix < w * h; pix++) data[pix] = arp_clip_255(bigDest[pix]); delete[] bigDest; delete cache; return B_OK; }
int main(int argc, char *argv[]) { SamplesDesctiptors descriptors = ParseDescriptors(TRAIN_IMAGES + GENDERS_FILENAME); cv::Mat features(descriptors.size(), THUMBNAIL_SIZE.width * THUMBNAIL_SIZE.height, CV_32FC1); cv::Mat targets(descriptors.size(), 1, CV_32SC1); std::cout << "Parsing data" << std::endl; MakeData(descriptors, &features, &targets); CvSVM svm; std::cout << "Learning" << std::endl; Learn(features, targets, &svm); std::cout << "Saving model" << std::endl; svm.save(GENDERMODEL_FILENAME); // std::cout << QFoldTest(features, targets, 10) << std::endl; return 0; }
CPLErr HFAEntry::SetFieldValue( const char * pszFieldPath, char chReqType, void *pValue ) { HFAEntry *poEntry = this; /* -------------------------------------------------------------------- */ /* Is there a node path in this string? */ /* -------------------------------------------------------------------- */ if( strchr(pszFieldPath,':') != NULL ) { poEntry = GetNamedChild( pszFieldPath ); if( poEntry == NULL ) return CE_Failure; pszFieldPath = strchr(pszFieldPath,':') + 1; } /* -------------------------------------------------------------------- */ /* Do we have the data and type for this node? Try loading */ /* from a file, or instantiating a new node. */ /* -------------------------------------------------------------------- */ LoadData(); if( MakeData() == NULL || pabyData == NULL || poType == NULL ) { CPLAssert( FALSE ); return CE_Failure; } /* -------------------------------------------------------------------- */ /* Extract the instance information. */ /* -------------------------------------------------------------------- */ MarkDirty(); return( poType->SetInstValue( pszFieldPath, pabyData, nDataPos, nDataSize, chReqType, pValue ) ); }
void D3DObjectImage::Draw(D3DDevice *d3d) { _dirty = false; DBG("Image draw: (%.3f, %.3f, %.3f, %.3f)", _x, _y, _w, _h); if (_cache_enabled) { _cache.Add(this); _cache_i = _cache.Length() - 1; return; } D3DShaderPack::Current()->SetVDecl(d3d, D3DShaderPack::VDECL_XYUVC); D3DShaderPack::Current()->SetVS(d3d, D3DShaderPack::VS_COPY_UV_COLOR); D3DShaderPack::Current()->SetPS(d3d, D3DShaderPack::PS_TEX_COLOR_FILTER); D3DImageCache::Current()->SelectImageToDevice(d3d, _image_id); if (!_with_border) d3d->GetDevice()->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, MakeData(), sizeof(Vertex)); else d3d->GetDevice()->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 18, MakeDataBorder(), sizeof(Vertex)); }
int main() { ObjIeeeIndexManager im; ObjFactory f(&im); ObjFile *fi = MakeData(f); fi->ResolveSymbols(&f); std::fstream a("hi.txt", std::fstream::trunc | std::fstream::out); ObjIeee i("hi"); i.SetTranslatorName("Link32"); i.SetDebugInfoFlag(true); ObjSection *sect = codeSection; ObjExpression *left = f.MakeExpression(sect); ObjExpression *right = f.MakeExpression(10); ObjExpression *sa = f.MakeExpression(ObjExpression::eAdd, left, right); i.SetStartAddress(sa); i.Write(a, fi, &f); a.close(); // ObjFile *fi = i->Read(a, ObjIeee::eAll, f); ObjIeeeIndexManager im1; ObjFactory fact1(&im1); std::fstream b("hi.txt", std::fstream::in); ObjIeee i1("hi"); ObjFile *fi1 = i.Read(b, ObjIeee::eAll, &fact1); a.close(); std::fstream c("hi2.txt", std::fstream::trunc | std::fstream::out); ObjIeee i2("hi"); i.SetTranslatorName("Link32"); i.SetDebugInfoFlag(true); i.Write(c, fi1, &fact1); c.close(); }
pf::Packet::OtherCharacterAnimation::OtherCharacterAnimation(pf::Character *character) { pf::Animation *animation = character->GetImage(); entityID = character->GetID(); data = MakeData(character->GetDirection() == pf::Character::RIGHT, animation->IsPlaying(), !animation->IsPlaying()); frame = animation->GetCurrentFrame(); }