Esempio n. 1
0
void MainWindow::actionFps(){
    QAction *action = (QAction*)sender();

    setFps(action->property("fps").toInt());

    updateFps();
}
Esempio n. 2
0
void MainView::paintEvent (QPaintEvent *event)
{
    if (m_imageBasedRendering) {
        if (!m_pixmapToRender)
            m_pixmapToRender = new QPixmap(size());

        if (m_pixmapToRender->size() != size()) {
            delete m_pixmapToRender;
            m_pixmapToRender = new QPixmap(size());
        }
        QPainter p(m_pixmapToRender);
        render(&p);
        p.end();
    }
    else {
        QGraphicsView::paintEvent(event);
    }

    if (!m_OutputFps)
        emit repainted();

    m_frameCount++;
    m_fpsLatestTs.start();
    if(m_fpsUpdated.elapsed() > 2000) {
        updateFps();
        m_fpsUpdated.start();
    }
}
Esempio n. 3
0
VideoItem::VideoItem()
{
    core = new Core();

    texture = nullptr;
    m_libcore = "";
    m_stretch_video = false;
    m_filtering = 2;
    m_aspect_ratio = 0.0;
    m_fps = 0;

    audio = new Audio();
    Q_CHECK_PTR(audio);
    audio->start();
    core->audio_buf = audio->abuf();
    m_volume = 1.0;

    connect(&fps_timer, SIGNAL(timeout()), this, SLOT(updateFps()));
    frame_timer.invalidate();
    fps_deviation = 0;
    fps_count = 0;

    connect(this, SIGNAL(runChanged(bool)), audio, SLOT(runChanged(bool)));
    connect(this, SIGNAL(volumeChanged(qreal)), audio, SLOT(setVolume(qreal)));
    connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
}
Esempio n. 4
0
Game::Game(QGLWidget *parent) :
    QGLWidget(parent)
{
    this->mainTimer = new QTimer( this );
    connect( mainTimer, SIGNAL(timeout()), this, SLOT(animate()) );
    connect( mainTimer, SIGNAL(timeout()), this, SLOT(updatePsychics()) );
    mainTimer->start( 8 );

    this->fpsTimer = new QTimer( this );
    connect( fpsTimer, SIGNAL(timeout()), this, SLOT(updateFps()) );
    fpsTimer->start(1000);

    this->titleTextTimer = new QTimer( this );
    connect( titleTextTimer, SIGNAL(timeout()), this, SLOT(hideTitleText()) );

    titleFont.setBold(true);
    titleFont.setFamily("arial");
    titleFont.setPixelSize(30);
    titleText = "";

    cristalFont.setBold(true);
    cristalFont.setFamily("arial");
    cristalFont.setPixelSize(15);

    fps = frames = 0;
    currentLevel = 0;
}
 void VideoCaptureDisplay::onInitialize()
 {
   updateFileName();
   updateFps();
   //updateStartCapture();
   start_capture_property_->setBool(false); // always false when starting up
   context_->queueRender();
 }
void RiftRenderingApp::drawRiftFrame() {
  ++frameCount;
  ovrHmd_BeginFrame(hmd, frameCount);
  MatrixStack & mv = Stacks::modelview();
  MatrixStack & pr = Stacks::projection();

  perFrameRender();
  
  ovrPosef fetchPoses[2];
  ovrHmd_GetEyePoses(hmd, frameCount, eyeOffsets, fetchPoses, nullptr);
  for (int i = 0; i < 2; ++i) {
    ovrEyeType eye = currentEye = hmd->EyeRenderOrder[i];
    // Force us to alternate eyes if we aren't keeping up with the required framerate
    if (eye == lastEyeRendered) {
      continue;
    }
    // We want to ensure that we only update the pose we 
    // send to the SDK if we actually render this eye.
    eyePoses[eye] = fetchPoses[eye];

    lastEyeRendered = eye;
    Stacks::withPush(pr, mv, [&] {
      // Set up the per-eye projection matrix
      pr.top() = projections[eye];

      // Set up the per-eye modelview matrix
      // Apply the head pose
      glm::mat4 eyePose = ovr::toGlm(eyePoses[eye]);
      mv.preMultiply(glm::inverse(eyePose));

      // Render the scene to an offscreen buffer
      eyeFramebuffers[eye]->Bind();
      perEyeRender();
    });
    
    if (eyePerFrameMode) {
      break;
    }
  }

  if (endFrameLock) {
    endFrameLock->lock();
  }
  ovrHmd_EndFrame(hmd, eyePoses, eyeTextures);
  if (endFrameLock) {
    endFrameLock->unlock();
  }
  rateCounter.increment();
  if (rateCounter.elapsed() > 2.0f) {
    float fps = rateCounter.getRate();
    updateFps(fps);
    rateCounter.reset();
  }
}
Esempio n. 7
0
 void GuiInfoAdder::addInfo(cv::Mat& cvOutputData, const int numberPeople, const unsigned long long id,
                            const std::string& elementRenderedName, const unsigned long long frameNumber,
                            const Array<long long>& poseIds, const Array<float>& poseKeypoints)
 {
     try
     {
         // Sanity check
         if (cvOutputData.empty())
             error("Wrong input element (empty cvOutputData).", __LINE__, __FUNCTION__, __FILE__);
         // Size
         const auto borderMargin = intRound(fastMax(cvOutputData.cols, cvOutputData.rows) * 0.025);
         // Update fps
         updateFps(mLastId, mFps, mFpsCounter, mFpsQueue, id, mNumberGpus);
         // Fps or s/gpu
         char charArrayAux[15];
         std::snprintf(charArrayAux, 15, "%4.1f fps", mFps);
         // Recording inverse: sec/gpu
         // std::snprintf(charArrayAux, 15, "%4.2f s/gpu", (mFps != 0. ? mNumberGpus/mFps : 0.));
         putTextOnCvMat(cvOutputData, charArrayAux, {intRound(cvOutputData.cols - borderMargin), borderMargin},
                        WHITE_SCALAR, true, cvOutputData.cols);
         // Part to show
         // Allowing some buffer when changing the part to show (if >= 2 GPUs)
         // I.e. one GPU might return a previous part after the other GPU returns the new desired part, it looks
         // like a mini-bug on screen
         // Difference between Titan X (~110 ms) & 1050 Ti (~290ms)
         if (mNumberGpus == 1 || (elementRenderedName != mLastElementRenderedName
                                  && mLastElementRenderedCounter > 4))
         {
             mLastElementRenderedName = elementRenderedName;
             mLastElementRenderedCounter = 0;
         }
         mLastElementRenderedCounter = fastMin(mLastElementRenderedCounter, std::numeric_limits<int>::max() - 5);
         mLastElementRenderedCounter++;
         // Add each person ID
         addPeopleIds(cvOutputData, poseIds, poseKeypoints, borderMargin);
         // OpenPose name as well as help or part to show
         putTextOnCvMat(cvOutputData, "OpenPose - " +
                        (!mLastElementRenderedName.empty() ?
                             mLastElementRenderedName : (mGuiEnabled ? "'h' for help" : "")),
                        {borderMargin, borderMargin}, WHITE_SCALAR, false, cvOutputData.cols);
         // Frame number
         putTextOnCvMat(cvOutputData, "Frame: " + std::to_string(frameNumber),
                        {borderMargin, (int)(cvOutputData.rows - borderMargin)}, WHITE_SCALAR, false, cvOutputData.cols);
         // Number people
         putTextOnCvMat(cvOutputData, "People: " + std::to_string(numberPeople),
                        {(int)(cvOutputData.cols - borderMargin), (int)(cvOutputData.rows - borderMargin)},
                        WHITE_SCALAR, true, cvOutputData.cols);
     }
     catch (const std::exception& e)
     {
         error(e.what(), __LINE__, __FUNCTION__, __FILE__);
     }
 }
Esempio n. 8
0
void MainWindow::loadSettings(){
    setFullScreen(false);
    setHideMenu(false);

    QSettings settingsNative;

    resize(settingsNative.value("size", QSize(320, 480 + ui.menuBar->height())).toSize());
    move(settingsNative.value("pos",    QPoint(0, 0)).toPoint());

    int red = settingsNative.value("backgroundRed",     240).toInt();
    int green = settingsNative.value("backgroundGreen", 240).toInt();
    int blue = settingsNative.value("backgroundBlue",   240).toInt();
    QColor backgroundColor = QColor(red, green, blue);

    red = settingsNative.value("canvasRed",     255).toInt();
    green = settingsNative.value("canvasGreen", 255).toInt();
    blue = settingsNative.value("canvasBlue",   255).toInt();
    QColor canvasColor = QColor(red, green, blue);

    red = settingsNative.value("infoRed",     0).toInt();
    green = settingsNative.value("infoGreen", 0).toInt();
    blue = settingsNative.value("infoBlue",   0).toInt();
    QColor infoColor = QColor(red, green, blue);

    setBackgroundColor(backgroundColor);
    setCanvasColor(canvasColor);
    setInfoColor(infoColor);

    updateBackgroundColor();
    updateCanvasColor();
    updateInfoColor();

    QSettings settings(Constants::SETTINGS_FOLDER + "/" + Constants::PLAYER_SETTINGS_FILE, QSettings::IniFormat);

    setWidth(settings.value("width",             320).toInt());
    setHeight(settings.value("height",           480).toInt());
    setScale(settings.value("scale",             100).toInt());
    setFps(settings.value("fps",                 60).toInt());
    setOrientation(static_cast<Orientation>(settings.value("orientation", ePortrait).toInt()));
    setDrawInfos(settings.value("drawInfos",     false).toBool());
    setAutoScale(settings.value("autoScale",     false).toBool());
    setAlwaysOnTop(settings.value("alwaysOnTop", false).toBool());

    checkLoadedSettings();

    updateFps();
    updateDrawInfos();
    updateAlwaysOnTop();
    updateAutoScale();
    updateOrientation();
    updateResolution();
}
void QtOpenCVZedDemo::timerEvent(QTimerEvent *event)
{    
    Q_UNUSED(event);

    updateFps( mElabTime.elapsed() );
    mElabTime.restart();

    cv::Mat image;
    mCapture >> image;

    if( mFlipVert && mFlipHoriz )
        cv::flip( image,image, -1);
    else if( mFlipVert )
        cv::flip( image,image, 0);
    else if( mFlipHoriz )
        cv::flip( image,image, 1);

    // Do what you want with the image :-)
    int w = image.cols/2;
    int h = image.rows;

    cv::Rect lRect( 0,0,w,h );
    cv::Rect rRect( w,0,w,h );

    cv::Mat left = image(lRect);
    cv::Mat right = image(rRect);

    ui->graphicsView_left->setScene( &mLeft );

    // Show the image
    mLeft.setBgImage( left );
    mRight.setBgImage( right );

    if( ui->tabWidget->currentIndex() == 0 )
    {
        doStereoSGBM_CPU( left, right );
    }
    else if( ui->tabWidget->currentIndex() == 1 )
    {
        // TODO Cuda processing
    }
    else if( ui->tabWidget->currentIndex() == 2 )
    {
#ifndef Q_PROCESSOR_ARM
        doStereoSBM_OCL(left, right );
        //doStereoCSBP_OCL( left, right );
        //doStereoBP_OCL(left,right);
#endif
    }

    mDisp.setBgImage( mDisparity );
}
 VideoCaptureDisplay::VideoCaptureDisplay():
   Display(), capturing_(false), first_time_(true)
 {
   start_capture_property_ = new rviz::BoolProperty(
     "start capture", false, "start capture",
     this, SLOT(updateStartCapture()));
   file_name_property_ = new rviz::StringProperty(
     "filename", "output.avi",
     "filename", this, SLOT(updateFileName()));
   fps_property_ = new rviz::FloatProperty(
     "fps", 30.0,
     "fps", this, SLOT(updateFps()));
   fps_property_->setMin(0.1);
 }
Esempio n. 11
0
    void Game::runStep(float dt)
    {
        appTime_ += dt;
        time_ += dt;
        
        updateFps();
        step(float(dt));
        updateCamera();

        SDL_GL_SwapWindow(window_);
        glClearColor(double(0x66) / 255.0, double(0x55) / 255.0, double(0x44) / 255.0, 0.0);
        glClear(GL_COLOR_BUFFER_BIT);
        graphicsManager_->draw();
    }
Esempio n. 12
0
qreal MainView::fps()
{
    if (m_Fpss.count() <= 0)
        updateFps();

    if (m_Fpss.count() <= 0)
        return 0.0;

    qreal sum = 0;
    int count = m_Fpss.count();
    for (int i = 0; i<count; ++i)
        sum += m_Fpss.at(i);
    m_Fpss.clear();
    fpsReset();
    return sum/qreal(count);
}
Esempio n. 13
0
    void GuiInfoAdder::addInfo(cv::Mat& cvOutputData, const Array<float>& poseKeypoints, const unsigned long long id, const std::string& elementRenderedName)
    {
        try
        {
            // Security checks
            if (cvOutputData.empty())
                error("Wrong input element (empty cvOutputData).", __LINE__, __FUNCTION__, __FILE__);

            // Update fps
            updateFps(mLastId, mFps, mFpsCounter, mFpsQueue, id, mNumberGpus);

            // Used colors
            const cv::Scalar white{255, 255, 255};
            // Fps or s/gpu
            char charArrayAux[15];
            std::snprintf(charArrayAux, 15, "%4.1f fps", mFps);
            // Recording inverse: sec/gpu
            // std::snprintf(charArrayAux, 15, "%4.2f s/gpu", (mFps != 0. ? mNumberGpus/mFps : 0.));
            putTextOnCvMat(cvOutputData, charArrayAux, {mBorderMargin,mBorderMargin}, white, false);
            // Part to show
            // Allowing some buffer when changing the part to show (if >= 2 GPUs)
            // I.e. one GPU might return a previous part after the other GPU returns the new desired part, it looks like a mini-bug on screen
            // Difference between Titan X (~110 ms) & 1050 Ti (~290ms)
            if (mNumberGpus == 1 || (elementRenderedName != mLastElementRenderedName && mLastElementRenderedCounter > 4))
            {
                mLastElementRenderedName = elementRenderedName;
                mLastElementRenderedCounter = 0;
            }
            mLastElementRenderedCounter = fastMin(mLastElementRenderedCounter, std::numeric_limits<int>::max() - 5);
            mLastElementRenderedCounter++;
            // Display element to display or help
            std::string message = (!mLastElementRenderedName.empty() ? mLastElementRenderedName : (mGuiEnabled ? "'h' for help" : ""));
            if (!message.empty())
                putTextOnCvMat(cvOutputData, message, {intRound(mOutputSize.x - mBorderMargin), mBorderMargin}, white, true);
            // Frame number
            putTextOnCvMat(cvOutputData, "Frame " + std::to_string(id), {mBorderMargin, (int)(mOutputSize.y - mBorderMargin)}, white, false);
            // Number people
            const auto textToDisplay = std::to_string(poseKeypoints.getSize(0)) + " people";
            putTextOnCvMat(cvOutputData, textToDisplay, {(int)(mOutputSize.x - mBorderMargin), (int)(mOutputSize.y - mBorderMargin)}, white, true);
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
        }
    }
Esempio n. 14
0
LRESULT CALLBACK WndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HDC dstDc;
    PAINTSTRUCT paintInfo;
    BOOL result;

    switch (msg)
    {
    case WM_CREATE:
        if (initFrameBuffer())
            return -1;

        if (!SetTimer(window, SCREEN_UPDATE_TIMER_ID, USER_TIMER_MINIMUM, NULL))
        {
            reportSysError(_T("Failed to create the display update timer."));
            return -1;
        }

        break;
    case WM_DESTROY:
        deinitialize();
        PostQuitMessage(exitCode);
        break;
    case WM_KEYDOWN:
        if (wParam == VK_ESCAPE)
            DestroyWindow(window);
        break;
    case WM_TIMER:
        InvalidateRect(window, NULL, FALSE);
        break;
    case WM_PAINT:
        dstDc = BeginPaint(window, &paintInfo);
        updateScreen();
        BitBlt(dstDc, - (int) bufOffset, 0, WIDTH, HEIGHT, bufDc, 0, 0, SRCCOPY);
        EndPaint(window, &paintInfo);
        updateFps();

        break;
    default:
        return DefWindowProc(window, msg, wParam, lParam);
    }

    return 0;
}
Esempio n. 15
0
void DebugMetricsMonitor::update() {
    // Engine::UPDATE_FREQUENCY should be in line with rendering frame rate

    mFpsCounterCount++;
    if (mFpsCounterTimer.elapsed() > mFpsAverageWindowSizeMs) {
        int intervalMillis = mFpsCounterTimer.restart();
        mFps = mFpsCounterCount * mFpsAverageWindowSizeMs / (float) intervalMillis;
        mFpsCounterCount = 0;
    }
    mInstantFps = 1000.0f / mInstantFpsCounterTimer.restart();

    if (mFpsRefreshTime.elapsed() >= mFpsRefreshIntervalMs) {
        updateFps();
        mFpsRefreshTime.restart();
    }
    if (mMemoryUsageRefreshTime.elapsed() >= mMemoryUsageRefreshIntervalMs) {
        updateMemoryUsage();
        mMemoryUsageRefreshTime.restart();
    }
}
Esempio n. 16
0
ScreenProvider::ScreenProvider(QObject* parent): QTcpServer(parent)
{
    streaming_ = false;
    orientation_ = QOrientationReading::TopUp;
    struct fb_var_screeninfo var;
    struct fb_fix_screeninfo fix;

    framebufferinfo_.fbmmap = (char*)MAP_FAILED;
    framebufferinfo_.scrinfo = var;
    framebufferinfo_.fix_scrinfo = fix;
    framebufferinfo_.fps = 0.0;
    framebufferinfo_.compression = 50;

    fpstimer_.setInterval(1000);
    connect(&fpstimer_, SIGNAL(timeout()), this, SLOT(updateFps()));
    connect(this, SIGNAL(clientConnected()), this, SLOT(onClientConnected()));

    if ((fbDevice_ = open("/dev/fb0", O_RDONLY)) == -1)
    {
        return;
    }

    if (ioctl(fbDevice_, FBIOGET_FSCREENINFO, &framebufferinfo_.fix_scrinfo) != 0){
        return;
    }

    if (ioctl(fbDevice_, FBIOGET_VSCREENINFO, &framebufferinfo_.scrinfo) != 0){
        return;
    }

    framebufferinfo_.fbmmap = (unsigned int*)mmap(NULL,
                                                  framebufferinfo_.fix_scrinfo.smem_len,
                                                  PROT_READ,
                                                  MAP_SHARED,
                                                  fbDevice_,
                                                  0);

    if ((char*)framebufferinfo_.fbmmap == MAP_FAILED){
        return;
    }
}
Esempio n. 17
0
int main() {

	if (!glfwInit()) {
		fprintf(stderr, "Failed to initialize GLFWn");
		return -1;
	}

	GLFWwindow* window = glfwCreateWindow(800, 600, "My Title", NULL, NULL);
	glfwMakeContextCurrent(window);

	// glewInit must be called after glfwMakeContextCurrent
	if (glewInit() != GLEW_OK) {
		fprintf(stderr, "Failed to initialize GLEWn");
		return -1;
	}

	glfwSetKeyCallback(window, keyCallback);
	glfwSetWindowSizeCallback(window, sizeChangedCallback);
	glfwSetWindowCloseCallback(window, destoryCallback);
	renderInit(window);

	double lasttime = glfwGetTime();

	while (!glfwWindowShouldClose(window))
	{
		double nowtime = glfwGetTime();
		render(window, (nowtime - lasttime)/100);
		lasttime = nowtime;

		updateFps();

		glfwSwapBuffers(window);
		glfwPollEvents();
	}
	return 0;
}
Esempio n. 18
0
	void DebugWindow::run(Ogre::Real elapsedTime)
	{
		updateFps();
	}