28 #include "mediapipe.h"
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);
87 jclass klass =
environment->FindClass(
"ch/bfh/cpvrlab/AppAndroidJNI");
88 jmethodID method =
environment->GetStaticMethodID(klass,
"RaytracingCallback",
"()Z");
89 return environment->CallStaticBooleanMethod(klass, method);
95 const char* v = (
const char*)glGetString(
s);
96 SL_LOG(
"GL %s = %s\n", name, v);
101 if (!jStr)
return "";
103 const char* chars = env->GetStringUTFChars(jStr, &isCopy);
104 std::string stdString(chars);
105 env->ReleaseStringUTFChars(jStr, chars);
113 const char* nativeString = env->GetStringUTFChars(filePath, 0);
114 string devicePath(nativeString);
115 env->ReleaseStringUTFChars(filePath, nativeString);
124 string device_path_msg =
"Device path:" + devicePath;
125 SL_LOG(device_path_msg.c_str(), 0);
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/",
148 static_cast<int>(width),
149 static_cast<int>(height),
150 static_cast<int>(
dpi),
196 return appNeedsUpdate || viewNeedsUpdate || jobIsRunning || isLoading;
298 SLuchar* srcLumaPtr =
reinterpret_cast<SLuchar*
>(env->GetByteArrayElements(imgBuffer, 0));
300 if (srcLumaPtr ==
nullptr)
301 SL_EXIT_MSG(
"copyVideoImage: No image data pointer passed!");
305 float videoImgWdivH = (float)imgWidth / (
float)imgHeight;
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)
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));
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!");
335 CVCapture::instance()->
copyYUVPlanes(viewportWdivH, srcW, srcH, y, ySize, yPixStride, yLineStride, u, uSize, uPixStride, uLineStride, v, vSize, vPixStride, vLineStride);
342 jdouble longitudeDEG,
357 jstring externalDirPath)
385 jobject assetManager,
386 jstring cacheDirPath)
388 mp_init_asset_manager(env, assetManager, cacheDirPath);
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)
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.
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesLocation(JNIEnv *env, jclass obj)
Asks the SLApplicaiton class if the GPS sensor data is requested.
std::string jstring2stdstring(JNIEnv *env, jstring jStr)
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.
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseUp(JNIEnv *env, jclass obj, jint button, jint x, jint y)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setCameraSize(JNIEnv *env, jclass obj, jint sizeIndex, jint sizeIndexMax, jint width, jint height)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseDown(JNIEnv *env, jclass obj, jint button, jint x, jint y)
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_usesRotation(JNIEnv *env, jclass obj)
static void printGLString(const char *name, GLenum s)
Native OpenGL info string print functions used in onInit.
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onPaintAllViews(JNIEnv *env, jclass obj)
JNIEXPORT bool JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onUpdate(JNIEnv *env, jclass obj)
bool Java_renderRaytracingCallback()
Native ray tracing callback function that calls the Java class method AppAndroidJNI....
static JNIEnv * environment
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onDoubleClick(JNIEnv *env, jclass obj, jint button, jint x, jint y)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Down(JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onSetupExternalDir(JNIEnv *env, jclass obj, jstring externalDirPath)
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoSizeIndex(JNIEnv *env, jclass obj)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_grabVideoFileFrame(JNIEnv *env, jclass obj)
Grabs a frame from a video file using OpenCV.
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)
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.
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_setDeviceParameter(JNIEnv *env, jclass obj, jstring parameter, jstring value)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onMouseMove(JNIEnv *env, jclass obj, jint x, jint y)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTouch2Move(JNIEnv *env, jclass obj, jint x1, jint y1, jint x2, jint y2)
JNIEXPORT jint JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_getVideoType(JNIEnv *env, jclass obj)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onResize(JNIEnv *env, jclass obj, jint width, jint height)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onRotationQUAT(JNIEnv *env, jclass obj, jfloat quatX, jfloat quatY, jfloat quatZ, jfloat quatW)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_initMediaPipeAssetManager(JNIEnv *env, jclass obj, jobject assetManager, jstring cacheDirPath)
JNIEXPORT void JNICALL Java_ch_bfh_cpvrlab_AppAndroidJNI_onTerminate(JNIEnv *env, jclass obj)
static int svIndex
Pointer to JAVA environment used in ray tracing callback.
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.
The AppCommon class holds the top-level instances of the app-demo.
static SLint dpi
Dot per inch resolution of screen.
vector< SLstring > SLVstring
#define SL_EXIT_MSG(message)
SLMouseButton
Mouse button codes.
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)
void slMouseMove(int sceneViewIndex, int x, int y)
void slSwitchScene(SLSceneView *sv, SLSceneID sceneID)
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 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)
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 ¶meter, SLstring value)
Adds a value to the applications device parameter map.
Declaration of the main Scene Library C-Interface.
static SLstring calibIniPath
That's where data/calibrations folder is located.
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
static SLAssetManager * assetManager
asset manager is the owner of all assets
static SLVSceneView sceneViews
Vector of sceneview pointers.
static SLAssetLoader * assetLoader
Asset-loader for async asset loading.
static SLScene * scene
Pointer to the one and only SLScene instance.
static SLstring calibFilePath
That's where calibrations are stored and loaded from.
Encapsulation of the OpenCV Capture Device and holder of the last frame.
void loadCalibrations(const string &computerInfo, const string &configPath)
CVCamera * activeCamera
Pointer to the active camera.
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.
CVSize captureSize
size of captured frame
void videoType(CVVideoType vt)
Setter for video type also sets the active calibration.
void setCameraSize(int sizeIndex, int sizeIndexMax, int width, int height)
static CVCapture * instance()
Public static instance getter for singleton pattern.
void loadIntoLastFrame(float vieportWdivH, int camWidth, int camHeight, CVPixelFormatGL srcPixelFormat, const uchar *data, bool isContinuous)
bool grabAndAdjustForSL(float viewportWdivH)
void checkIfAsyncLoadingIsDone()
The SLScene class represents the top level instance holding the scene structure.
SceneView class represents a dynamic real time 3D view onto the scene.
void viewportSameAsVideo(bool sameAsVideo)
void setViewportFromRatio(const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
Sets the viewport ratio and the viewport rectangle.
SLViewportAlign viewportAlign() const
SLfloat viewportWdivH() const
int run(Config config)
App::run implementation from App.h for the Emscripten platform.
Config config
The configuration set in App::run.
App configuration struct to be passed to the App::run function.
OnGuiLoadConfigCallback onGuiLoadConfig
OnNewSceneViewCallback onNewSceneView
OnUpdateCallback onUpdate
OnGuiSaveConfigCallback onGuiSaveConfig
OnGuiBuildCallback onGuiBuild