コード例 #1
0
ファイル: GuiComboControls.cpp プロジェクト: Jiaheng3/GacUI
			void GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments)
			{
				Size expectedSize(0, GetFont().size * 20);
				Size adoptedSize = containedListControl->GetAdoptedSize(expectedSize);

				Size clientSize = GetPreferredMenuClientSize();
				clientSize.y = adoptedSize.y + GetSubMenu()->GetClientSize().y - containedListControl->GetBoundsComposition()->GetBounds().Height();
				SetPreferredMenuClientSize(clientSize);

				if (GetSubMenuOpening())
				{
					GetSubMenu()->SetClientSize(clientSize);
				}
			}
コード例 #2
0
ファイル: SlamDriver.cpp プロジェクト: meiroo/dtslam
// Initialization for this application
bool SlamDriver::init(void)
{
    std::cout << "SlamDriver init." << std::endl;
	
#ifdef ENABLE_LOG
	std::cout << "Logging is enabled. This severely hits performance! It can be disabled in dtslam/log.h." << std::endl;
#else
	std::cout << "Logging is disabled. See dtslam/log.h to enable it." << std::endl;
#endif

#ifdef ENABLE_PROFILER
	std::cout << "Profiling is enabled.\n";
#else
	std::cout << "Profiling is disabled. See dtslam/Profiler.h to enable it.\n";
#endif

    Profiler::Instance().setCurrentThreadName("render");
    char glogstr[] = "dtslam";

    google::InitGoogleLogging(glogstr);

    if (!initImageSrc())
    {
    	DTSLAM_LOG << "Couldn't initialize image source.\n";
        return false;
    }

    // Initialize Shader
    if (!mShaders.init())
    {
		DTSLAM_LOG << "Couldn't initialize shaders.\n";
		return false;
    }

	//Determine downscale at input
	int width = mImageSrc->getSourceSize().width;
	mDownsampleInputCount = 0;
	while(width > FLAGS_DriverMaxImageWidth)
	{
		width = (width+1)/2;
		mDownsampleInputCount++;
	}
	int scale = 1<<mDownsampleInputCount;

	mImageSrc->setDownsample(mDownsampleInputCount);
	mImageSize = mImageSrc->getSize();
	DTSLAM_LOG << "Input image size after downsampling: " << mImageSize << "\n";

	//Check size vs calibration
	cv::Size expectedSize(FLAGS_CameraWidth/scale, FLAGS_CameraHeight/scale);
	if(mImageSize.width != expectedSize.width || mImageSize.height != expectedSize.height)
	{
		DTSLAM_LOG << "Warning: image size " << mImageSize << " does not match calibration size " << expectedSize << "\n";
	}

	//Get first frame
	if(!mImageSrc->update())
    {
    	DTSLAM_LOG << "Couldn't get first frame from image source.\n";
    	return false;
    }

    //Init camera
	mCamera.reset(new CameraModel());
	mCamera->init((float)FLAGS_CameraFx / scale, (float)FLAGS_CameraFy / scale, (float)FLAGS_CameraU0 / scale, (float)FLAGS_CameraV0 / scale, FLAGS_CameraWidth / scale, FLAGS_CameraHeight / scale);
	mCamera->getDistortionModel().init((float)FLAGS_CameraK1, (float)FLAGS_CameraK2);
	mCamera->getDistortionModel().setMaxRadius(mCamera->getMaxRadiusSq(mImageSize));
	mCamera->initLUT();

	//Slam system
	cv::Mat1b imageGray = mImageSrc->getImgGray();
	cv::Mat3b imageColor = mImageSrc->getImgColor();
	mSlam.init(mCamera.get(), mImageSrc->getCaptureTime(), imageColor, imageGray);
	mSlam.setSingleThreaded(FLAGS_DriverSingleThreaded);

	//Add windows
	mWindows.push_back(std::unique_ptr<BaseWindow>(new MatchesWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new MapExpanderWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new MapWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new KeyFramePairWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new ARWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new TestMatchWindow()));
	mWindows.push_back(std::unique_ptr<BaseWindow>(new FrameLinkWindow()));

	//Add bindings
	mKeyBindings.addBinding(true,GLUT_KEY_F5,static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::runVideo),"Run the video stream.");
	mKeyBindings.addBinding(true, GLUT_KEY_F8, static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::saveMap), "Save the map to disk.");
	mKeyBindings.addBinding(true, GLUT_KEY_F9, static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::loadMap), "Load the map from disk.");
	mKeyBindings.addBinding(false, ' ', static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::stepVideo), "Advance one frame.");
	mKeyBindings.addBinding(false,'p',static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::toggleProfilerMode),"Toggle profiler mode.");
	mKeyBindings.addBinding(false,'P',static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::resetProfiler),"Reset profiler counts.");
	mKeyBindings.addBinding(false,'r',static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::resetSystem),"Reset the slam system.");
	mKeyBindings.addBinding(false,'R',static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::startRecording),"Reset and start recording.");
	mKeyBindings.addBinding(true,GLUT_KEY_F1,static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::resyncTracker),"Resyncs the tracker with/without 2D matches.");

	for(int i=0; i<(int)mWindows.size(); ++i)
		mKeyBindings.addBinding(false,i+'1',static_cast<KeyBindingHandler<SlamDriver>::BindingFunc>(&SlamDriver::changeWindowKey),"Show window: " + mWindows[i]->getName());

	mKeyBindings.addBinding(false,27,static_cast<KeyBindingHandler<SlamDriver>::SimpleBindingFunc>(&SlamDriver::escapePressed),"Quit.");

	DTSLAM_LOG << "\nBasic keys:\n";
	mKeyBindings.showHelp();

	setActiveWindow(mWindows[0].get());

	setARCube(cv::Point3f(0, 0,10), cv::Point3f(0.1, 0, 0), cv::Point3f(0, 0.1, 0), cv::Point3f(0, 0, 0.1));
	//disableARCube();

    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_LINE_SMOOTH);

	mFPS = 0;
	mLastFPSCheck = std::chrono::high_resolution_clock::now();
	mFPSUpdateDuration = std::chrono::duration_cast<std::chrono::high_resolution_clock::duration>(std::chrono::seconds(1));
	mFPSSampleAccum = std::chrono::high_resolution_clock::duration(0);
	mFPSSampleCount = 0;

	mInitialized = true;
    return true;
}
コード例 #3
0
ファイル: tpointatten.cpp プロジェクト: chrisforbes/piglit
bool
PointAttenuationTest::testPointRendering(GLboolean smooth)
{
	// epsilon is the allowed size difference in pixels between the
	// expected and actual rendering.
	const GLfloat epsilon = (smooth ? 1.5 : 1.0) + 0.0;
	GLfloat atten[3];
	int count = 0;

	// Enable front buffer if you want to see the rendering
	glDrawBuffer(GL_FRONT);
	glReadBuffer(GL_FRONT);

	if (smooth) {
		glEnable(GL_POINT_SMOOTH);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	else {
		glDisable(GL_POINT_SMOOTH);
		glDisable(GL_BLEND);
	}

	for (int a = 0; a < 3; a++) {
		atten[0] = pow(10.0, -a);
		for (int b = -2; b < 3; b++) {
			atten[1] = (b == -1) ? 0.0 : pow(10.0, -b);
			for (int c = -2; c < 3; c++) {
				atten[2] = (c == -1) ? 0.0 : pow(10.0, -c);
				PointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, atten);
				for (float min = 1.0; min < MAX_SIZE; min += 10) {
					PointParameterfARB(GL_POINT_SIZE_MIN_ARB, min);
					for (float max = min; max < MAX_SIZE; max += 10) {
						PointParameterfARB(GL_POINT_SIZE_MAX_ARB, max);
						for (float size = 1.0; size < MAX_SIZE; size += 8) {
							glPointSize(size);

							// draw column of points
							glClear(GL_COLOR_BUFFER_BIT);
							glBegin(GL_POINTS);
							for (float z = -6.0; z <= 6.0; z += 1.0) {
								glVertex3f(0, z, z);
							}
							glEnd();

							// test the column of points
							for (float z = -6.0; z <= 6.0; z += 1.0) {
								count++;
								float expected
									= expectedSize(size, atten, min, max,
												   z, smooth);
								float actual = measureSize(z);
								if (fabs(expected - actual) > epsilon) {
									reportFailure(size, atten, min, max,
												  z, smooth,
												  expected, actual);
									return false;
								}
								else if(0){
									printf("pass z=%f exp=%f act=%f\n",
										   z, expected, actual);
								}
							}
						}
					}
				}
			}
		}
	}
	reportSuccess(count, smooth);
	return true;
}