Exemplo n.º 1
0
	void prepareValuesForPoseEstimation(IMAGEDATA templateImage, Mat homography, vector<Point3d> &modelPoints, vector<Point2f> &imagePoints, Point2f &centerPoint ){
		
		float height = templateImage.image.rows;
		float width = templateImage.image.cols;
		
		modelPoints.clear();
		modelPoints.push_back(Point3d(0.0, 0.0, 0.0));
		modelPoints.push_back(Point3d(height, 0.0, 0.0));
		modelPoints.push_back(Point3d(height, height, 0.0));
		modelPoints.push_back(Point3d(0.0, height, 0.0));
		
		vector<Point2f> squareCorners;
		squareCorners.push_back(Point2f(((width / 2.0f) - (height / 2.0f)), 0.0f));
		squareCorners.push_back(Point2f(((width / 2.0f) + (height / 2.0f)), 0.0f));
		squareCorners.push_back(Point2f(((width / 2.0f) + (height / 2.0f)), height));
		squareCorners.push_back(Point2f(((width / 2.0f) - (height / 2.0f)), height));
		
		imagePoints.clear();
		transformPoints(homography, squareCorners, imagePoints);
		
		vector<Point2f> centerPointTemplate;
		vector<Point2f> temp;
		centerPointTemplate.push_back(Point2f(width/2.0f, height/2.0f));
		transformPoints(homography, centerPointTemplate, temp);
		
		centerPoint = temp[0];
		
	}	
void HomotheticTransformation2D::transformPoints ( const Container <Point1 *, destructable> &global_points, const Container <Point2 *, destructable2> &local_points, Container <Point3 *, destructable3> &transformed_points,
                TTransformationKeyHomothetic2D <typename Point1::Type> & key_homothetic, const bool print_exception, std::ostream * output )
{
        //Compute non weighted 2D Homothetic transformation
        typename TWeights <typename Point1::Type> ::Type weights ( global_points.size(), 1.0 );
        transformPoints ( global_points, local_points, transformed_points, weights, key_homothetic );
}
	void PointAlignerTest(){

		MatrixXf P(2, 100);

		for(int i=0; i<100; i++){
		
			srand (time(NULL));
			P(0, i) = rand()%100;

			for(int j=0; j<100000; j++)

			srand (time(NULL));
			P(1, i) = rand()%100;
		
		}

		cout << "P : \n" << P << endl;

		Vector3f x_ideal;

		x_ideal << 20, 30, PI/2;

		//cout << "x_ideal : \n" << x_ideal << endl;

		Matrix3f X_ideal;

		X_ideal = v2tRad(x_ideal);

		//cout << "X_ideal : \n" << X_ideal << endl;

		MatrixXf Pt(2, 100);

		Pt = transformPoints(X_ideal.inverse(), P);

		cout << "Pt : \n" << Pt << endl;

		MatrixXf Z(4, P.cols());

		for(int i=0; i<P.cols(); i++){

			Z(0, i) = P(0, i);
			Z(1, i) = P(1, i);
			Z(2, i) = Pt(0, i);
			Z(3, i) = Pt(1, i);

		}

		cout << "Z : \n" << Z << endl;

		Vector3f x; //initial guess

		x << 0,0,0;

		cout << "x : \n" << x << endl;

		cout << pointAlignerLoop(x, Z, 100);

		return ;
	}
Exemplo n.º 4
0
/*
 * Class:     sun_java2d_x11_X11Renderer
 * Method:    XDrawPoly
 * Signature: (IJII[I[IIZ)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawPoly
    (JNIEnv *env, jobject xr,
     jlong pXSData, jlong xgc,
     jint transx, jint transy,
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints,
     jboolean isclosed)
{
#ifndef HEADLESS
    XPoint pTmp[POLYTEMPSIZE], *points;
    X11SDOps *xsdo = (X11SDOps *) pXSData;

    if (xsdo == NULL) {
        return;
    }

    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
        JNU_ThrowNullPointerException(env, "coordinate array");
        return;
    }
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
    {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
        return;
    }

    if (npoints < 2) {
        return;
    }

    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
                             pTmp, (int *)&npoints, isclosed);
    if (points == 0) {
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
    } else {
        if (npoints == 2) {
            /*
             * Some X11 implementations fail to draw anything for
             * simple 2 point polygons where the vertices are the
             * same point even though this violates the X11
             * specification.  For simplicity we will dispatch all
             * 2 point polygons through XDrawLine even if they are
             * non-degenerate as this may invoke less processing
             * down the line than a Poly primitive anyway.
             */
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
                      points[0].x, points[0].y,
                      points[1].x, points[1].y);
        } else {
            XDrawLines(awt_display, xsdo->drawable, (GC) xgc,
                       points, npoints, CoordModeOrigin);
        }
        if (points != pTmp) {
            free(points);
        }
        X11SD_DirectRenderNotify(env, xsdo);
    }
#endif /* !HEADLESS */
}
 void translate(double x, double y, double z)
 {
     double tmp[16] =
     {
         1.0, 0.0, 0.0, x  ,
         0.0, 1.0, 0.0, y  ,
         0.0, 0.0, 1.0, z  ,
         0.0, 0.0, 0.0, 1.0
     };
     transformPoints(Matrix(tmp));
 }
    void scale(double x, double y, double z)
    {
        double tmp[16] =
        {
            x  , 0.0, 0.0, 0.0,
            0.0, y  , 0.0, 0.0,
            0.0, 0.0,   z, 0.0,
            0.0, 0.0, 0.0, 1.0
        };

        transformPoints(Matrix(tmp));
    }
    void rotateY(float angleDeg)
    {
        double angleRad = toRad(angleDeg);

        double tmp[16] =
        {
            cos(angleRad) , 0.0, sin(angleRad), 0.0,
            0.0           , 1.0,           0.0, 0.0,
            -sin(angleRad), 0.0, cos(angleRad), 0.0,
            0.0           , 0.0,           0.0, 1.0
        };

        transformPoints(Matrix(tmp));
    }
    void rotateX(double angleDeg)
    {
        double angleRad = toRad(angleDeg);

        double tmp[16] =
        {
            1.0,           0.0,            0.0, 0.0,
            0.0, cos(angleRad), -sin(angleRad), 0.0,
            0.0, sin(angleRad),  cos(angleRad), 0.0,
            0.0,           0.0,            0.0, 1.0
        };

        transformPoints(Matrix(tmp));
        mChanged = true;
    }
void solidBodyMotionDisplacementPointPatchVectorField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

    // Determine current local points and offset
    fixedValuePointPatchVectorField::operator==
    (
        transformPoints(SBMFPtr_().transformation(), localPoints0())
       -localPoints0()
    );

    fixedValuePointPatchVectorField::updateCoeffs();
}
Exemplo n.º 10
0
/*
 * Class:     sun_java2d_x11_X11Renderer
 * Method:    XFillPoly
 * Signature: (IJII[I[II)V
 */
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillPoly
    (JNIEnv *env, jobject xr,
     jlong pXSData, jlong xgc,
     jint transx, jint transy,
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints)
{
#ifndef HEADLESS
    XPoint pTmp[POLYTEMPSIZE], *points;
    X11SDOps *xsdo = (X11SDOps *) pXSData;

    if (xsdo == NULL) {
        return;
    }

    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
        JNU_ThrowNullPointerException(env, "coordinate array");
        return;
    }
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
    {
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
        return;
    }

    if (npoints < 3) {
        return;
    }

    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
                             pTmp, (int *)&npoints, JNI_FALSE);
    if (points == 0) {
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
    } else {
        if (npoints > 2) {
            XFillPolygon(awt_display, xsdo->drawable, (GC) xgc,
                         points, npoints, Complex, CoordModeOrigin);
            X11SD_DirectRenderNotify(env, xsdo);
        }
        if (points != pTmp) {
            free(points);
        }
    }
#endif /* !HEADLESS */
}
solidBodyMotionDisplacementPointPatchVectorField::
solidBodyMotionDisplacementPointPatchVectorField
(
    const solidBodyMotionDisplacementPointPatchVectorField& ptf,
    const DimensionedField<vector, pointMesh>& iF
)
:
    fixedValuePointPatchVectorField(ptf, iF),
    SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
{
    // For safety re-evaluate

    fixedValuePointPatchVectorField::operator==
    (
        transformPoints(SBMFPtr_().transformation(), localPoints0())
       -localPoints0()
    );
}
Exemplo n.º 12
0
void CurvePlot::outPut(QVector<float>&data)
{
    int w = width() - Margin.Left - Margin.Right;
    int h = height() - Margin.Top - Margin.Bottom;

    pixmap = QPixmap(w, h);
    QPainter painter(&pixmap);
    painter.setRenderHints(QPainter::SmoothPixmapTransform);
    painter.fillRect(QRectF(0, 0, w, h), Background);

    QVector<QPointF> points;
    transformPoints(data, w, h, points);
    painter.setPen(Pen);
    for (int i= 0; i< points.size()-1; i++)
        painter.drawLine(points[i], points[i+1]);

    update();
}
solidBodyMotionDisplacementPointPatchVectorField::
solidBodyMotionDisplacementPointPatchVectorField
(
    const pointPatch& p,
    const DimensionedField<vector, pointMesh>& iF,
    const dictionary& dict
)
:
    fixedValuePointPatchVectorField(p, iF, dict, false),
    SBMFPtr_(solidBodyMotionFunction::New(dict, this->db().time()))
{
    if (!dict.found("value"))
    {
        // Determine current local points and offset
        fixedValuePointPatchVectorField::operator==
        (
            transformPoints(SBMFPtr_().transformation(), localPoints0())
           -localPoints0()
        );
    }
}
Exemplo n.º 14
0
PERF_TEST_P(DevInfo, transformPoints, testing::ValuesIn(devices()))
{
    DeviceInfo devInfo = GetParam();

    setDevice(devInfo.deviceID());

    Mat src_host(1, 10000, CV_32FC3);

    declare.in(src_host, WARMUP_RNG);

    GpuMat src(src_host);
    GpuMat dst;

    declare.time(0.5).iterations(100);

    SIMPLE_TEST_CYCLE()
    {
        transformPoints(src, Mat::ones(1, 3, CV_32FC1), Mat::ones(1, 3, CV_32FC1), dst);
    }

    Mat dst_host(dst);

    SANITY_CHECK(dst_host);
}