From cc0b288464da697edc686219fc2e802a9e0cb3a4 Mon Sep 17 00:00:00 2001 From: mattiabaro98 Date: Fri, 17 Nov 2023 17:25:55 +0100 Subject: [PATCH 1/2] implement periodic acquisitions with thread --- wrappers/android/build.gradle | 2 +- wrappers/android/gradle.properties | 19 +- wrappers/android/gradlew | 263 +++++++++++------- wrappers/android/gradlew.bat | 191 ++++++------- .../main/assets/presets/ShortRangePreset.json | 150 +++++++--- wrappers/android/tools/camera/build.gradle | 12 +- .../tools/camera/src/main/AndroidManifest.xml | 6 + .../realsense/camera/ExportCallback.java | 5 + .../intel/realsense/camera/FrameExporter.java | 77 +++++ .../camera/Models/ExportModel.java.back | 58 ++++ .../camera/Models/State/ExportState.java | 13 + .../realsense/camera/RecordingActivity.java | 90 ++++-- .../res/layout-land/activity_recording.xml | 1 + .../main/res/layout/activity_recording.xml | 1 + wrappers/python/pyrsutil.cpp | 4 +- 15 files changed, 606 insertions(+), 286 deletions(-) create mode 100644 wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/ExportCallback.java create mode 100644 wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/FrameExporter.java create mode 100644 wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/ExportModel.java.back create mode 100644 wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/State/ExportState.java diff --git a/wrappers/android/build.gradle b/wrappers/android/build.gradle index 98518eea6ed..47a85343bf9 100644 --- a/wrappers/android/build.gradle +++ b/wrappers/android/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' + classpath 'com.android.tools.build:gradle:7.4.2' // NOTE: Do not place your application dependencies here; they belong diff --git a/wrappers/android/gradle.properties b/wrappers/android/gradle.properties index d546deaf0e2..2fe674e12d3 100644 --- a/wrappers/android/gradle.properties +++ b/wrappers/android/gradle.properties @@ -1,17 +1,16 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit +## For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html +# # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m +# Default value: -Xmx1024m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +# # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true - - +#Fri Nov 17 12:25:02 CET 2023 +android.enableJetifier=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" diff --git a/wrappers/android/gradlew b/wrappers/android/gradlew index 2fe81a7d95e..a69d9cb6c20 100644 --- a/wrappers/android/gradlew +++ b/wrappers/android/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,101 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/wrappers/android/gradlew.bat b/wrappers/android/gradlew.bat index 9618d8d9607..53a6b238d41 100644 --- a/wrappers/android/gradlew.bat +++ b/wrappers/android/gradlew.bat @@ -1,100 +1,91 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json b/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json index 76579154e59..0701cdd2b6a 100644 --- a/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json +++ b/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json @@ -1,47 +1,105 @@ { - "param-censususize": 9, - "param-censusvsize": 3, - "param-disableraucolor": 0, - "param-disablesadcolor": 0, - "param-disablesadnormalize": 0, - "param-disablesloleftcolor": 0, - "param-disableslorightcolor": 0, - "param-lambdaad": 2000.0, - "param-lambdacensus": 39, - "param-leftrightthreshold": 52, - "param-maxscorethreshb": 2000, - "param-medianthreshold": 100, - "param-minscorethresha": 13, - "param-neighborthresh": 1, - "param-raumine": 6, - "param-rauminn": 1, - "param-rauminnssum": 1, - "param-raumins": 1, - "param-rauminw": 4, - "param-rauminwesum": 8, - "param-regioncolorthresholdb": 0.02404790738643174, - "param-regioncolorthresholdg": 0.05924149629687343, - "param-regioncolorthresholdr": 0.1693732549608611, - "param-regionshrinku": 4, - "param-regionshrinkv": 1, - "param-regionspatialthresholdu": 7, - "param-regionspatialthresholdv": 3, - "param-robbinsmonrodecrement": 11, - "param-robbinsmonroincrement": 1, - "param-rsmdiffthreshold": 4.707440954582961, - "param-rsmrauslodiffthreshold": 0.007420896027247603, - "param-rsmremovethreshold": 0.31771802714889097, - "param-scanlineedgetaub": 849, - "param-scanlineedgetaug": 515, - "param-scanlineedgetaur": 736, - "param-scanlinep1": 5, - "param-scanlinep1onediscon": 341, - "param-scanlinep1twodiscon": 248, - "param-scanlinep2": 56, - "param-scanlinep2onediscon": 28, - "param-scanlinep2twodiscon": 415, - "param-secondpeakdelta": 26, - "param-texturecountthresh": 0, - "param-texturedifferencethresh": 500, - "param-usersm": 1 -} \ No newline at end of file + "device": { + "fw version": "5.15.1", + "name": "Intel RealSense D455", + "product line": "D400" + }, + "parameters": { + "aux-param-autoexposure-setpoint": "1000", + "aux-param-colorcorrection1": "-0.493164", + "aux-param-colorcorrection10": "-0.272461", + "aux-param-colorcorrection11": "-0.272461", + "aux-param-colorcorrection12": "-0.355469", + "aux-param-colorcorrection2": "0.831055", + "aux-param-colorcorrection3": "0.831055", + "aux-param-colorcorrection4": "-0.368164", + "aux-param-colorcorrection5": "-0.133789", + "aux-param-colorcorrection6": "-0.323242", + "aux-param-colorcorrection7": "-0.323242", + "aux-param-colorcorrection8": "1.19141", + "aux-param-colorcorrection9": "0.90918", + "aux-param-depthclampmax": "680", + "aux-param-depthclampmin": "540", + "aux-param-disparityshift": "0", + "controls-autoexposure-auto": "True", + "controls-autoexposure-manual": "33000", + "controls-color-autoexposure-auto": "True", + "controls-color-autoexposure-manual": "166", + "controls-color-backlight-compensation": "0", + "controls-color-brightness": "0", + "controls-color-contrast": "50", + "controls-color-gain": "64", + "controls-color-gamma": "300", + "controls-color-hue": "0", + "controls-color-power-line-frequency": "3", + "controls-color-saturation": "64", + "controls-color-sharpness": "50", + "controls-color-white-balance-auto": "True", + "controls-color-white-balance-manual": "4600", + "controls-depth-gain": "16", + "controls-laserpower": "250", + "controls-laserstate": "on", + "ignoreSAD": "0", + "param-amplitude-factor": "0", + "param-autoexposure-setpoint": "1000", + "param-censusenablereg-udiameter": "9", + "param-censusenablereg-vdiameter": "9", + "param-censususize": "9", + "param-censusvsize": "9", + "param-depthclampmax": "680", + "param-depthclampmin": "540", + "param-depthunits": "2300", + "param-disableraucolor": "0", + "param-disablesadcolor": "0", + "param-disablesadnormalize": "0", + "param-disablesloleftcolor": "0", + "param-disableslorightcolor": "0", + "param-disparitymode": "0", + "param-disparityshift": "0", + "param-lambdaad": "800", + "param-lambdacensus": "26", + "param-leftrightthreshold": "24", + "param-maxscorethreshb": "2047", + "param-medianthreshold": "500", + "param-minscorethresha": "1", + "param-neighborthresh": "7", + "param-raumine": "1", + "param-rauminn": "1", + "param-rauminnssum": "3", + "param-raumins": "1", + "param-rauminw": "1", + "param-rauminwesum": "3", + "param-regioncolorthresholdb": "0.0499022", + "param-regioncolorthresholdg": "0.0499022", + "param-regioncolorthresholdr": "0.0499022", + "param-regionshrinku": "3", + "param-regionshrinkv": "1", + "param-robbinsmonrodecrement": "10", + "param-robbinsmonroincrement": "10", + "param-rsmdiffthreshold": "4", + "param-rsmrauslodiffthreshold": "1", + "param-rsmremovethreshold": "0.375", + "param-scanlineedgetaub": "72", + "param-scanlineedgetaug": "72", + "param-scanlineedgetaur": "72", + "param-scanlinep1": "60", + "param-scanlinep1onediscon": "105", + "param-scanlinep1twodiscon": "70", + "param-scanlinep2": "342", + "param-scanlinep2onediscon": "190", + "param-scanlinep2twodiscon": "130", + "param-secondpeakdelta": "325", + "param-texturecountthresh": "0", + "param-texturedifferencethresh": "0", + "param-usersm": "1", + "param-zunits": "2300" + }, + "schema version": 1, + "viewer": { + "stream-depth-format": "Z16", + "stream-fps": "30", + "stream-height": "720", + "stream-ir-format": "Y8", + "stream-width": "1280" + } +} diff --git a/wrappers/android/tools/camera/build.gradle b/wrappers/android/tools/camera/build.gradle index 5e0b26b121f..a1abefa0ad5 100644 --- a/wrappers/android/tools/camera/build.gradle +++ b/wrappers/android/tools/camera/build.gradle @@ -22,9 +22,9 @@ def getFwVersion(String productLine) { try { String versionsFile = new File("$projectDir/../../../../common/fw/firmware-version.h").text def regex = productLine + " \"(.*)\"" - def matcher = ( versionsFile =~ regex ) + def matcher = (versionsFile =~ regex) return matcher[0][1] - }catch(e){ + } catch (e) { println(e) return "Unknown FW version" } @@ -37,21 +37,21 @@ task downloadFirmware() { def d4xxFile = new File("$projectDir/src/main/res/raw/fw_d4xx.bin") if (!d4xxFile.exists()) { println("downloading D4xx fw: " + d4xxFwVersion) - new URL('https://librealsense.intel.com/Releases/RS4xx/FW/D4XX_FW_Image-' + d4xxFwVersion + '.bin').withInputStream{ i -> d4xxFile.withOutputStream{ it << i }} + new URL('https://librealsense.intel.com/Releases/RS4xx/FW/D4XX_FW_Image-' + d4xxFwVersion + '.bin').withInputStream { i -> d4xxFile.withOutputStream { it << i } } } - + def l51xFwVersion = getFwVersion('L51X_RECOMMENDED_FIRMWARE_VERSION') def l51xFile = new File("$projectDir/src/main/res/raw/fw_l51x.bin") if (!l51xFile.exists()) { println("downloading L51x fw: " + l51xFwVersion) - new URL('https://librealsense.intel.com/Releases/L5xx/FW/L51X_FW_Image-' + l51xFwVersion + '.bin').withInputStream{ i -> l51xFile.withOutputStream{ it << i }} + new URL('https://librealsense.intel.com/Releases/L5xx/FW/L51X_FW_Image-' + l51xFwVersion + '.bin').withInputStream { i -> l51xFile.withOutputStream { it << i } } } def sr3xxFwVersion = getFwVersion('SR3XX_RECOMMENDED_FIRMWARE_VERSION') def sr3xxFile = new File("$projectDir/src/main/res/raw/fw_sr3xx.bin") if (!sr3xxFile.exists()) { println("downloading SR3xx fw: " + sr3xxFwVersion) - new URL('https://librealsense.intel.com/Releases/SR300/FW/SR3XX_FW_Image-' + sr3xxFwVersion + '.bin').withInputStream{ i -> sr3xxFile.withOutputStream{ it << i }} + new URL('https://librealsense.intel.com/Releases/SR300/FW/SR3XX_FW_Image-' + sr3xxFwVersion + '.bin').withInputStream { i -> sr3xxFile.withOutputStream { it << i } } } } diff --git a/wrappers/android/tools/camera/src/main/AndroidManifest.xml b/wrappers/android/tools/camera/src/main/AndroidManifest.xml index 827c57c9d21..55096b8d7c4 100644 --- a/wrappers/android/tools/camera/src/main/AndroidManifest.xml +++ b/wrappers/android/tools/camera/src/main/AndroidManifest.xml @@ -2,9 +2,15 @@ + + + + { + exportFrameSet(basePath, frameSet, frameNumber); + callback.onComplete(); + }); + } + + public void exportFrameSet(Path basePath, final FrameSet frameSet, final int frameNumber) { + Path dir = Paths.get(basePath.toString(), this.exportDate); + Path path = this.getExportPathPath(dir, frameNumber); + Log.d("Export", path.toString()); + + try { + Files.createDirectories(dir); + } catch (IOException e) { + e.printStackTrace(); + return; + } + + DepthFrame d = frameSet.first(StreamType.DEPTH).as(Extension.DEPTH_FRAME); + assert d.is(Extension.DEPTH_FRAME); + + try (Pointcloud pc = new Pointcloud()) { + Points points = pc.process(d).as(Extension.POINTS); + + Points p = points.as(Extension.POINTS); + + VideoFrame v = frameSet.first(StreamType.COLOR).as(Extension.VIDEO_FRAME); + + p.exportToPly(path.toString(), v); + + Log.d("Export", "exported"); + } + } + + private Path getExportPathPath(Path basePath, int frameNumber) { + return Paths.get(basePath.toString(), frameNumber * 90 + ".ply"); + } + +} diff --git a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/ExportModel.java.back b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/ExportModel.java.back new file mode 100644 index 00000000000..b5a8aef4eaa --- /dev/null +++ b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/ExportModel.java.back @@ -0,0 +1,58 @@ +package com.intel.realsense.camera.Models; + +import android.util.Log; + +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; + +import com.intel.realsense.camera.ExportCallback; +import com.intel.realsense.camera.FrameExporter; +import com.intel.realsense.camera.Models.State.ExportState; +import com.intel.realsense.librealsense.FrameSet; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ExportModel extends ViewModel { + private static final int INTERVAL_MS = 5000; + + private long lastFrameTime = 0; + private int capturedFrames = 0; + private final FrameExporter exporter; + + private final MutableLiveData uiState = new MutableLiveData<>(new ExportState(0)); + + private final ExecutorService executorService = Executors.newFixedThreadPool(4); + + + public LiveData getUiState() { + return uiState; + } + + public ExportModel() { + this.lastFrameTime = System.currentTimeMillis(); + this.exporter = new FrameExporter(this.executorService); + } + + public void nextFrame(FrameSet frameSet, Path basePath) { + long time = System.currentTimeMillis(); + long diff = time - lastFrameTime; + + if (diff < INTERVAL_MS || capturedFrames >= 4) { + return; + } + exporter.exportInBackground(basePath, frameSet, capturedFrames, () -> { + Log.d("Export", String.format(Locale.ENGLISH, "Frame %d exported", capturedFrames)); + + Integer current = uiState.getValue().getExported(); + uiState.setValue(new ExportState(current + 1)); + }); + capturedFrames += 1; + lastFrameTime = time; + + } +} diff --git a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/State/ExportState.java b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/State/ExportState.java new file mode 100644 index 00000000000..d1b759e01ef --- /dev/null +++ b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/Models/State/ExportState.java @@ -0,0 +1,13 @@ +package com.intel.realsense.camera.Models.State; + +public class ExportState { + private final Integer exported; + + public ExportState(Integer exported) { + this.exported = exported; + } + + public Integer getExported() { + return exported; + } +} diff --git a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java index ae9cc18cf3c..a3822906b05 100644 --- a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java +++ b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java @@ -1,24 +1,41 @@ package com.intel.realsense.camera; import android.Manifest; +import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; +import android.os.AsyncTask; import android.os.Bundle; + import com.google.android.material.floatingactionbutton.FloatingActionButton; + import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.appcompat.app.AppCompatActivity; +import androidx.lifecycle.ViewModelProvider; + +import android.os.Environment; +import android.util.Log; import android.view.View; import android.view.WindowManager; +import android.widget.TextView; +import android.widget.Toast; +import com.intel.realsense.camera.Models.State.ExportState; import com.intel.realsense.librealsense.Config; import com.intel.realsense.librealsense.FrameSet; import com.intel.realsense.librealsense.GLRsSurfaceView; import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.Date; +import java.util.Locale; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; public class RecordingActivity extends AppCompatActivity { private static final String TAG = "librs camera rec"; @@ -29,6 +46,15 @@ public class RecordingActivity extends AppCompatActivity { private boolean mPermissionsGranted = false; private FloatingActionButton mStopRecordFab; + private Path basePath; + //private ExportModel exportModel; + private final ExecutorService executorService = Executors.newFixedThreadPool(4); + private FrameExporter exporter; + private static final int INTERVAL_MS = 5000; + + private long lastFrameTime = 0; + private int capturedFrames = 0; + private int exported = 0; @Override protected void onCreate(Bundle savedInstanceState) { @@ -44,6 +70,20 @@ protected void onCreate(Bundle savedInstanceState) { } mPermissionsGranted = true; + + // this.exportModel = new ViewModelProvider(this).get(ExportModel.class); + String exportDate = Instant.now().toString(); + + this.basePath = Paths.get(getExternalFilesDir(null).getAbsolutePath(), exportDate); + this.exporter = new FrameExporter(this.executorService); + // exportModel.getUiState().observe(this, uiState -> { + // Integer exported = uiState.getExported(); + // TextView textView = (TextView) findViewById(R.id.textView); + // textView.setText(String.format(Locale.ENGLISH, "Recorded measure %d/4", exported)); + // if (exported == 4) { + // finish(); + // } + // }); } @Override @@ -63,7 +103,7 @@ public void onConfigurationChanged(Configuration newConfig) { // handling device orientation changes to avoid interruption during recording // cleanup previous surface - if(mGLSurfaceView != null) { + if (mGLSurfaceView != null) { mGLSurfaceView.clear(); mGLSurfaceView.close(); } @@ -93,16 +133,17 @@ public void onClick(View view) { protected void onResume() { super.onResume(); - if(mPermissionsGranted){ - mStreamer = new Streamer(this,true, new Streamer.Listener() { + if (mPermissionsGranted) { + mStreamer = new Streamer(this, true, new Streamer.Listener() { @Override public void config(Config config) { - config.enableRecordToFile(getFilePath()); + // config.enableRecordToFile(getFilePath()); } @Override public void onFrameset(FrameSet frameSet) { mGLSurfaceView.upload(frameSet); + nextFrame(frameSet); } }); try { @@ -114,26 +155,39 @@ public void onFrameset(FrameSet frameSet) { } } + public void nextFrame(FrameSet frameSet) { + long time = System.currentTimeMillis(); + long diff = time - lastFrameTime; + + if (diff < INTERVAL_MS || capturedFrames >= 4) { + return; + } + exporter.exportInBackground(this.basePath, frameSet.clone(), capturedFrames, () -> { + Log.d("Export", String.format(Locale.ENGLISH, "Frame %d exported", capturedFrames)); + + exported += 1; + + if (exported == 4) { + + + finish(); + } + }); + + capturedFrames += 1; + lastFrameTime = time; + + } + @Override protected void onPause() { super.onPause(); - if(mStreamer != null) + if (mStreamer != null) mStreamer.stop(); - if(mGLSurfaceView != null) + if (mGLSurfaceView != null) mGLSurfaceView.clear(); } - private String getFilePath(){ - File rsFolder = new File(getExternalFilesDir(null).getAbsolutePath() + - File.separator + getString(R.string.realsense_folder)); - rsFolder.mkdir(); - File folder = new File(getExternalFilesDir(null).getAbsolutePath() + - File.separator + getString(R.string.realsense_folder) + File.separator + "video"); - folder.mkdir(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); - String currentDateAndTime = sdf.format(new Date()); - File file = new File(folder, currentDateAndTime + ".bag"); - return file.getAbsolutePath(); - } + } diff --git a/wrappers/android/tools/camera/src/main/res/layout-land/activity_recording.xml b/wrappers/android/tools/camera/src/main/res/layout-land/activity_recording.xml index 4fb07dbf761..6643956433f 100644 --- a/wrappers/android/tools/camera/src/main/res/layout-land/activity_recording.xml +++ b/wrappers/android/tools/camera/src/main/res/layout-land/activity_recording.xml @@ -31,4 +31,5 @@ android:clickable="true" android:backgroundTint="#000000" app:srcCompat="@android:drawable/ic_media_pause" /> + \ No newline at end of file diff --git a/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml b/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml index 1f1a69c3cf3..bd5bb84584b 100644 --- a/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml +++ b/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml @@ -31,4 +31,5 @@ android:clickable="true" android:backgroundTint="#000000" app:srcCompat="@android:drawable/ic_media_pause" /> + \ No newline at end of file diff --git a/wrappers/python/pyrsutil.cpp b/wrappers/python/pyrsutil.cpp index a2397bab383..2f071d10217 100644 --- a/wrappers/python/pyrsutil.cpp +++ b/wrappers/python/pyrsutil.cpp @@ -51,7 +51,7 @@ void init_util(py::module &m) { }; m.def("rs2_project_color_pixel_to_depth_pixel", cp_to_dp, "Given pixel coordinates of the color image and a minimum and maximum depth, compute the corresponding pixel coordinates in the depth image. Returns [-1 -1] on failure.", - "data"_a, "depth_scale"_a, "depth_min"_a, "depth_max"_a, "depth_intrin"_a, "color_intrin"_a, "color_to_depth"_a, - "depth_to_color"_a, "from_pixel"_a); + "data"_a, "depth_scale"_a, "depth_min"_a, "depth_max"_a, "depth_intrin"_a, "color_intrin"_a, "depth_to_color"_a, + "color_to_depth"_a, "from_pixel"_a); /** end rsutil.h **/ } From 031596cc8659f5c1510a83ad1ccae12c4dc02a84 Mon Sep 17 00:00:00 2001 From: mattiabaro98 Date: Wed, 22 Nov 2023 17:18:20 +0100 Subject: [PATCH 2/2] update periodic acquisition --- third-party/rsutils/include/rsutils/version.h | 2 +- .../main/assets/presets/ShortRangePreset.json | 8 +++--- .../intel/realsense/camera/FrameExporter.java | 11 ++++---- .../realsense/camera/RecordingActivity.java | 25 ++++++++++++------- .../main/res/layout/activity_recording.xml | 1 - 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/third-party/rsutils/include/rsutils/version.h b/third-party/rsutils/include/rsutils/version.h index c3cb0e21d1d..bf8330cef2c 100644 --- a/third-party/rsutils/include/rsutils/version.h +++ b/third-party/rsutils/include/rsutils/version.h @@ -5,7 +5,7 @@ #include #include -#include + struct tm; diff --git a/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json b/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json index 0701cdd2b6a..1995839c77b 100644 --- a/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json +++ b/wrappers/android/librealsense/src/main/assets/presets/ShortRangePreset.json @@ -18,8 +18,8 @@ "aux-param-colorcorrection7": "-0.323242", "aux-param-colorcorrection8": "1.19141", "aux-param-colorcorrection9": "0.90918", - "aux-param-depthclampmax": "680", - "aux-param-depthclampmin": "540", + "aux-param-depthclampmax": "690", + "aux-param-depthclampmin": "480", "aux-param-disparityshift": "0", "controls-autoexposure-auto": "True", "controls-autoexposure-manual": "33000", @@ -46,8 +46,8 @@ "param-censusenablereg-vdiameter": "9", "param-censususize": "9", "param-censusvsize": "9", - "param-depthclampmax": "680", - "param-depthclampmin": "540", + "param-depthclampmax": "690", + "param-depthclampmin": "480", "param-depthunits": "2300", "param-disableraucolor": "0", "param-disablesadcolor": "0", diff --git a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/FrameExporter.java b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/FrameExporter.java index 079fd7379c6..7c65126da03 100644 --- a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/FrameExporter.java +++ b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/FrameExporter.java @@ -30,20 +30,19 @@ public class FrameExporter { private final Executor executor; - public FrameExporter(Executor executor) { this.executor = executor; } - public void exportInBackground(Path basePath, FrameSet frameSet, int frameNumber, ExportCallback callback) { + public void exportInBackground(Path basePath, FrameSet frameSet, int frameNumber, ExportCallback callback, final String exportDate) { this.executor.execute(() -> { - exportFrameSet(basePath, frameSet, frameNumber); + exportFrameSet(basePath, frameSet, frameNumber, exportDate); callback.onComplete(); }); } - public void exportFrameSet(Path basePath, final FrameSet frameSet, final int frameNumber) { - Path dir = Paths.get(basePath.toString(), this.exportDate); + public void exportFrameSet(Path basePath, final FrameSet frameSet, final int frameNumber, final String exportDate) { + Path dir = Paths.get(basePath.toString()); Path path = this.getExportPathPath(dir, frameNumber); Log.d("Export", path.toString()); @@ -71,7 +70,7 @@ public void exportFrameSet(Path basePath, final FrameSet frameSet, final int fra } private Path getExportPathPath(Path basePath, int frameNumber) { - return Paths.get(basePath.toString(), frameNumber * 90 + ".ply"); + return Paths.get(basePath.toString(), frameNumber*90 + ".ply"); } } diff --git a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java index a3822906b05..4d2ac7fc650 100644 --- a/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java +++ b/wrappers/android/tools/camera/src/main/java/com/intel/realsense/camera/RecordingActivity.java @@ -50,11 +50,14 @@ public class RecordingActivity extends AppCompatActivity { //private ExportModel exportModel; private final ExecutorService executorService = Executors.newFixedThreadPool(4); private FrameExporter exporter; - private static final int INTERVAL_MS = 5000; + private static final int INTERVAL_MS = 10000; private long lastFrameTime = 0; private int capturedFrames = 0; private int exported = 0; + private String exportDate; + + long absolute_time_start; @Override protected void onCreate(Bundle savedInstanceState) { @@ -72,10 +75,11 @@ protected void onCreate(Bundle savedInstanceState) { mPermissionsGranted = true; // this.exportModel = new ViewModelProvider(this).get(ExportModel.class); - String exportDate = Instant.now().toString(); + this.exportDate = Instant.now().toString(); - this.basePath = Paths.get(getExternalFilesDir(null).getAbsolutePath(), exportDate); + this.basePath = Paths.get(getExternalFilesDir(null).getAbsolutePath(), this.exportDate); this.exporter = new FrameExporter(this.executorService); + this.absolute_time_start = System.currentTimeMillis(); // exportModel.getUiState().observe(this, uiState -> { // Integer exported = uiState.getExported(); // TextView textView = (TextView) findViewById(R.id.textView); @@ -143,7 +147,7 @@ public void config(Config config) { @Override public void onFrameset(FrameSet frameSet) { mGLSurfaceView.upload(frameSet); - nextFrame(frameSet); + nextFrame(frameSet, exportDate); } }); try { @@ -155,24 +159,27 @@ public void onFrameset(FrameSet frameSet) { } } - public void nextFrame(FrameSet frameSet) { + public void nextFrame(FrameSet frameSet, final String exportDate) { long time = System.currentTimeMillis(); long diff = time - lastFrameTime; - - if (diff < INTERVAL_MS || capturedFrames >= 4) { + // || capturedFrames >= 4 + if (diff < INTERVAL_MS) { return; } + long absolute_time = System.currentTimeMillis() - absolute_time_start; + Log.d("Export", String.format(Locale.ENGLISH, "At instant %d", absolute_time)); + Log.d("Export", String.format(Locale.ENGLISH, "Exporting frame %d ...", capturedFrames)); exporter.exportInBackground(this.basePath, frameSet.clone(), capturedFrames, () -> { Log.d("Export", String.format(Locale.ENGLISH, "Frame %d exported", capturedFrames)); exported += 1; - if (exported == 4) { + if (exported == 1) { finish(); } - }); + }, exportDate); capturedFrames += 1; lastFrameTime = time; diff --git a/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml b/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml index bd5bb84584b..1f1a69c3cf3 100644 --- a/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml +++ b/wrappers/android/tools/camera/src/main/res/layout/activity_recording.xml @@ -31,5 +31,4 @@ android:clickable="true" android:backgroundTint="#000000" app:srcCompat="@android:drawable/ic_media_pause" /> - \ No newline at end of file