SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoMain.cpp File Reference

This file has the main function of the demo app of SLProject. More...

#include <App.h>
#include <AppCommon.h>
#include <AppDemoGui.h>
#include <AppDemoSceneView.h>
#include <AppDemoSceneID.h>
#include <SLGLState.h>
#include <SLEnums.h>
#include <CVCapture.h>
#include <AppDemoScene2Dand3DText.h>
#include <AppDemoSceneAnimNode.h>
#include <AppDemoSceneAnimNodeMass.h>
#include <AppDemoSceneAnimNodeMass2.h>
#include <AppDemoSceneAnimSkinned.h>
#include <AppDemoSceneAnimSkinnedMass.h>
#include <AppDemoSceneAnimSkinnedMass2.h>
#include <AppDemoSceneEmpty.h>
#include <AppDemoSceneErlebARBielBFH.h>
#include <AppDemoSceneErlebARAugustaTmpTht.h>
#include <AppDemoSceneErlebARAventicumCigognier.h>
#include <AppDemoSceneErlebARAventicumTheater.h>
#include <AppDemoSceneErlebARAventicumAmphitheater.h>
#include <AppDemoSceneErlebARBernChristoffel.h>
#include <AppDemoSceneErlebARSutz.h>
#include <AppDemoSceneFigure.h>
#include <AppDemoSceneFrustum.h>
#include <AppDemoSceneGLTF.h>
#include <AppDemoSceneJansUniverse.h>
#include <AppDemoSceneMeshLoad.h>
#include <AppDemoSceneMinimal.h>
#include <AppDemoSceneLargeModel.h>
#include <AppDemoSceneLevelOfDetail.h>
#include <AppDemoSceneLotsOfNodes.h>
#include <AppDemoSceneParticleComplexFire.h>
#include <AppDemoSceneParticleDustStorm.h>
#include <AppDemoSceneParticleFountain.h>
#include <AppDemoSceneParticleMany.h>
#include <AppDemoSceneParticleRingOfFire.h>
#include <AppDemoSceneParticleSimple.h>
#include <AppDemoSceneParticleSun.h>
#include <AppDemoScenePointClouds.h>
#include <AppDemoSceneRevolver.h>
#include <AppDemoSceneRTDoF.h>
#include <AppDemoSceneRTMuttenzerBox.h>
#include <AppDemoSceneRTLens.h>
#include <AppDemoSceneRTSpheres.h>
#include <AppDemoSceneRobot.h>
#include <AppDemoSceneSuzanne.h>
#include <AppDemoSceneShaderBlinn.h>
#include <AppDemoSceneShaderBump.h>
#include <AppDemoSceneShaderCook.h>
#include <AppDemoSceneShaderEarth.h>
#include <AppDemoSceneShaderIBL.h>
#include <AppDemoSceneShaderParallax.h>
#include <AppDemoSceneShaderSkybox.h>
#include <AppDemoSceneShaderWave.h>
#include <AppDemoSceneShadowBasic.h>
#include <AppDemoSceneShadowCascaded.h>
#include <AppDemoSceneShadowLightTypes.h>
#include <AppDemoSceneShadowLightSpot.h>
#include <AppDemoSceneShadowLightPoint.h>
#include <AppDemoSceneTextureBlend.h>
#include <AppDemoSceneTextureCompression.h>
#include <AppDemoSceneTextureFilter.h>
#include <AppDemoSceneVideoSensorAR.h>
#include <AppDemoSceneVideoTexture.h>
#include <AppDemoSceneVideoTrackAruco.h>
#include <AppDemoSceneVideoTrackChessboard.h>
#include <AppDemoSceneVideoTrackFace.h>
#include <AppDemoSceneVideoTrackFeatures.h>
#include <AppDemoSceneVideoTrackMediapipe.h>
#include <AppDemoSceneVideoTrackWAI.h>
#include <AppDemoSceneVolumeRayCast.h>
#include <AppDemoSceneVolumeRayCastLighted.h>
#include <AppDemoSceneZFighting.h>
#include <CVTracked.h>

Go to the source code of this file.

Functions

bool onUpdateVideo ()
 Implements the update per frame for video update and feature tracking. More...
 
static SLSceneViewcreateSceneView (SLScene *scene, int curDPI, SLInputManager &inputManager)
 
static SLScenecreateScene (SLSceneID sceneID)
 
static void onBeforeSceneDelete (SLSceneView *sv, SLScene *s)
 
static void onBeforeSceneLoad (SLSceneView *sv, SLScene *s)
 
static void onBeforeSceneAssembly (SLSceneView *sv, SLScene *s)
 
static void onAfterSceneAssembly (SLSceneView *sv, SLScene *s)
 
static SLbool onUpdate (SLSceneView *sv)
 
int SL_MAIN_FUNCTION (int argc, char *argv[])
 

Variables

SLGLTexturegVideoTexture
 
CVTrackedgVideoTracker
 
SLNodegVideoTrackedNode
 

Detailed Description

This file has the main function of the demo app of SLProject.

An App::Config is set and then passed to the run function defined App.h. Beside this is contains the callback functions for the scene creation. See App.h for their typedef. For more info on how to create a new app with SLProject see: https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App For more info about App framework see: https://cpvrlab.github.io/SLProject4/app-framework.html

Authors
Marcus Hudritsch, Marino von Wattenwyl
Date
July 2024
Remarks
Please use clangformat to format the code. See more code style on https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style

Definition in file AppDemoMain.cpp.

Function Documentation

◆ createScene()

static SLScene* createScene ( SLSceneID  sceneID)
static

Definition at line 117 of file AppDemoMain.cpp.

118 {
119  switch (sceneID)
120  {
121  case SID_Empty: return new AppDemoSceneEmpty();
122  case SID_Figure: return new AppDemoSceneFigure();
123  case SID_Minimal: return new AppDemoSceneMinimal();
124  case SID_MeshLoad: return new AppDemoSceneMeshLoad();
125  case SID_Revolver: return new AppDemoSceneRevolver();
126  case SID_TextureBlend: return new AppDemoSceneTextureBlend();
127  case SID_TextureFilter: return new AppDemoSceneTextureFilter();
128 #ifdef SL_BUILD_WITH_KTX
130 #endif
131  case SID_FrustumCull: return new AppDemoSceneFrustum();
132  case SID_2Dand3DText: return new AppDemoScene2Dand3DText();
133  case SID_PointClouds: return new AppDemoScenePointClouds();
134  case SID_ZFighting: return new AppDemoSceneZFighting();
135  case SID_ShaderPerVertexBlinn: return new AppDemoSceneShaderBlinn("Per Vertex Blinn-Phong Lighting", true);
136  case SID_ShaderPerPixelBlinn: return new AppDemoSceneShaderBlinn("Per Pixel Blinn-Phong Lighting", false);
138  case SID_ShaderIBL: return new AppDemoSceneShaderIBL();
139  case SID_ShaderWave: return new AppDemoSceneShaderWave();
140  case SID_ShaderBumpNormal: return new AppDemoSceneShaderBump();
142  case SID_ShaderSkybox: return new AppDemoSceneShaderSkybox();
143  case SID_ShaderEarth: return new AppDemoSceneShaderEarth();
149  case SID_SuzannePerPixBlinn: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and reflection colors", false, false, false, false, false);
150  case SID_SuzannePerPixBlinnTm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and texture mapping", true, false, false, false, false);
151  case SID_SuzannePerPixBlinnNm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and normal mapping", false, true, false, false, false);
152  case SID_SuzannePerPixBlinnAo: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and ambient occlusion", false, false, true, false, false);
153  case SID_SuzannePerPixBlinnSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and shadow mapping", false, false, false, true, false);
154  case SID_SuzannePerPixBlinnTmNm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, texture and normal mapping", true, true, false, false, false);
155  case SID_SuzannePerPixBlinnTmAo: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, texture mapping and ambient occlusion", true, false, true, false, false);
156  case SID_SuzannePerPixBlinnNmAo: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, normal mapping and ambient occlusion", false, true, true, false, false);
157  case SID_SuzannePerPixBlinnTmSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, texture mapping and shadow mapping", true, false, false, true, false);
158  case SID_SuzannePerPixBlinnNmSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, normal mapping and shadow mapping", false, true, false, true, false);
159  case SID_SuzannePerPixBlinnAoSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting, ambient occlusion and shadow mapping", false, false, true, true, false);
160  case SID_SuzannePerPixBlinnTmNmAo: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and diffuse, normal, ambient occlusion and shadow mapping", true, true, true, false, false);
161  case SID_SuzannePerPixBlinnTmNmSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and diffuse, normal and shadow mapping ", true, true, false, true, false);
162  case SID_SuzannePerPixBlinnTmNmAoSm: return new AppDemoSceneSuzanne("Suzanne with per pixel Blinn-Phong lighting and diffuse, normal, ambient occlusion and shadow mapping", true, true, true, true, false);
163  case SID_SuzannePerPixCookTmNmAoSmEm: return new AppDemoSceneSuzanne("Suzanne with per pixel Cook-Torrance lighting and diffuse, normal, ambient occlusion, shadow and environment mapping", true, true, true, true, true);
166  case SID_glTF_Sponza:
168  case SID_Robotics_FanucCRX_FK: return new AppDemoSceneRobot();
169  case SID_VolumeRayCast: return new AppDemoSceneVolumeRayCast();
171  case SID_AnimationNode: return new AppDemoSceneAnimNode();
187  case SID_VideoTrackWAI: return new AppDemoSceneVideoTrackWAI();
188  case SID_VideoSensorAR: return new AppDemoSceneVideoSensorAR();
197  case SID_RTSpheres:
200  case SID_RTDoF: return new AppDemoSceneRTDoF();
201  case SID_RTLens: return new AppDemoSceneRTLens();
216  default: SL_EXIT_MSG("appDemoSwitchScene: Unknown SceneID");
217  }
218 }
@ SID_SuzannePerPixBlinnNmSm
@ SID_Benchmark_SkinnedAnimations
@ SID_TextureBlend
@ SID_Minimal
@ SID_glTF_Sponza
@ SID_VideoTrackChessScnd
@ SID_ParticleSystem_Many
@ SID_SuzannePerPixBlinnTmAo
@ SID_VideoTrackMediaPipeHandsMain
@ SID_Benchmark_LargeModel
@ SID_SuzannePerPixBlinnTmSm
@ SID_SuzannePerPixBlinnAoSm
@ SID_ParticleSystem_ComplexFire
@ SID_ParticleSystem_RingOfFire
@ SID_ShaderSkybox
@ SID_RTSoftShadows
@ SID_Figure
@ SID_SuzannePerPixBlinnNm
@ SID_ShadowMappingSpotLights
@ SID_VideoTrackFaceScnd
@ SID_RTSpheres
@ SID_VideoSensorAR
@ SID_ErlebAR_BielBFH
@ SID_ErlebAR_BernChristoffel
@ SID_PointClouds
@ SID_ParticleSystem_DustStorm
@ SID_Revolver
@ SID_SuzannePerPixBlinnNmAo
@ SID_ShaderEarth
@ SID_VolumeRayCast
@ SID_VideoTextureLive
@ SID_AnimationNode
@ SID_ParticleSystem_Simple
@ SID_VideoCalibrateScnd
@ SID_Benchmark_JansUniverse
@ SID_Benchmark_ColumnsNoLOD
@ SID_MeshLoad
@ SID_ParticleSystem_Fountain
@ SID_SuzannePerPixBlinnSm
@ SID_ShadowMappingLightTypes
@ SID_AnimationSkinnedMass
@ SID_VideoTextureFile
@ SID_SuzannePerPixBlinnTmNmSm
@ SID_ShaderPerPixelBlinn
@ SID_ZFighting
@ SID_SuzannePerPixBlinnTm
@ SID_ErlebAR_AventicumAmphiteatre
@ SID_Empty
@ SID_Benchmark_NodeAnimations
@ SID_Benchmark_ColumnsLOD
@ SID_ShadowMappingCascaded
@ SID_SuzannePerPixBlinnTmNmAoSm
@ SID_SuzannePerPixCookTmNmAoSmEm
@ SID_ErlebAR_AventicumCigognier
@ SID_glTF_DamagedHelmet
@ SID_SuzannePerPixBlinn
@ SID_ShaderIBL
@ SID_ShadowMappingPointLights
@ SID_VideoTrackArucoMain
@ SID_glTF_FlightHelmet
@ SID_TextureFilter
@ SID_RTLens
@ SID_Benchmark_ParticleSystemComplexFire
@ SID_Benchmark_LotsOfNodes
@ SID_VideoTrackArucoScnd
@ SID_SuzannePerPixBlinnTmNmAo
@ SID_VideoTrackFeature2DMain
@ SID_ParticleSystem_Sun
@ SID_VolumeRayCastLighted
@ SID_ErlebAR_AventicumTheatre
@ SID_ShadowMappingBasicScene
@ SID_2Dand3DText
@ SID_VideoTrackFaceMain
@ SID_VideoCalibrateMain
@ SID_VideoTrackChessMain
@ SID_ShaderBumpParallax
@ SID_ShaderPerPixelCook
@ SID_ShaderWave
@ SID_SuzannePerPixBlinnAo
@ SID_SuzannePerPixBlinnTmNm
@ SID_ErlebAR_AugustaRauricaTmpTht
@ SID_ErlebAR_SutzKirchrain18
@ SID_TextureCompression
@ SID_ShaderBumpNormal
@ SID_Robotics_FanucCRX_FK
@ SID_glTF_WaterBottle
@ SID_FrustumCull
@ SID_VideoTrackWAI
@ SID_ShaderPerVertexBlinn
@ SID_RTMuttenzerBox
@ SID_AnimationNodeMass
@ SID_AnimationSkinned
@ SID_RTDoF
#define SL_EXIT_MSG(message)
Definition: SL.h:240
SLScene SLSceneView SLint sceneID
Definition: SLScene.h:33
Class for 2D and 3D text scene.
Class for node animation test scene.
Class for benchmark mass animation test scene.
Class for mass animation test scene.
Class for skinned animation test scene.
Class for skinned animation test scene.
Class for skinned animation test scene.
Class for ErlebAR model for Augusta Raurica Tempel & Theater.
Class for ErlebAR model for Aventicum Amphitheater.
Class for ErlebAR model for Aventicum Cigognier.
Class for ErlebAR model for Aventicum Theater.
Class for ErlebAR model Christoffel Tower in Bern.
Class for ErlebAR model in Biel at BFH.
Class for ErlebAR model in Sutz.
Class for the figure scene.
Class for frustum culling test scene.
Class for GLTF file loading demo scene.
Class for the benchmark scene for Jans Universe.
Class for large model scene.
Class for level of detail test scene.
Class for scene with lots of nodes.
Class for mesh loading demo scene.
Class for minimal scene.
Class for fire ring particle system scene.
Class for simple particle system scene.
Class for simple particle system scene.
Class for benchmark scene with a particle system with many particles.
Class for fire ring particle system scene.
Class for simple particle system scene.
Class for sun particle system scene.
Class for point cloud test scene.
Class for the depth of field ray tracing scene.
Class for the lens ray tracing scene.
Class for the Muttenzer Box ray tracing scene.
Class for the ray tracing scene with sphere group.
Class for revolver mesh scene.
Class for a robot arm test scene.
Class for demo scene with Blinn-Phong lighting per vertex or per pixel.
Class for normal map bump mapping.
Class for Cook-Torrance lighting demo scene.
Class for image base lighting demo scene.
Class for image base lighting demo scene.
Class for parallax bump mapping demo scene.
Class for image base lighting demo scene.
Class for per vertex wave shader.
Class for basic shadow mapping demo scene.
Class for demo scene for cascaded shadow mapping.
Class for demo scene for point light shadow mapping.
Class for demo scene for spotlight shadow mapping.
Class for demo scene with all shadow mapping types.
Class for all variants of generated shaders on the Suzanne head.
Class for texture blending scene.
Class for texture compression test scene.
Class for texture filtering scene.
Class for devices IMU and GPS Sensors test scene.
Class for live or file video on texture test scene.
Class for ARUCO marker tracking test scene.
Class for video for chessboard test scene.
Class for facial feature tracking test scene.
Class for feature tracking test scene.
Class for Mediapipe hand tracking test scene.
Class for Mediapipe hand tracking test scene.
Class for test scene for volume rendering of an angiographic MRI scan".
Class for test scene for lighted volume rendering of an angiographic MRI scan".
Class for z-fighting test scene.

◆ createSceneView()

static SLSceneView* createSceneView ( SLScene scene,
int  curDPI,
SLInputManager inputManager 
)
static

Definition at line 109 of file AppDemoMain.cpp.

112 {
113  // The sceneview will be deleted by SLScene::~SLScene()
114  return new AppDemoSceneView(scene, curDPI, inputManager);
115 }

◆ onAfterSceneAssembly()

static void onAfterSceneAssembly ( SLSceneView sv,
SLScene s 
)
static

Definition at line 244 of file AppDemoMain.cpp.

245 {
246  if (CVCapture::instance()->videoType() != VT_NONE)
247  {
248  if (sv->viewportSameAsVideo())
249  {
250  // Pass a negative value to the start function, so that the
251  // viewport aspect ratio can be adapted later to the video aspect.
252  // This will be known after start.
253  CVCapture::instance()->start(-1.0f);
254  SLVec2i videoAspect;
255  videoAspect.x = CVCapture::instance()->captureSize.width;
256  videoAspect.y = CVCapture::instance()->captureSize.height;
257  sv->setViewportFromRatio(videoAspect,
258  sv->viewportAlign(),
259  true);
260  }
261  else
263  }
264 }
@ VT_NONE
No camera needed.
Definition: CVCapture.h:41
CVSize captureSize
size of captured frame
Definition: CVCapture.h:123
void start(float viewportWdivH)
starts the video capturing
Definition: CVCapture.cpp:174
static CVCapture * instance()
Public static instance getter for singleton pattern.
Definition: CVCapture.h:65
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void viewportSameAsVideo(bool sameAsVideo)
Definition: SLSceneView.h:155
void setViewportFromRatio(const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
Sets the viewport ratio and the viewport rectangle.
SLViewportAlign viewportAlign() const
Definition: SLSceneView.h:181
SLfloat viewportWdivH() const
Definition: SLSceneView.h:178
T y
Definition: SLVec2.h:30
T x
Definition: SLVec2.h:30

◆ onBeforeSceneAssembly()

static void onBeforeSceneAssembly ( SLSceneView sv,
SLScene s 
)
static

Definition at line 239 of file AppDemoMain.cpp.

240 {
241  AppDemoGui::loadingString = "Assembling ...";
242 }
static SLstring loadingString
String shown during loading screens.
Definition: AppDemoGui.h:78

◆ onBeforeSceneDelete()

static void onBeforeSceneDelete ( SLSceneView sv,
SLScene s 
)
static

Definition at line 220 of file AppDemoMain.cpp.

221 {
222  // Reset video and trackers
223  CVCapture::instance()->videoType(VT_NONE); // turn off any video
224  CVTracked::resetTimes(); // delete all gVideoTracker times
225  delete gVideoTracker; // delete the tracker deep
226  gVideoTracker = nullptr;
227  gVideoTexture = nullptr; // The video texture will be deleted by scene uninit
228  gVideoTrackedNode = nullptr; // The tracked node will be deleted by scene uninit
229 
230  // Clear gui stuff that depends on scene and sceneview
232 }
SLNode * gVideoTrackedNode
SLGLTexture * gVideoTexture
CVTracked * gVideoTracker
static void clear()
Definition: AppDemoGui.cpp:218
void videoType(CVVideoType vt)
Setter for video type also sets the active calibration.
Definition: CVCapture.cpp:866
static void resetTimes()
Resets all static variables.
Definition: CVTracked.cpp:31

◆ onBeforeSceneLoad()

static void onBeforeSceneLoad ( SLSceneView sv,
SLScene s 
)
static

Definition at line 234 of file AppDemoMain.cpp.

235 {
236  AppDemoGui::loadingString = "Loading ...";
237 }

◆ onUpdate()

static SLbool onUpdate ( SLSceneView sv)
static

Definition at line 266 of file AppDemoMain.cpp.

267 {
268  // If live video image is requested grab it and copy it
269  if (CVCapture::instance()->videoType() != VT_NONE)
270  {
271  float viewportWdivH = sv->viewportWdivH();
272  CVCapture::instance()->grabAndAdjustForSL(viewportWdivH);
273  }
274 
275  SLbool trackingGotUpdated = onUpdateVideo();
276  return trackingGotUpdated;
277 }
bool onUpdateVideo()
Implements the update per frame for video update and feature tracking.
bool SLbool
Definition: SL.h:175
bool grabAndAdjustForSL(float viewportWdivH)
Definition: CVCapture.cpp:235

◆ onUpdateVideo()

bool onUpdateVideo ( )

Implements the update per frame for video update and feature tracking.

This routine is called once per frame before any other update within the the main rendering loop (see: AppDemoMainGLFW::onPaint or GLES3View::onDrawFrame). See the documentation within SLCVTracked and in all of its inheritants.

Definition at line 226 of file AppDemoVideo.cpp.

227 {
229 
230  if (AppCommon::sceneViews.empty())
231  return false;
232 
235 
236  if (CVCapture::instance()->videoType() != VT_NONE &&
237  !CVCapture::instance()->lastFrame.empty())
238  {
239  SLfloat trackingTimeStartMS = GlobalTimer::timeMS();
240 
242 
245  {
247  }
248  else
249  {
251  // Attention: Always update scene camera fovV from calibration because the calibration may have
252  // been adapted in adjustForSL after a change of aspect ratio!
253  // The active scene view camera may be a different one that the tracking camera
254  // but we have to update the tracking camera only!
256 
258  {
259  bool foundPose = gVideoTracker->track(CVCapture::instance()->lastFrameGray,
260  CVCapture::instance()->lastFrame,
261  &ac->calibration);
262  if (foundPose)
263  {
264  // clang-format off
265  // convert matrix type CVMatx44f to SLMat4f
267  SLMat4f glOVM(cvOVM.val[0], cvOVM.val[1], cvOVM.val[2], cvOVM.val[3],
268  cvOVM.val[4], cvOVM.val[5], cvOVM.val[6], cvOVM.val[7],
269  cvOVM.val[8], cvOVM.val[9], cvOVM.val[10],cvOVM.val[11],
270  cvOVM.val[12],cvOVM.val[13],cvOVM.val[14],cvOVM.val[15]);
271  // clang-format on
272 
273  // set the object matrix depending if the
274  // tracked node is attached to a camera or not
275  if (typeid(*gVideoTrackedNode) == typeid(SLCamera))
276  {
277  gVideoTrackedNode->om(glOVM.inverted());
279  }
280  else
281  {
282  // see comments in CVTracked::calcObjectMatrix
283  gVideoTrackedNode->om(sv->camera()->om() * glOVM);
285  }
286  }
287  else
289  }
290 
291  // Update info text only for chessboard scene
296  {
297  SLfloat fovH = ac->calibration.cameraFovHDeg();
299  stringstream ss; // info line text
300  ss << "Tracking Chessboard on " << (CVCapture::instance()->videoType() == VT_MAIN ? "main " : "scnd. ") << "camera. ";
301  if (ac->calibration.state() == CS_calibrated)
302  ss << "FOVH: " << fovH << ", error: " << err;
303  else
304  ss << "Not calibrated. FOVH guessed: " << fovH << " degrees.";
305  s->info(ss.str());
306  }
307  }
308 
309  //...................................................................
310  // copy image to video texture
311  if (gVideoTexture)
312  {
313  if (ac->calibration.state() == CS_calibrated && ac->showUndistorted())
314  {
315  CVMat undistorted;
316  ac->calibration.remap(CVCapture::instance()->lastFrame, undistorted);
317 
318  // CVCapture::instance()->gVideoTexture()->copyVideoImage(undistorted.cols,
319  gVideoTexture->copyVideoImage(undistorted.cols,
320  undistorted.rows,
322  undistorted.data,
323  undistorted.isContinuous(),
324  true);
325  }
326  else
327  {
328  // CVCapture::instance()->gVideoTexture()->copyVideoImage(CVCapture::instance()->lastFrame.cols,
333  CVCapture::instance()->lastFrame.isContinuous(),
334  true);
335  }
336  }
337  else
338  SL_WARN_MSG("No video texture to copy to.");
339 
340 #ifndef SL_EMSCRIPTEN
341  CVTracked::trackingTimesMS.set(GlobalTimer::timeMS() - trackingTimeStartMS);
342 #endif
343 
344  return true;
345  }
346 
347  return false;
348 }
SLNode * gVideoTrackedNode
SLGLTexture * gVideoTexture
void ensureValidCalibration(CVCamera *ac, SLSceneView *sv)
logic that ensures that we have a valid calibration state
void updateTrackingSceneCamera(CVCamera *ac)
CVTracked * gVideoTracker
void runCalibrationEstimator(CVCamera *ac, SLScene *s, SLSceneView *sv)
@ CS_calibrated
The camera is calibrated.
Definition: CVCalibration.h:33
@ VT_MAIN
Main camera on all on all all devices.
Definition: CVCapture.h:42
cv::Matx44f CVMatx44f
Definition: CVTypedefs.h:59
cv::Mat CVMat
Definition: CVTypedefs.h:38
#define PROFILE_FUNCTION()
Definition: Instrumentor.h:41
float SLfloat
Definition: SL.h:173
#define SL_WARN_MSG(message)
Definition: SL.h:241
#define SL_DB_HIDDEN
Flags an object as hidden.
Definition: SLDrawBits.h:20
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLSceneID sceneID
ID of currently loaded scene.
Definition: AppCommon.h:89
static SLScene * scene
Pointer to the one and only SLScene instance.
Definition: AppCommon.h:61
void remap(CVMat &inDistorted, CVMat &outUndistorted)
Undistorts the inDistorted image into the outUndistorted.
float reprojectionError() const
float cameraFovHDeg() const
CVCalibState state() const
CVCalibration calibration
Definition: CVCamera.h:36
void showUndistorted(bool su)
Definition: CVCamera.h:25
CVCamera * activeCamera
Pointer to the active camera.
Definition: CVCapture.h:136
CVPixelFormatGL format
GL pixel format.
Definition: CVCapture.h:122
CVMat lastFrame
last frame grabbed in BGR
Definition: CVCapture.h:119
static AvgFloat trackingTimesMS
Averaged time for video tracking in ms.
Definition: CVTracked.h:82
virtual bool track(CVMat imageGray, CVMat imageBgr, CVCalibration *calib)=0
CVMatx44f objectViewMat()
Definition: CVTracked.h:65
static float timeMS()
Definition: GlobalTimer.cpp:25
Active or visible camera node class.
Definition: SLCamera.h:54
SLbool copyVideoImage(SLint camWidth, SLint camHeight, CVPixelFormatGL glFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
Copies the image data from a video camera into the current video image.
void om(const SLMat4f &mat)
Definition: SLNode.h:276
void setDrawBitsRec(SLuint bit, SLbool state)
Definition: SLNode.cpp:804
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
void info(SLstring i)
Definition: SLScene.h:93
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
void set(T value)
Sets the current value in the value array and builds the average.
Definition: Averaged.h:53

◆ SL_MAIN_FUNCTION()

int SL_MAIN_FUNCTION ( int  argc,
char *  argv[] 
)

Definition at line 285 of file AppDemoMain.cpp.

286 {
288  config.argc = argc;
289  config.argv = argv;
290  config.windowWidth = 1280;
291  config.windowHeight = 720;
292  config.windowTitle = "SLProject Test Application";
293  config.numSamples = 4;
294  config.startSceneID = SL_STARTSCENE;
305 
306  return App::run(config);
307 }
static SLbool onUpdate(SLSceneView *sv)
static SLSceneView * createSceneView(SLScene *scene, int curDPI, SLInputManager &inputManager)
static void onBeforeSceneAssembly(SLSceneView *sv, SLScene *s)
static void onAfterSceneAssembly(SLSceneView *sv, SLScene *s)
static void onBeforeSceneDelete(SLSceneView *sv, SLScene *s)
static void onBeforeSceneLoad(SLSceneView *sv, SLScene *s)
static SLScene * createScene(SLSceneID sceneID)
static void loadConfig(SLint dotsPerInch)
Loads the UI configuration.
static void saveConfig()
Stores the UI configuration.
static void build(SLScene *s, SLSceneView *sv)
This is the main building function for the GUI of the Demo apps.
Definition: AppDemoGui.cpp:229
int run(Config config)
App::run implementation from App.h for the Emscripten platform.
Definition: AppAndroid.cpp:78
Config config
The configuration set in App::run.
Definition: AppAndroid.cpp:34
App configuration struct to be passed to the App::run function.
Definition: App.h:57
OnGuiLoadConfigCallback onGuiLoadConfig
Definition: App.h:73
OnAfterSceneAssemblyCallback onAfterSceneAssembly
Definition: App.h:70
SLSceneID startSceneID
Definition: App.h:64
SLint windowWidth
Definition: App.h:60
SLint windowHeight
Definition: App.h:61
OnNewSceneViewCallback onNewSceneView
Definition: App.h:65
OnUpdateCallback onUpdate
Definition: App.h:71
OnBeforeSceneAssemblyCallback onBeforeSceneAssembly
Definition: App.h:69
OnGuiSaveConfigCallback onGuiSaveConfig
Definition: App.h:74
OnNewSceneCallback onNewScene
Definition: App.h:66
SLint numSamples
Definition: App.h:63
OnGuiBuildCallback onGuiBuild
Definition: App.h:72
int argc
Definition: App.h:58
OnBeforeSceneLoadCallback onBeforeSceneLoad
Definition: App.h:68
OnBeforeSceneDeleteCallback onBeforeSceneDelete
Definition: App.h:67
char ** argv
Definition: App.h:59
SLstring windowTitle
Definition: App.h:62

Variable Documentation

◆ gVideoTexture

SLGLTexture* gVideoTexture
extern

Global pointer for the video texture defined in AppDemoLoad for video scenes It gets updated in the following onUpdateTracking routine

Definition at line 32 of file AppDemoVideo.cpp.

◆ gVideoTrackedNode

SLNode* gVideoTrackedNode
extern

Global pointer to a node that from witch the gVideoTracker changes the pose. it gets updated in the following onUpdateTracking routine

Definition at line 42 of file AppDemoVideo.cpp.

◆ gVideoTracker

CVTracked* gVideoTracker
extern

Global pointer for a gVideoTracker that is set in AppDemoLoad for video scenes It gets updated in the following onUpdateTracking routine

Definition at line 37 of file AppDemoVideo.cpp.