Пример #1
0
void SyntroLCamConsole::stopVideo()
{
    if (m_camera) {
        disconnect(m_camera, SIGNAL(newJPEG(QByteArray)), m_client, SLOT(newJPEG(QByteArray)));

        disconnect(m_camera, SIGNAL(cameraState(QString)), this, SLOT(cameraState(QString)));
        disconnect(m_camera, SIGNAL(videoFormat(int,int,int)), this, SLOT(videoFormat(int,int,int)));
        disconnect(m_camera, SIGNAL(videoFormat(int,int,int)), m_client, SLOT(videoFormat(int,int,int)));

        m_camera->exitThread();
        m_camera = NULL;
    }
}
    void MobileExampleApp::Draw (float dt)
    {
        Eegeo::EegeoWorld& eegeoWorld = World();

        Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsModule = eegeoWorld.GetMapModule().GetInteriorsPresentationModule();
        Eegeo::Resources::Interiors::Camera::InteriorsCameraController& interiorsCameraController = interiorsModule.GetCameraController();
        
        Eegeo::Camera::CameraState cameraState(interiorsCameraController.IsEnabled()
                                               ? interiorsCameraController.GetCameraState()
                                               : m_pGlobeCameraController->GetCameraState());
        Eegeo::Camera::RenderCamera renderCamera(interiorsCameraController.IsEnabled()
                                                 ? interiorsCameraController.GetRenderCamera()
                                                 : m_pGlobeCameraController->GetRenderCamera());
        Eegeo::dv3 ecefInterestPoint(cameraState.InterestPointEcef());

        if(!eegeoWorld.Initialising())
        {
            WorldPinsModule().GetWorldPinsInFocusController().Update(dt, ecefInterestPoint, renderCamera);
        }

        Eegeo::EegeoDrawParameters drawParameters(cameraState.LocationEcef(),
                cameraState.InterestPointEcef(),
                cameraState.ViewMatrix(),
                cameraState.ProjectionMatrix(),
                m_screenProperties);

        eegeoWorld.Draw(drawParameters);

        if (m_pLoadingScreen != NULL)
        {
            m_pLoadingScreen->Draw();
        }
    }
Пример #3
0
void LadybugWidget::navigationMousePress(QMouseEvent* e)
{
  QRect arrowRect = QRect(QPoint(-5, 0), QPoint(5, -10));

  QPoint centerPt = NAVIGATION_RECT.center();
  QMatrix m;
  m.translate(centerPt.x(), centerPt.y());

  for (int i = 0; i < 5; i++)
  {
    QMatrix m2 = m;
    m2.rotate(i*360/5);
    m2.translate(0,-16);

    QPoint resPt = m2.inverted().map(e->pos());
    if (arrowRect.contains(resPt))
    {
      // invert camera on/off setting
      setCameraState(i, !cameraState(i));

      if (mPaused)
        updateVideo(getSingleFrame(mCurrentFrame));
    }
  }
}
Пример #4
0
LadybugPlayerFrame LadybugWidget::getSingleFrame(int frameId)
{

  LadybugImage image;
  // go to the frame
  mStream.seekToFrame(frameId);
  // fetch the frame
  bool res = mStream.readNextFrame(image);

  if (!res)
  {
    LadybugPlayerFrame invalidFrame;
    invalidFrame.frameId = -1;
    return invalidFrame;
  }

  LadybugPlayerFrame playerFrame;
  playerFrame.frameId = mStream.currentFrame();
  playerFrame.time = image.time();

  // decode images
  for (int c = 0; c < 6; c++)
  {
    int pow_scale = (cameraZoom(c) > 1 ? 0 : 1);

    if (cameraState(c))
      playerFrame.imgs[c] = image.getColorImage(c, true, pow_scale);
    else
      playerFrame.imgs[c] = QImage();
  }

  return playerFrame;
}
bool ModifiedRenderingExample::IsToBeReplacedWithAlternative(const TSceneElement* pSceneElement)  const
{
	const TRenderable& renderable = pSceneElement->GetResource();

	if(!renderable.GetMaterial()->GetName().compare(Eegeo::Rendering::MaterialNames::Buildings))
	{
		const double filterRadius = 400.0f;
		const double filterRadiusSq = filterRadius*filterRadius;
        
        Eegeo::Camera::CameraState cameraState(GetCurrentCameraState());
        
		Eegeo::v3 cameraRelativePos = Eegeo::Camera::CameraHelpers::CameraRelativePoint(renderable.GetEcefPosition(),
                                                                                        cameraState.InterestPointEcef());

		double delta = cameraRelativePos.LengthSq();
		bool closeToInterest = delta < filterRadiusSq;

		if (closeToInterest)
		{
			return true;
		}
	}

	return false;
}
Пример #6
0
void LadybugWidget::paintEvent(QPaintEvent* /* event */)
{
  QPainter p(this);

  if (!mHasImage)
  {
    p.drawLine(0,0, width(), height());
    p.drawLine(width(),0, 0, height());
    return;
  }

  QRect srcRect;
  int x = 0;
  p.save();
  p.translate(100,1);
  for (int c = 0; c < CAMERAS; c++)
  {
    int cam = (c+3) % CAMERAS;
    if (cam == 5) // top cam - skip
      continue;

    if (cameraState(cam))
    {
      QColor color = QColor::fromHsv(cam*72, 255,255);
      p.setPen(QPen(color, PEN_WIDTH));

      p.drawRect(x,0, IMG_WIDTH + PEN_WIDTH, IMG_HEIGHT + PEN_WIDTH);
      QPointF offset;
      double zoom = cameraZoom(cam, &offset);
      printf("draw: zoom %.2f -- off %.1f,%.1f -- %.1f x %.1f\n", zoom, offset.x(), offset.y(), IMG_WIDTH/zoom, IMG_HEIGHT/zoom);

      // prepare source rectangle - usually a window from the image
      // additionally image can be scaled for better details when zoomed in
      int imgScale = mImgs[cam].width() / IMG_WIDTH;
      QSize imgSize = QSize(IMG_WIDTH/zoom, IMG_HEIGHT/zoom) * imgScale;
      QPoint imgOffset = offset.toPoint() * imgScale;
      srcRect = QRect(imgOffset, imgSize);

      p.drawImage(QRect(x+PEN_WIDTH/2, PEN_WIDTH/2, IMG_WIDTH, IMG_HEIGHT), mImgs[cam], srcRect);
      x += IMG_WIDTH + PEN_WIDTH*3;
    }
  }
  p.restore();

  // draw info
  drawNavigation(p);

  p.setPen(QColor(255,0,0));

  p.drawText(20,120, QString("%1 / %2").arg(mCurrentFrame).arg(mStream.framesCount()) );
  p.drawText(20,140, QString::number((mCurrentTime-mStartTime)/1000.0, 'f', 3) + " s");
}
Пример #7
0
QRect LadybugWidget::cameraRect(int camRequested)
{
  if (!cameraState(camRequested))
    return QRect();

  QPoint topleft = QPoint(100,1) + QPoint(PEN_WIDTH/2,PEN_WIDTH/2);

  for (int c = 0; c < CAMERAS; c++)
  {
    int cam = (c+3) % CAMERAS;
    if (cam == 5) // top cam - skip
      continue;

    if (cam == camRequested) // we're done!
      break;

    if (cameraState(cam))
      topleft += QPoint(IMG_WIDTH + PEN_WIDTH*3, 0);
  }

  return QRect(topleft, QSize(IMG_WIDTH, IMG_HEIGHT));
}
Пример #8
0
bool SyntroLCamConsole::startVideo()
{
	if (!m_camera) {
		if (!createCamera()) {
            appLogError("Error allocating camera");
			return false;
		}
	}

	if (!m_daemonMode) {
		connect(m_camera, SIGNAL(cameraState(QString)), this, SLOT(cameraState(QString)), Qt::DirectConnection);
		connect(m_camera, SIGNAL(newFrame()), this, SLOT(newFrame()), Qt::DirectConnection);
    }

    connect(m_camera, SIGNAL(videoFormat(int,int,int)), this, SLOT(videoFormat(int,int,int)));
    connect(m_camera, SIGNAL(videoFormat(int,int,int)), m_client, SLOT(videoFormat(int,int,int)));

    connect(m_camera, SIGNAL(newJPEG(QByteArray)), m_client, SLOT(newJPEG(QByteArray)), Qt::DirectConnection);

    m_camera->resumeThread();

	return true;
}
        void VRCameraStreamingController::UpdateStreamingVolume()
        {
            Eegeo::Camera::CameraState cameraState(m_vrRenderCamera.GetCameraState());
            Eegeo::Camera::RenderCamera& renderCamera = m_vrRenderCamera.GetCamera();

            std::vector<Eegeo::Geometry::Plane> frustumPlanes(Eegeo::Geometry::Frustum::PLANES_COUNT);
            BuildFrustumPlanesFromViewProjection(frustumPlanes, renderCamera.GetViewProjectionMatrix());
            const double d = renderCamera.GetAltitude() * Eegeo::Streaming::StreamingVolumeController::CAMERA_ALTITUDE_TO_FAR_PLANE_DISTANCE_MULTIPLIER;
            const double cameraFarPlaneD = fmin(fmax(d, Eegeo::Streaming::StreamingVolumeController::MIN_STREAMING_FAR_PLANE_DISTANCE), frustumPlanes[Eegeo::Geometry::Frustum::PLANE_FAR].d);
            frustumPlanes[Eegeo::Geometry::Frustum::PLANE_FAR].d = static_cast<float>(cameraFarPlaneD);

            //Workaround: added 100.0f to FOV to load textures for surroundings even when camera is not looking at it to fix interior loading crash.
            //m_pStreamingVolume->updateStreamingVolume(renderCamera.GetEcefLocation(), frustumPlanes, renderCamera.GetFOV());
            m_pStreamingVolume->updateStreamingVolume(renderCamera.GetEcefLocation(), frustumPlanes, renderCamera.GetFOV()+100.0f);
            m_pStreamingVolume->ResetVolume(cameraState.InterestPointEcef());
        }
Пример #10
0
void LadybugWidget::keyPressEvent(QKeyEvent* e)
{
  if (e->key() >= Qt::Key_1 && e->key() <= Qt::Key_5)
  {
    int i = e->key()-Qt::Key_1;

    // invert camera on/off setting
    setCameraState(i, !cameraState(i));

    if (mPaused)
      updateVideo(getSingleFrame(mCurrentFrame));
  }

  switch (e->key())
  {
    case Qt::Key_Space:
      pause();
      break;
    case Qt::Key_Left:
      seekToFrame(mCurrentFrame-1);
      break;
    case Qt::Key_Right:
      seekToFrame(mCurrentFrame+1);
      break;
    case Qt::Key_Home:
      seekToFrame(0);
      break;
    case Qt::Key_End:
      seekToFrame(mStream.framesCount()-1);
      break;
    case Qt::Key_PageUp:
      seekToFrame(mCurrentFrame-25);
      break;
    case Qt::Key_PageDown:
      seekToFrame(mCurrentFrame+25);
      break;

    // %%% seek to random position (for testing)
    case Qt::Key_S:
      {
        uint msecs = rand() % (mStream.framesCount() / 15 * 1000);
        printf("RANDOM TIME SEEK! %d ms\n", msecs);
        seekToTime(msecs);
        break;
      }
  }
}
Пример #11
0
void RouteSimulationExample::Update(float dt)
{
    //Defer initialisation until the loading state is over.
    if(!m_initialised)
    {
        return;
    }

    Eegeo::Camera::RenderCamera renderCamera(m_usingFollowCamera
            ? m_pRouteSessionFollowCameraController->GetRenderCamera()
            : GetGlobeCameraController().GetRenderCamera());

    m_pViewBindingForCycleSession->Update();
    m_pViewBindingForOscillatingSession->Update();
    m_pViewBindingForCameraSession->Update();

    //The route session for which we want to project a position to (in this case, the ecef interest
    //point) should be updated giving it the latest position.
    Eegeo::Camera::CameraState cameraState(GetCurrentCameraState());
    const Eegeo::dv3& ecefPositionToProjectToRoute = cameraState.InterestPointEcef();
    m_pSessionCamera->SetCurrentPositionSnappedToRoute(ecefPositionToProjectToRoute);

    //For the session which should just cycle the route forever, when it has completed simply end
    //the session and restart playback from the beginning.
    if(m_pSessionCycle->IsRouteCompleted())
    {
        m_pSessionCycle->EndPlayback();
        m_pSessionCycle->StartPlaybackFromBeginning();
    }

    //For the session which should oscillate, when the route is finished we change the playback direction
    //and unpause the session (such that it restarts from where it left off), and also demonstrate that
    //we can change playback speed by selecting a random speed multiplier. This multiplier applies to the
    //link speed (such that it is like a 'fast-forward' function). If we wanted to, we could also override
    //the playback speed such that the link speed is ignored by calling the UseCustomSpeedValue method.
    if(m_pSessionAlternatingSpeedChanger->IsRouteCompleted())
    {
        m_pSessionAlternatingSpeedChanger->TogglePlaybackDirection();
        m_pSessionAlternatingSpeedChanger->Unpause();

        m_linkSpeedMultiplier = 0.5f + ((rand() % 200)/100.f);
        m_pSessionAlternatingSpeedChanger->UseLinkSpeedValueWithMultiplier(m_linkSpeedMultiplier);
    }

    EXAMPLE_LOG("%f metres from start of route. %f percent.\n", m_pSessionAlternatingSpeedChanger->GetDistanceFromStartInMetres(),(m_pSessionAlternatingSpeedChanger->GetDistanceFromStartInMetres() / m_pRoute->GetLength())*100.0f) ;
}
Пример #12
0
void QDeclarativeCamera::setupDevice(const QString &deviceName)
{
    QMediaService *service = m_camera->service();
    if (!service)
        return;

    QVideoDeviceSelectorControl *deviceControl = qobject_cast<QVideoDeviceSelectorControl*>(service->requestControl(QVideoDeviceSelectorControl_iid));
    if (!deviceControl)
        return;

    int deviceIndex = -1;

    if (deviceName.isEmpty()) {
        deviceIndex = deviceControl->defaultDevice();
    } else {
        for (int i = 0; i < deviceControl->deviceCount(); ++i) {
            if (deviceControl->deviceName(i) == deviceName) {
                deviceIndex = i;
                break;
            }
        }
    }

    if (deviceIndex == -1)
        return;

    State previousState = cameraState();
    setCameraState(UnloadedState);

    deviceControl->setSelectedDevice(deviceIndex);

    QCameraInfo oldCameraInfo = m_currentCameraInfo;
    m_currentCameraInfo = QCameraInfo(*m_camera);

    emit deviceIdChanged();
    if (oldCameraInfo.description() != m_currentCameraInfo.description())
        emit displayNameChanged();
    if (oldCameraInfo.position() != m_currentCameraInfo.position())
        emit positionChanged();
    if (oldCameraInfo.orientation() != m_currentCameraInfo.orientation())
        emit orientationChanged();

    setCameraState(previousState);
}
Пример #13
0
void ExampleApp::Draw (float dt)
{
    Eegeo::EegeoWorld& eegeoWorld = World();
    
    Eegeo::Camera::CameraState cameraState(m_pCameraController->GetCameraState());
    
    Eegeo::EegeoDrawParameters drawParameters(cameraState.LocationEcef(),
                                              cameraState.InterestPointEcef(),
                                              cameraState.ViewMatrix(),
                                              cameraState.ProjectionMatrix(),
                                              m_screenPropertiesProvider.GetScreenProperties());
    
    eegeoWorld.Draw(drawParameters);
    
    if (m_pLoadingScreen != NULL)
    {
        //m_pLoadingScreen->Draw();
    }
}
Пример #14
0
void LadybugWidget::drawNavigation(QPainter& p)
{
  QColor color;
  QPolygon arrow;
  arrow << QPoint(-5, 0) << QPoint(5,0) << QPoint(0,-10);
  p.save();
  p.setRenderHint(QPainter::Antialiasing);
  p.translate(NAVIGATION_RECT.center());
  for (int i = 0; i < 5; i++)
  {
    p.save();
    p.rotate(i*360/5);
    p.translate(0,-16);
    color = ( cameraState(i) ? QColor::fromHsv(i*360/5, 255,255) : Qt::lightGray);
    p.setBrush(color);
    p.setPen(color.darker());
    p.drawPolygon(arrow);
    p.restore();
  }
  p.setBrush(Qt::black);
  p.drawEllipse(-5,-5,11,11);
  p.restore();
}
Пример #15
0
void ExampleApp::Update (float dt)
{
	Eegeo::EegeoWorld& eegeoWorld = World();
    
    m_pCameraTouchController->Update(dt);

	eegeoWorld.EarlyUpdate(dt);
    m_pCameraController->Update(dt);
    
    Eegeo::Camera::CameraState cameraState(m_pCameraController->GetCameraState());
    Eegeo::Streaming::IStreamingVolume& streamingVolume(World().GetMapModule().GetStreamingVolume());
    
    Eegeo::EegeoUpdateParameters updateParameters(dt,
                                                  cameraState.LocationEcef(),
                                                  cameraState.InterestPointEcef(),
                                                  cameraState.ViewMatrix(),
                                                  cameraState.ProjectionMatrix(),
                                                  streamingVolume,
                                                  m_screenPropertiesProvider.GetScreenProperties());
    
	eegeoWorld.Update(updateParameters);
    
    UpdateLoadingScreen(dt);
}
    void MobileExampleApp::Update(float dt)
    {
        Eegeo::EegeoWorld& eegeoWorld(World());
        
        Eegeo::Modules::Map::Layers::InteriorsPresentationModule& interiorsModule = eegeoWorld.GetMapModule().GetInteriorsPresentationModule();
        Eegeo::Resources::Interiors::Camera::InteriorsCameraController& interiorsCameraController = interiorsModule.GetCameraController();
        
        m_pCurrentTouchController = interiorsModule.GetCameraController().IsEnabled()
            ? &interiorsModule.GetTouchController()
            : m_pCameraTouchController;

        eegeoWorld.EarlyUpdate(dt);

        m_pGlobeCameraController->Update(dt);
        m_pCameraTransitionController->Update(dt);
        
        if(interiorsCameraController.IsEnabled())
        {
            interiorsCameraController.Update(dt);
        }

        Eegeo::Camera::CameraState cameraState(interiorsCameraController.IsEnabled()
                                               ? interiorsCameraController.GetCameraState()
                                               : m_pGlobeCameraController->GetCameraState());
        
        Eegeo::Camera::RenderCamera renderCamera(interiorsCameraController.IsEnabled()
                                                 ? interiorsCameraController.GetRenderCamera()
                                                 : m_pGlobeCameraController->GetRenderCamera());
        
        Eegeo::dv3 ecefInterestPoint(cameraState.InterestPointEcef());

        m_pPoiRingModule->GetPoiRingController().Update(dt, renderCamera, ecefInterestPoint);

        Eegeo::EegeoUpdateParameters updateParameters(dt,
                cameraState.LocationEcef(),
                cameraState.InterestPointEcef(),
                cameraState.ViewMatrix(),
                cameraState.ProjectionMatrix(),
                GetUpdatedStreamingVolume(cameraState, renderCamera),
                m_screenProperties);

        eegeoWorld.Update(updateParameters);

        m_pSearchModule->GetSearchRefreshService().TryRefreshSearch(dt, ecefInterestPoint);

        m_pPinsModule->GetController().Update(dt, renderCamera);

        if(!eegeoWorld.Initialising())
        {
            WorldPinsModule().GetWorldPinsScaleController().Update(dt, renderCamera);
            CompassModule().GetCompassUpdateController().Update(dt);
            CompassModule().GetCompassUpdateController().Update(dt);
            m_pGpsMarkerModule->GetGpsMarkerController().Update(dt, renderCamera);
            
            if (m_interiorsEnabled)
            {
                Eegeo_ASSERT(m_pInteriorsEntitiesPinsModule != NULL);
                
                m_pInteriorsEntitiesPinsModule->GetPinsModule().Update(dt, renderCamera);
                m_pInteriorsEntitiesPinsModule->GetInteriorsEntitiesPinsController().Update(dt);
            }
            
            InitialExperience::SdkModel::IInitialExperienceModel& initialExperienceModel = m_initialExperienceModule.GetInitialExperienceModel();
            if(!initialExperienceModel.HasCompletedInitialExperience() && IsLoadingScreenComplete())
            {
                InitialExperience::SdkModel::IInitialExperienceController& initialExperienceController = m_initialExperienceModule.GetInitialExperienceController();
                initialExperienceController.Update(dt);
            }
  
            if (!m_setMetricsLocation)
            {
                Eegeo::dv3 gpsLocation;
                if(m_pNavigationService->TryGetGpsLocationOnTerrain(gpsLocation))
                {
                    Eegeo::Space::LatLong ll = Eegeo::Space::LatLong::FromECEF(gpsLocation);
                    m_metricsService.SetPosition(ll.GetLatitudeInDegrees(), ll.GetLongitudeInDegrees(), 0.f, 0.f);
                    m_setMetricsLocation = true;
                }
            }
        }

        m_pNavigationService->Update(dt);

        UpdateLoadingScreen(dt);
    }