Example #1
0
void ma::cpdLinear(const ma::FacingPointSets& points,
                   ma::WarpResult& warpResult, const ma::CPDParams& params,
                   ma::Context* ctx) {
    if (!ctx) {
        ctx = &defaultContext();
    }
    McDMatrix<double> refCoordsM, transCoordsM;

    CPDLinearAligner cpd;
    cpd.setContext(ctx);
    cpd.params = params.linear;

    if (params.linear.useDirections) {
        FacingPointSets copy = points;
        for (int i = 0; i < copy.trans.directions.size(); i++) {
            copy.trans.directions[i] *= -1;
        }
        cpd.setPoints(copy);
    } else {
        cpd.setPoints(points);
    }

    McDMatrix<double> R, Rd;
    McDVector<double> t;
    double s;
    const AlignInfo info = cpd.align(R, s, t, Rd);
    warpResult.type = WT_LINEAR;
    warpResult.transformMatrix = cpd.getTransformMat4f(R, s, t);
    warpResult.alignInfo = info;
}
Example #2
0
void t05_context(){
	INIT_LOCAL();
	Onion::Dict dict(defaultContext());
	ONION_DEBUG("Render");
	
	// This is important as otemplate templates need ownership as they 
	// will free the pointer. These way we use the internal refcount to avoid double free.
	onion_dict_dup(dict.c_handler()); 
	
	index_html_template(dict.c_handler());
	END_LOCAL();
}
Example #3
0
void ma::cpdElastic(const ma::FacingPointSets& points,
                    ma::WarpResult& warpResult, const ma::CPDParams& params,
                    ma::Context* ctx) {
    if (!ctx) {
        ctx = &defaultContext();
    }
    CPDElasticAligner cpd;
    cpd.setContext(ctx);
    cpd.params = params.elastic;

    if (params.elastic.useDirections) {
        FacingPointSets copy = points;
        for (int i = 0; i < copy.trans.directions.size(); i++) {
            copy.trans.directions[i] *= -1;
        }
        cpd.setPoints(copy);
    } else {
        cpd.setPoints(points);
    }

    // Solve.
    AlignInfo info;
    McDArray<McVec3f> transCoords = cpd.align(info);

    McDArray<McVec3f> origCoords = points.trans.positions;
    const int nbefore = origCoords.size();
    resamplePairs(origCoords, transCoords,
                  params.elastic.sampleDistForWarpingLandmarks);
    ctx->print(QString("%1 of %2 points left after resampling.")
                   .arg(nbefore)
                   .arg(origCoords.size()));
    warpResult.type = WT_ELASTIC;
    warpResult.mlsParams.alpha = params.alphaForMLS;
    warpResult.mlsParams.ps = asVec2dArray(origCoords);
    warpResult.mlsParams.qs = asVec2dArray(transCoords);
    warpResult.alignInfo = info;
}
Example #4
0
Onion::Dict defaultContext(){
  Onion::Dict dict; 
  return defaultContext(dict);
}