Ejemplo n.º 1
0
bool AbstractContent::fromXml(QDomElement & contentElement, const QDir & /*baseDir*/)
{
    // restore content properties
    QDomElement domElement;

    // Load image size saved in the rect node
    domElement = contentElement.firstChildElement("rect");
    qreal x, y, w, h;
    x = domElement.firstChildElement("x").text().toDouble();
    y = domElement.firstChildElement("y").text().toDouble();
    w = domElement.firstChildElement("w").text().toDouble();
    h = domElement.firstChildElement("h").text().toDouble();
    resizeContents(QRect(x, y, w, h));

    // Load position coordinates
    domElement = contentElement.firstChildElement("pos");
    x = domElement.firstChildElement("x").text().toDouble();
    y = domElement.firstChildElement("y").text().toDouble();
    setPos(x, y);

    qreal zvalue = contentElement.firstChildElement("zvalue").text().toDouble();
    setZValue(zvalue);

    bool visible = contentElement.firstChildElement("visible").text().toInt();
    setVisible(visible);

    qreal opacity = contentElement.firstChildElement("opacity").text().toDouble();
    if (opacity > 0.0 && opacity < 1.0)
        setContentOpacity(opacity);

    int fxIdx = contentElement.firstChildElement("fxindex").text().toInt();
    if (fxIdx > 0)
        setFxIndex(fxIdx);

    bool hasText = contentElement.firstChildElement("frame-text-enabled").text().toInt();
    setFrameTextEnabled(hasText);
    if (hasText) {
        QString text = contentElement.firstChildElement("frame-text").text();
        setFrameText(text);
    }

    quint32 frameClass = contentElement.firstChildElement("frame-class").text().toInt();
    setFrame(frameClass ? FrameFactory::createFrame(frameClass) : 0);

    // restore transformation
    QDomElement te = contentElement.firstChildElement("transformation");
    if (!te.isNull()) {
        m_perspectiveAngles = QPointF(te.attribute("xRot").toDouble(), te.attribute("yRot").toDouble());
#if QT_VERSION < 0x040600
        m_rotationAngle = te.attribute("zRot").toDouble();
#else
        setRotation(te.attribute("zRot").toDouble());
#endif
        applyTransforms();
    }
    domElement = contentElement.firstChildElement("mirror");
    setMirrored(domElement.attribute("state").toInt());

    return true;
}
Ejemplo n.º 2
0
void AbstractContent::setRotation(qreal angle)
{
    if (m_rotationAngle != angle) {
        m_rotationAngle = angle;
        applyTransforms();
        emit rotationChanged();
    }
}
Ejemplo n.º 3
0
void AbstractContent::setPerspective(const QPointF & angles)
{
    if (angles != m_perspectiveAngles) {
        m_perspectiveAngles = angles;
        applyTransforms();
        emit perspectiveChanged();
    }
}
Ejemplo n.º 4
0
static void lvDisplay(void) {
    glClear(GL_COLOR_BUFFER_BIT);
	applyTransforms();

	glColor3f(0.25f, 0.25f, 0.25f);
	glLineWidth(2);
	drawLine(-lvWidth-lvTransX, 0, lvWidth-lvTransX, 0);
	drawLine(0, -lvHeight-lvTransY, 0, lvHeight-lvTransY);
	glLineWidth(1);

	lsystem.Draw();
	
	glMatrixMode(GL_PROJECTION); glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, lvWidth, lvHeight, 0);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    drawSquare(0.25f, 0.25f, 0.25f, 0, 0, lvWidth, BARH);
	drawSquare(0.25f, 0.25f, 0.25f, 0, lvHeight, lvWidth, lvHeight-BARH);
	glLoadIdentity();

	gluOrtho2D(-lvWidth, lvWidth, lvHeight, -lvHeight);
	glColor3f(0, 1, 1);
	drawText(-lvWidth + 15, -lvTransY*lvZoom - 8, SBFONT, "+z");
	drawText(lvWidth - 50, -lvTransY*lvZoom - 8, SBFONT, "-z");
	drawText(-lvTransX*lvZoom, -lvHeight + 75, SBFONT, "+y");
	drawText(-lvTransX*lvZoom, lvHeight - 65, SBFONT, "-y");
	
    glColor3f(1, 1, 1);
	lvText(9, lvHeight-16, SBFONT, 0, "fstop %1.1f (aperture %1.1fmm) | "
		                              "object %1.1fmm | image %1.1fmm | mode: none", 
		                              0.,0.,0.,0.); 

	lvText(9, 8, SBFONT, 0, "F %1.1fmm | F' %1.1fmm | P %1.1fmm | "
		                    "P' %1.1fmm | exit pupil (%1.1fmm, %1.1fmm)", 
							0.,0.,0.,0.,0.,0.);
	glPopMatrix();
	glutSwapBuffers();
}
Ejemplo n.º 5
0
//处理无匹配区域
void FindRegionCorrespondence(const Mat& srcImg, const Mat& refImg, const vector<Point2i>& srcFeatures, const vector<Point2i>& refFeatures, const Mat& srcVisibility, const Mat& refVisibility,
	const vector<int>& srcLabels, const int& regionum, vector<int>& refLabels, string resultFolder)
{
	vector<vector<Point2f>> srcFeaturesTab(regionum);
	vector<vector<Point2f>> refFeaturesTab(regionum);
	int sz = srcFeatures.size();
	int width = srcImg.size().width;
	int height = srcImg.size().height;
	for (int i = 0; i < sz; ++i)
	{
		int index = srcFeatures[i].y * width + srcFeatures[i].x;
		int l = srcLabels[index];

		srcFeaturesTab[l].push_back(srcFeatures[i]);
		refFeaturesTab[l].push_back(refFeatures[i]);	
	}

	//保存无匹配区域
	vector<int> unmatchedIdx(0);
	for (int i = 0; i < regionum; ++i)
		if (srcFeaturesTab[i].size() == 0)
		{
			unmatchedIdx.push_back(i);
		}
	vector<vector<Point2f>> d_srcPointsTab(regionum);
	calPointsTab(srcLabels, width, height, d_srcPointsTab);
	
	string fn;
	Mat unmatchedMsk = Mat::zeros(height, width, CV_8UC1), unmatched;
	cout << "unmatched regions: " << endl;
	for (int i = 0; i < unmatchedIdx.size(); ++i)
	{
		int idx = unmatchedIdx[i];
		cout << idx << ' ';
		pointsToMask(d_srcPointsTab[idx], unmatchedMsk);
	}
	cout << endl;
	fn = resultFolder + "/unmatched_regions_mask.png";
	imwrite(fn, unmatchedMsk);
	srcImg.copyTo(unmatched, unmatchedMsk);
	fn = resultFolder + "/unmatched_regions.png";
	imwrite(fn, unmatched);
	

	//每个区域的像素点
	vector<vector<Point2f>> srcPointsTab(regionum);  //已知
	vector<vector<Point2f>> refPointsTab(regionum);  //未知
	calPointsTab(srcLabels, srcVisibility, srcPointsTab);   //每个区域只保留可见性为1的像素
	//calPointsTab(srcLabels, width, height, srcPointsTab);

	vector<Mat> transforms(regionum);
	vector<int> isMatched(regionum);
	computeTransforms(srcFeaturesTab, refFeaturesTab, transforms, isMatched);

	//deal with unmatched region
	//cout << endl << "copy with no-matched region." << endl;
	dealUnMatchedRegion(isMatched, transforms);
	//dealUnMatchedRegion(srcImg, srcPointsTab, srcFeaturesTab, srcLabels, isMatched, transforms);
	
	//apply transform to each region
	applyTransforms(srcPointsTab, transforms, isMatched, refPointsTab);

	//求解refLabels
	computeRefLabels(refPointsTab, width, height, refVisibility, refLabels);	
}
Ejemplo n.º 6
0
static void lvDisplay(void) {
    glClear(GL_COLOR_BUFFER_BIT);


    applyTransforms();


    glScalef(scale, scale, scale);
	glColor3f(0.25f, 0.25f, 0.25f);
	glLineWidth(2);
	drawLine(-lvWidth-lvTransX, 0, lvWidth-lvTransX, 0);
	drawLine(0, -lvHeight-lvTransY, 0, lvHeight-lvTransY);
	glLineWidth(1);

	lsystem.Draw();		

	// Draw image planes
	glColor3f(1.0, 0.0, 1.0);
	glLineWidth(2);
	drawLine(lsystem.iPlane, lsystem.maxAperture()/2, lsystem.iPlane, -lsystem.maxAperture()/2); 
	drawText(lsystem.iPlane - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "I");
	drawLine(zDist, lsystem.maxAperture()/2, zDist, -lsystem.maxAperture()/2);
	drawText(zDist - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "O");

	// Trace rays through lens system
	glColor3f(0.0, 0.0, 1.0);
	glLineWidth(1);
	
	for (int i = -9; i < 10; i++)
	{
        Ray rayv = Ray(Point(0, iPlaneY, lsystem.iPlane), Vector(0, lsystem.pupil.y/2 * (float) i/9 - iPlaneY, lsystem.pupil.z - lsystem.iPlane));
        Ray& rays = rayv;
        lsystem.Trace(rays, new Ray());
	}
	

	//lsystem.findExitPupil();
	//lsystem.recalAper();
	//lsystem.findF();
	//lsystem.findFp();
	//lsystem.refocus(zDist, -1);

	//Draw principal axes
	glColor3f(0.0, 1.0, 0.0);
	glLineWidth(2);
	drawLine(lsystem.pupil.z, lsystem.pupil.y/2, lsystem.pupil.z, (lsystem.pupil.y+lsystem.maxAperture()) / 2);
	drawLine(lsystem.pupil.z, -lsystem.pupil.y/2, lsystem.pupil.z, (-lsystem.pupil.y-lsystem.maxAperture()) / 2);
	drawText(lsystem.pupil.z, (-lsystem.pupil.y-lsystem.maxAperture()) / 2 - 5, SBFONT, "ep");

	//Draw principal axes
	glColor3f(1.0, 0.0, 0.0);
	glLineWidth(2);
	drawLine(lsystem.p2, lsystem.maxAperture()/2, lsystem.p2, -lsystem.maxAperture()/2);
	drawText(lsystem.p2 - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "P'");
	drawLine(lsystem.p1, lsystem.maxAperture()/2, lsystem.p1, -lsystem.maxAperture()/2);
	drawText(lsystem.p1 - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "P");

	//Draw focal planes
	glColor3f(1.0, 1.0, 0.0);
	drawPoint(5, lsystem.f1, 0);
	drawText(lsystem.f1 - 1, -5, SBFONT, "F");
	drawPoint(5, lsystem.f2, 0);
	drawText(lsystem.f2 - 1, -5, SBFONT, "F'");
	
	glMatrixMode(GL_PROJECTION); glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, lvWidth, lvHeight, 0);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    drawSquare(0.25f, 0.25f, 0.25f, 0, 0, lvWidth, BARH);
	drawSquare(0.25f, 0.25f, 0.25f, 0, lvHeight, lvWidth, lvHeight-BARH);
	glLoadIdentity();

	gluOrtho2D(-lvWidth, lvWidth, lvHeight, -lvHeight);
	glColor3f(0, 1, 1);
	drawText(-lvWidth + 15, -lvTransY*lvZoom - 8, SBFONT, "+z");
	drawText(lvWidth - 50, -lvTransY*lvZoom - 8, SBFONT, "-z");
	drawText(-lvTransX*lvZoom, -lvHeight + 75, SBFONT, "+y");
	drawText(-lvTransX*lvZoom, lvHeight - 65, SBFONT, "-y");
	
    glColor3f(1, 1, 1);
    const char* mode = lsystem.M == precise ? "precise" : "thick";
	lvText(9, lvHeight-16, SBFONT, 0, "fstop %1.1f (aperture %1.1fmm) | "
		                              "object %1.1fmm | image %1.1fmm | mode: %s", 
									  lsystem.fstop,lsystem.getAperture()->aper,zDist,lsystem.iPlane, mode); 

	lvText(9, 8, SBFONT, 0, "F %1.1fmm | F' %1.1fmm | P %1.1fmm | "
		                    "P' %1.1fmm | exit pupil (%1.1fmm, %1.1fmm)", 
							lsystem.f1,lsystem.f2,lsystem.p1,lsystem.p2,lsystem.pupil.z,lsystem.pupil.y);

	glPopMatrix();
	glutSwapBuffers();
}