SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppAndroid.cpp
Go to the documentation of this file.
1 /**
2  * \file AppAndroid.cpp
3  * \brief App::run implementation from App.h for the Android platform
4  * \details The functions implement mostly the callbacks for the platform
5  * Android over the JNI interface into SLInterface.h.
6  * For more info on how to create a new app with SLProject see:
7  * https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App
8  * For more info about App framework see:
9  * https://cpvrlab.github.io/SLProject4/app-framework.html
10  * \date June 2024
11  * \authors Marino von Wattenwyl
12  * \copyright http://opensource.org/licenses/GPL-3.0
13  * \remarks Please use clangformat to format the code. See more code style on
14  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
15 */
16 
17 #include <App.h>
18 #include <SLGLState.h>
19 #include <SLEnums.h>
20 #include <SLInterface.h>
21 #include <AppCommon.h>
22 #include <SLAssetManager.h>
23 #include <SLScene.h>
24 #include <SLSceneView.h>
25 #include <CVCapture.h>
26 #include <Profiler.h>
27 #include <SLAssetLoader.h>
28 #include "mediapipe.h"
29 
30 #include <jni.h>
31 
32 //-----------------------------------------------------------------------------
33 // Global variables
34 App::Config App::config; //!< The configuration set in App::run
35 static JNIEnv* environment; //! Pointer to JAVA environment used in ray tracing callback
36 static int svIndex = 0; //!< SceneView index
37 
38 //-----------------------------------------------------------------------------
39 int slAndroidMain(int argc, char* argv[]);
40 
41 //-----------------------------------------------------------------------------
42 /*! Java Native Interface (JNI) function declarations. These functions are
43 called by the Java interface class AppAndroidJNI. The function name follows the pattern
44 Java_{package name}_{JNI class name}_{function name}(JNIEnv* env,jclass obj,*);
45 The functions mostly forward to the C-Interface functions of SLProject declared
46 in SLInterface.h.
47 */
48 extern "C" {
49 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit(JNIEnv* env, jclass obj, jint width, jint height, jint dpi, jstring filePath);
50 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate(JNIEnv* env, jclass obj);
51 JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews(JNIEnv* env, jclass obj);
52 JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate(JNIEnv* env, jclass obj);
53 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize(JNIEnv* env, jclass obj, jint width, jint height);
54 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown(JNIEnv* env, jclass obj, jint button, jint x, jint y);
55 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp(JNIEnv* env, jclass obj, jint button, jint x, jint y);
56 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove(JNIEnv* env, jclass obj, jint x, jint y);
57 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2);
58 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2);
59 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2);
60 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick(JNIEnv* env, jclass obj, jint button, jint x, jint y);
61 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose(JNIEnv* env, jclass obj);
62 JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation(JNIEnv* env, jclass obj);
63 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT(JNIEnv* env, jclass obj, jfloat quatX, jfloat quatY, jfloat quatZ, jfloat quatW);
64 JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation(JNIEnv* env, jclass obj);
65 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt(JNIEnv* env, jclass obj, jdouble latitudeDEG, jdouble longitudeDEG, jdouble altitudeM, jfloat accuracyM);
66 JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType(JNIEnv* env, jclass obj);
67 JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex(JNIEnv* env, jclass obj);
68 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame(JNIEnv* env, jclass obj);
69 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage(JNIEnv* env, jclass obj, jint imgWidth, jint imgHeight, jbyteArray srcBuffer);
70 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir(JNIEnv* env, jclass obj, jstring externalDirPath);
71 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes(JNIEnv* env, jclass obj, jint srcW, jint srcH, jbyteArray yBuf, jint ySize, jint yPixStride, jint yLineStride, jbyteArray uBuf, jint uSize, jint uPixStride, jint uLineStride, jbyteArray vBuf, jint vSize, jint vPixStride, jint vLineStride);
72 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize(JNIEnv* env, jclass obj, jint sizeIndex, jint sizeIndexMax, jint width, jint height);
73 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter(JNIEnv* env, jclass obj, jstring parameter, jstring value);
74 JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager(JNIEnv* env, jclass obj, jobject assetManager, jstring cacheDirPath);
75 };
76 
77 //-----------------------------------------------------------------------------
78 int App::run(Config configuration)
79 {
80  App::config = configuration;
81  return 0;
82 }
83 //-----------------------------------------------------------------------------
84 //! Native ray tracing callback function that calls the Java class method AppAndroidJNI.RaytracingCallback
86 {
87  jclass klass = environment->FindClass("ch/bfh/cpvrlab/AppAndroidJNI");
88  jmethodID method = environment->GetStaticMethodID(klass, "RaytracingCallback", "()Z");
89  return environment->CallStaticBooleanMethod(klass, method);
90 }
91 //-----------------------------------------------------------------------------
92 //! Native OpenGL info string print functions used in onInit
93 static void printGLString(const char* name, GLenum s)
94 {
95  const char* v = (const char*)glGetString(s);
96  SL_LOG("GL %s = %s\n", name, v);
97 }
98 //-----------------------------------------------------------------------------
99 std::string jstring2stdstring(JNIEnv* env, jstring jStr)
100 {
101  if (!jStr) return "";
102  jboolean isCopy;
103  const char* chars = env->GetStringUTFChars(jStr, &isCopy);
104  std::string stdString(chars);
105  env->ReleaseStringUTFChars(jStr, chars);
106  return stdString;
107 }
108 //-----------------------------------------------------------------------------
109 //! Creates the scene and sceneview instance
110 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit(JNIEnv* env, jclass obj, jint width, jint height, jint dpi, jstring filePath)
111 {
112  environment = env;
113  const char* nativeString = env->GetStringUTFChars(filePath, 0);
114  string devicePath(nativeString);
115  env->ReleaseStringUTFChars(filePath, nativeString);
116 
117  slAndroidMain(0, nullptr);
118  const App::Config& config = App::config;
119 
120  SLVstring* cmdLineArgs = new SLVstring();
121 
122  SL_LOG("GUI : Android");
123 
124  string device_path_msg = "Device path:" + devicePath;
125  SL_LOG(device_path_msg.c_str(), 0);
126 
127  AppCommon::calibFilePath = devicePath + "/data/config/"; //that's where calibrations are stored an loaded from
128  AppCommon::calibIniPath = devicePath + "/data/calibrations/";
130  AppCommon::calibFilePath); // for calibrations made
131 
132  ////////////////////////////////////////////////////
133  slCreateApp(*cmdLineArgs,
134  devicePath + "/data/",
135  devicePath + "/data/shaders/",
136  devicePath + "/data/models/",
137  devicePath + "/data/images/textures/",
138  devicePath + "/data/images/fonts/",
139  devicePath + "/data/videos/",
140  devicePath + "/",
141  "AppDemoAndroid");
142 
144 
145  ////////////////////////////////////////////////////////////////////
148  static_cast<int>(width),
149  static_cast<int>(height),
150  static_cast<int>(dpi),
152  nullptr,
153  nullptr,
154  reinterpret_cast<void*>(config.onNewSceneView),
155  reinterpret_cast<void*>(config.onGuiBuild),
156  reinterpret_cast<void*>(config.onGuiLoadConfig),
157  reinterpret_cast<void*>(config.onGuiSaveConfig));
158  ////////////////////////////////////////////////////////////////////
159 
160  delete cmdLineArgs;
161 }
162 //-----------------------------------------------------------------------------
163 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate(JNIEnv* env, jclass obj)
164 {
165  slTerminate();
166 }
167 //-----------------------------------------------------------------------------
168 extern "C" JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews(JNIEnv* env, jclass obj)
169 {
170  return slPaintAllViews();
171 }
172 //-----------------------------------------------------------------------------
173 extern "C" JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate(JNIEnv* env, jclass obj)
174 {
175  if (AppCommon::sceneViews.empty())
176  return false;
177 
179 
181  {
183  AppCommon::sceneToLoad = {}; // sets optional to empty
184  }
185 
186  if (AppCommon::assetLoader->isLoading())
188 
189  ////////////////////////////////////////////////////////////////
190  SLbool appNeedsUpdate = App::config.onUpdate && App::config.onUpdate(sv);
191  SLbool jobIsRunning = slUpdateParallelJob();
192  SLbool isLoading = AppCommon::assetLoader->isLoading();
193  SLbool viewNeedsUpdate = slPaintAllViews();
194  ////////////////////////////////////////////////////////////////
195 
196  return appNeedsUpdate || viewNeedsUpdate || jobIsRunning || isLoading;
197 }
198 //-----------------------------------------------------------------------------
199 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize(JNIEnv* env, jclass obj, jint width, jint height)
200 {
201  slResize(svIndex, width, height);
202 }
203 //-----------------------------------------------------------------------------
204 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown(JNIEnv* env, jclass obj, jint button, jint x, jint y)
205 {
206  slMouseDown(svIndex, (SLMouseButton)button, x, y, K_none);
207 }
208 //-----------------------------------------------------------------------------
209 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp(JNIEnv* env, jclass obj, jint button, jint x, jint y)
210 {
211  slMouseUp(svIndex, (SLMouseButton)button, x, y, K_none);
212 }
213 //-----------------------------------------------------------------------------
214 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove(JNIEnv* env, jclass obj, jint x, jint y)
215 {
216  slMouseMove(svIndex, x, y);
217 }
218 //-----------------------------------------------------------------------------
219 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2)
220 {
221  slTouch2Down(svIndex, x1, y1, x2, y2);
222 }
223 //-----------------------------------------------------------------------------
224 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2)
225 {
226  slTouch2Move(svIndex, x1, y1, x2, y2);
227 }
228 //-----------------------------------------------------------------------------
229 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up(JNIEnv* env, jclass obj, jint x1, jint y1, jint x2, jint y2)
230 {
231  slTouch2Up(svIndex, x1, y1, x2, y2);
232 }
233 //-----------------------------------------------------------------------------
234 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick(JNIEnv* env, jclass obj, jint button, jint x, jint y)
235 {
237 }
238 //-----------------------------------------------------------------------------
239 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT(JNIEnv* env, jclass obj, jfloat quatX, jfloat quatY, jfloat quatZ, jfloat quatW)
240 {
241  slRotationQUAT(quatX, quatY, quatZ, quatW);
242 }
243 //-----------------------------------------------------------------------------
244 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose(JNIEnv* env, jclass obj)
245 {
246  SL_LOG("onClose");
247  slTerminate();
248 }
249 //-----------------------------------------------------------------------------
250 extern "C" JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation(JNIEnv* env, jclass obj)
251 {
252  return slUsesRotation();
253 }
254 //-----------------------------------------------------------------------------
255 extern "C" JNIEXPORT
256  jint JNICALL
258 {
259  return (int)CVCapture::instance()->videoType();
260 }
261 //-----------------------------------------------------------------------------
262 extern "C" JNIEXPORT
263  jint JNICALL
265 {
267 }
268 //-----------------------------------------------------------------------------
269 //! Grabs a frame from a video file using OpenCV
270 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame(JNIEnv* env, jclass obj)
271 {
273  CVCapture* capture = CVCapture::instance();
274 
275  // Get the current capture size of the videofile
276  CVSize videoSizeBefore = capture->captureSize;
277 
278  // If viewportWdivH is negative the viewport aspect will be adapted to the video
279  // aspect ratio. No cropping will be applied.
280  // Android doesn't know the video file frame size before grab
281  float viewportWdivH = sv->viewportWdivH();
282  if (sv->viewportSameAsVideo())
283  viewportWdivH = -1;
284 
285  capture->grabAndAdjustForSL(viewportWdivH);
286 
287  // If video aspect has changed we need to tell the new viewport to the sceneview
288  CVSize videoSizeAfter = capture->captureSize;
289  if (sv->viewportSameAsVideo() && videoSizeBefore != videoSizeAfter)
290  sv->setViewportFromRatio(SLVec2i(videoSizeAfter.width, videoSizeAfter.height),
291  sv->viewportAlign(),
293 }
294 //-----------------------------------------------------------------------------
295 //! Copies the video image data to the CVCapture class
296 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage(JNIEnv* env, jclass obj, jint imgWidth, jint imgHeight, jbyteArray imgBuffer)
297 {
298  SLuchar* srcLumaPtr = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(imgBuffer, 0));
299 
300  if (srcLumaPtr == nullptr)
301  SL_EXIT_MSG("copyVideoImage: No image data pointer passed!");
302 
304  CVCapture* capture = CVCapture::instance();
305  float videoImgWdivH = (float)imgWidth / (float)imgHeight;
306 
307  if (sv->viewportSameAsVideo())
308  {
309  // If video aspect has changed we need to tell the new viewport to the sceneview
310  if (Utils::abs(videoImgWdivH - sv->viewportWdivH()) > 0.01f)
311  sv->setViewportFromRatio(SLVec2i(imgWidth, imgHeight), sv->viewportAlign(), true);
312  }
313 
314  capture->loadIntoLastFrame(sv->viewportWdivH(), imgWidth, imgHeight, PF_yuv_420_888, srcLumaPtr, true);
315 }
316 //-----------------------------------------------------------------------------
317 //! This function is not in use and was an attempt to copy the data faster.
318 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes(JNIEnv* env, jclass obj, jint srcW, jint srcH, jbyteArray yBuf, jint ySize, jint yPixStride, jint yLineStride, jbyteArray uBuf, jint uSize, jint uPixStride, jint uLineStride, jbyteArray vBuf, jint vSize, jint vPixStride, jint vLineStride)
319 {
320  // Cast jbyteArray to unsigned char pointer
321  SLuchar* y = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(yBuf, 0));
322  SLuchar* u = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(uBuf, 0));
323  SLuchar* v = reinterpret_cast<SLuchar*>(env->GetByteArrayElements(vBuf, 0));
324 
325  if (y == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for y-buffer passed!");
326  if (u == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for u-buffer passed!");
327  if (v == nullptr) SL_EXIT_MSG("copyVideoYUVPlanes: No pointer for v-buffer passed!");
328 
329  // If viewportWdivH is negative the viewport aspect will be adapted to the video
330  // aspect ratio. No cropping will be applied.
331  float viewportWdivH = AppCommon::sceneViews[0]->viewportWdivH();
332  if (AppCommon::sceneViews[0]->viewportSameAsVideo())
333  viewportWdivH = -1;
334 
335  CVCapture::instance()->copyYUVPlanes(viewportWdivH, srcW, srcH, y, ySize, yPixStride, yLineStride, u, uSize, uPixStride, uLineStride, v, vSize, vPixStride, vLineStride);
336 }
337 //-----------------------------------------------------------------------------
338 //! Copies the GPS information to the SLApplicaiton class
339 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt(JNIEnv* env,
340  jclass obj,
341  jdouble latitudeDEG,
342  jdouble longitudeDEG,
343  jdouble altitudeM,
344  jfloat accuracyM)
345 {
346  slLocationLatLonAlt(latitudeDEG, longitudeDEG, altitudeM, accuracyM);
347 }
348 //-----------------------------------------------------------------------------
349 //! Asks the SLApplicaiton class if the GPS sensor data is requested
350 extern "C" JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation(JNIEnv* env, jclass obj)
351 {
352  return slUsesLocation();
353 }
354 //-----------------------------------------------------------------------------
355 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir(JNIEnv* env,
356  jclass obj,
357  jstring externalDirPath)
358 {
359  std::string externalDirPathNative = jstring2stdstring(env, externalDirPath);
360  slSetupExternalDir(externalDirPathNative);
361 }
362 //-----------------------------------------------------------------------------
363 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize(JNIEnv* env,
364  jclass obj,
365  jint sizeIndex,
366  jint sizeIndexMax,
367  jint width,
368  jint height)
369 {
370  CVCapture::instance()->setCameraSize(sizeIndex, sizeIndexMax, width, height);
371 }
372 //-----------------------------------------------------------------------------
373 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter(JNIEnv* env,
374  jclass obj,
375  jstring parameter,
376  jstring value)
377 {
378  std::string par = jstring2stdstring(env, parameter);
379  std::string val = jstring2stdstring(env, value);
380  slSetDeviceParameter(par.c_str(), val.c_str());
381 }
382 //-----------------------------------------------------------------------------
383 extern "C" JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager(JNIEnv* env,
384  jclass obj,
385  jobject assetManager,
386  jstring cacheDirPath)
387 {
388  mp_init_asset_manager(env, assetManager, cacheDirPath);
389 }
390 //-----------------------------------------------------------------------------
The App namespace declares the App::Config struct and the App::run function.
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onClose(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:244
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onInit(JNIEnv *env, jclass obj, jint width, jint height, jint dpi, jstring filePath)
Creates the scene and sceneview instance.
Definition: AppAndroid.cpp:110
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation(JNIEnv *env, jclass obj)
Asks the SLApplicaiton class if the GPS sensor data is requested.
Definition: AppAndroid.cpp:350
std::string jstring2stdstring(JNIEnv *env, jstring jStr)
Definition: AppAndroid.cpp:99
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onLocationLatLonAlt(JNIEnv *env, jclass obj, jdouble latitudeDEG, jdouble longitudeDEG, jdouble altitudeM, jfloat accuracyM)
Copies the GPS information to the SLApplicaiton class.
Definition: AppAndroid.cpp:339
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp(JNIEnv *env, jclass obj, jint button, jint x, jint y)
Definition: AppAndroid.cpp:209
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize(JNIEnv *env, jclass obj, jint sizeIndex, jint sizeIndexMax, jint width, jint height)
Definition: AppAndroid.cpp:363
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown(JNIEnv *env, jclass obj, jint button, jint x, jint y)
Definition: AppAndroid.cpp:204
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:250
static void printGLString(const char *name, GLenum s)
Native OpenGL info string print functions used in onInit.
Definition: AppAndroid.cpp:93
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:168
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:173
bool Java_renderRaytracingCallback()
Native ray tracing callback function that calls the Java class method AppAndroidJNI....
Definition: AppAndroid.cpp:85
static JNIEnv * environment
Definition: AppAndroid.cpp:35
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick(JNIEnv *env, jclass obj, jint button, jint x, jint y)
Definition: AppAndroid.cpp:234
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down(JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
Definition: AppAndroid.cpp:219
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir(JNIEnv *env, jclass obj, jstring externalDirPath)
Definition: AppAndroid.cpp:355
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:264
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame(JNIEnv *env, jclass obj)
Grabs a frame from a video file using OpenCV.
Definition: AppAndroid.cpp:270
int slAndroidMain(int argc, char *argv[])
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Up(JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
Definition: AppAndroid.cpp:229
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoImage(JNIEnv *env, jclass obj, jint imgWidth, jint imgHeight, jbyteArray srcBuffer)
Copies the video image data to the CVCapture class.
Definition: AppAndroid.cpp:296
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter(JNIEnv *env, jclass obj, jstring parameter, jstring value)
Definition: AppAndroid.cpp:373
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove(JNIEnv *env, jclass obj, jint x, jint y)
Definition: AppAndroid.cpp:214
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move(JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
Definition: AppAndroid.cpp:224
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:257
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize(JNIEnv *env, jclass obj, jint width, jint height)
Definition: AppAndroid.cpp:199
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT(JNIEnv *env, jclass obj, jfloat quatX, jfloat quatY, jfloat quatZ, jfloat quatW)
Definition: AppAndroid.cpp:239
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager(JNIEnv *env, jclass obj, jobject assetManager, jstring cacheDirPath)
Definition: AppAndroid.cpp:383
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate(JNIEnv *env, jclass obj)
Definition: AppAndroid.cpp:163
static int svIndex
Pointer to JAVA environment used in ray tracing callback.
Definition: AppAndroid.cpp:36
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_copyVideoYUVPlanes(JNIEnv *env, jclass obj, jint srcW, jint srcH, jbyteArray yBuf, jint ySize, jint yPixStride, jint yLineStride, jbyteArray uBuf, jint uSize, jint uPixStride, jint uLineStride, jbyteArray vBuf, jint vSize, jint vPixStride, jint vLineStride)
This function is not in use and was an attempt to copy the data faster.
Definition: AppAndroid.cpp:318
The AppCommon class holds the top-level instances of the app-demo.
static SLint dpi
Dot per inch resolution of screen.
Definition: AppGLFW.cpp:41
@ PF_yuv_420_888
Definition: CVImage.h:26
cv::Size CVSize
Definition: CVTypedefs.h:55
#define SL_LOG(...)
Definition: SL.h:233
unsigned char SLuchar
Definition: SL.h:163
bool SLbool
Definition: SL.h:175
vector< SLstring > SLVstring
Definition: SL.h:201
#define SL_EXIT_MSG(message)
Definition: SL.h:240
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
@ MB_left
Definition: SLEnums.h:100
@ K_none
Definition: SLEnums.h:17
Singleton class for global render state.
void slRotationQUAT(float quatX, float quatY, float quatZ, float quatW)
void slTouch2Move(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
void slMouseDown(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slSetupExternalDir(const SLstring &externalPath)
void slTouch2Down(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
bool slUsesRotation()
void slMouseMove(int sceneViewIndex, int x, int y)
void slSwitchScene(SLSceneView *sv, SLSceneID sceneID)
bool slUsesLocation()
void slLocationLatLonAlt(double latitudeDEG, double longitudeDEG, double altitudeM, float accuracyM)
void slMouseUp(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slTouch2Up(int sceneViewIndex, int xpos1, int ypos1, int xpos2, int ypos2)
void slDoubleClick(int sceneViewIndex, SLMouseButton button, int xpos, int ypos, SLKey modifier)
void slLoadCoreAssetsSync()
void slResize(int sceneViewIndex, int width, int height)
bool slPaintAllViews()
void slTerminate()
bool slUpdateParallelJob()
void slCreateApp(SLVstring &cmdLineArgs, const SLstring &dataPath, const SLstring &shaderPath, const SLstring &modelPath, const SLstring &texturePath, const SLstring &fontPath, const SLstring &videoPath, const SLstring &configPath, const SLstring &applicationName)
Definition: SLInterface.cpp:57
SLint slCreateSceneView(SLAssetManager *am, SLScene *scene, int screenWidth, int screenHeight, int dotsPerInch, SLSceneID initScene, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, void *onNewSceneViewCallback, void *onImGuiBuild, void *onImGuiLoadConfig, void *onImGuiSaveConfig)
void slSetDeviceParameter(const SLstring &parameter, SLstring value)
Adds a value to the applications device parameter map.
Declaration of the main Scene Library C-Interface.
SLVec2< SLint > SLVec2i
Definition: SLVec2.h:140
static SLstring calibIniPath
That's where data/calibrations folder is located.
Definition: AppCommon.h:108
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLAssetManager * assetManager
asset manager is the owner of all assets
Definition: AppCommon.h:59
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
Definition: AppCommon.h:60
static SLScene * scene
Pointer to the one and only SLScene instance.
Definition: AppCommon.h:61
static SLstring calibFilePath
That's where calibrations are stored and loaded from.
Definition: AppCommon.h:109
int camSizeIndex()
Definition: CVCamera.h:27
Encapsulation of the OpenCV Capture Device and holder of the last frame.
Definition: CVCapture.h:63
void loadCalibrations(const string &computerInfo, const string &configPath)
Definition: CVCapture.cpp:894
CVCamera * activeCamera
Pointer to the active camera.
Definition: CVCapture.h:136
void copyYUVPlanes(float scrWdivH, int srcW, int srcH, uchar *y, int ySize, int yPixStride, int yLineStride, uchar *u, int uSize, int uPixStride, int uLineStride, uchar *v, int vSize, int vPixStride, int vLineStride)
Copies and converts the video image in YUV_420 format to RGB and Grayscale.
Definition: CVCapture.cpp:695
CVSize captureSize
size of captured frame
Definition: CVCapture.h:123
void videoType(CVVideoType vt)
Setter for video type also sets the active calibration.
Definition: CVCapture.cpp:866
void setCameraSize(int sizeIndex, int sizeIndexMax, int width, int height)
Definition: CVCapture.cpp:969
static CVCapture * instance()
Public static instance getter for singleton pattern.
Definition: CVCapture.h:65
void loadIntoLastFrame(float vieportWdivH, int camWidth, int camHeight, CVPixelFormatGL srcPixelFormat, const uchar *data, bool isContinuous)
Definition: CVCapture.cpp:301
bool grabAndAdjustForSL(float viewportWdivH)
Definition: CVCapture.cpp:235
void checkIfAsyncLoadingIsDone()
bool isLoading() const
Definition: SLAssetLoader.h:68
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
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
static std::string get()
Definition: Utils.cpp:1261
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
T abs(T a)
Definition: Utils.h:249
App configuration struct to be passed to the App::run function.
Definition: App.h:57
OnGuiLoadConfigCallback onGuiLoadConfig
Definition: App.h:73
SLSceneID startSceneID
Definition: App.h:64
OnNewSceneViewCallback onNewSceneView
Definition: App.h:65
OnUpdateCallback onUpdate
Definition: App.h:71
OnGuiSaveConfigCallback onGuiSaveConfig
Definition: App.h:74
OnGuiBuildCallback onGuiBuild
Definition: App.h:72