Skip to content

Commit

Permalink
WIP update Android SDK and fix videoInit
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorstenBux committed Jan 18, 2018
1 parent de86622 commit b7ef3a6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
9 changes: 5 additions & 4 deletions AndroidStudioProjects/ARBaseLibProj/aRBaseLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion = 25 // The version of the Android API, i.e. SDK, the app is compiled against
buildToolsVersion = "25.0.2" // The downloaded version of the Build Tools used to build Android application code
compileSdkVersion = 27 // The version of the Android API, i.e. SDK, the app is compiled against
buildToolsVersion = "27.0.3" // The downloaded version of the Build Tools used to build Android application code

defaultConfig {
minSdkVersion 15 // Signals the Google Play Store as to what device, running this minimum indicated or greater version, an app can be installed on
targetSdkVersion 24 // Indicates the version of the latest API feature set that can be used and that you have tested your app on (presumably up to and including)
targetSdkVersion 27 // Indicates the version of the latest API feature set that can be used and that you have tested your app on (presumably up to and including)
versionCode = 2 // Integer type incremented by 1 for every release, major or minor, to the Google store
versionName = "2.0" // The real fully qualified major and minor release description

Expand All @@ -21,5 +21,6 @@ android {

dependencies {
// compile 'com.android.support:support-v4:24.2.1'// Only required when the target device API level is greater than
compile 'com.android.support:appcompat-v7:25.1.0' // the compile and target of the app being deployed to the device
// the compile and target of the app being deployed to the device
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ public GLSurfaceView getGLView() {
}

@Override
public void cameraPreviewStarted(int width, int height, int rate, int cameraIndex, boolean cameraIsFrontFacing) {
public void cameraPreviewStarted(int width, int height, int rate, String pixelFormat, int cameraIndex, boolean cameraIsFrontFacing) {

if (ARToolKit.getInstance().startWithPushedVideo(width, height, null, cameraIndex, cameraIsFrontFacing)) {
if (ARToolKit.getInstance().startWithPushedVideo(width, height, pixelFormat, null, cameraIndex, cameraIsFrontFacing)) {
// Expects Data to be already in the cache dir. This can be done with the AssetUnpacker.
Log.i(TAG, "cameraPreviewStarted(): Camera initialised");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public class ARToolKit {
else Log.i(TAG, "Loaded native library.");
}

private int frameWidth;
private int frameHeight;
private int cameraIndex;
private boolean cameraIsFrontFacing;

/**
* Array of RGB color values containing the debug video image data.
*/
Expand Down Expand Up @@ -170,6 +175,11 @@ public boolean nativeInitialised() {
*/
public boolean startWithPushedVideo(int videoWidth, int videoHeight, String pixelFormat, String cameraParaPath, int cameraIndex, boolean cameraIsFrontFacing) {

this.frameWidth = videoWidth;
this.frameHeight = videoHeight;
this.cameraIndex = cameraIndex;
this.cameraIsFrontFacing = cameraIsFrontFacing;

if (!initedNative) {
Log.e(TAG, "startWithPushedVideo(): Cannot start because native interface not inited.");
return false;
Expand Down Expand Up @@ -346,7 +356,7 @@ public boolean isRunning() {
*/
public boolean convertAndDetect1(byte[] frame, int frameSize) {

if ((!isNativeInited()) || (frame == null)) {
if ((!initedNative) || (frame == null)) {
return false;
}

Expand All @@ -369,7 +379,7 @@ public boolean convertAndDetect1(byte[] frame, int frameSize) {
*/
public boolean convertAndDetect2(ByteBuffer[] framePlanes, int[] framePlanePixelStrides, int[] framePlaneRowStrides) {

if ((!isNativeInited()) || (framePlanes == null)) {
if ((!initedNative) || (framePlanes == null)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ public interface CameraEventListener {
* @param width The width of the video image in pixels.
* @param height The height of the video image in pixels.
* @param rate The capture rate in frames per second.
* @param pixelFormat A string with format in which buffers will be pushed. Supported values include "NV21", "NV12", "YUV_420_888", "RGBA", "RGB_565", and "MONO".
* @param cameraIndex Zero-based index of the camera in use. If only one camera is present, will be 0.
* @param cameraIsFrontFacing false if camera is rear-facing (the default) or true if camera is facing toward the user.
*/
public void cameraPreviewStarted(int width, int height, int rate, int cameraIndex, boolean cameraIsFrontFacing);
public void cameraPreviewStarted(int width, int height, int rate, String pixelFormat, int cameraIndex, boolean cameraIsFrontFacing);

/**
* Called when the camera preview has a new frame ready.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
camera.startPreview();

if (listener != null)
listener.cameraPreviewStarted(captureWidth, captureHeight, captureRate, cameraIndex, cameraIsFrontFacing);
listener.cameraPreviewStarted(captureWidth, captureHeight, captureRate,"NV21", cameraIndex, cameraIsFrontFacing);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions AndroidStudioProjects/ARSimpleProj/aRSimple/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion = 25 // The version of the Android API, i.e. SDK, the app is compiled against
buildToolsVersion = "25.0.2" // The downloaded version of the Build Tools used to build Android application code
compileSdkVersion = 27 // The version of the Android API, i.e. SDK, the app is compiled against
buildToolsVersion = "27.0.3" // The downloaded version of the Build Tools used to build Android application code

defaultConfig {
applicationId = "org.artoolkit.ar.samples.ARSimple"
minSdkVersion 15 // Signals the Google Play Store as to what device, running this minimum indicated or greater version, an app can be installed on
targetSdkVersion 24 // Indicates the version that you have tested your app on (presumably up to and including)
targetSdkVersion 27 // Indicates the version that you have tested your app on (presumably up to and including)
versionCode = 5000 // Integer type incremented by 1 for every release, major or minor, to Google store
versionName = "5.0" // Real fully qualified major and minor release description

Expand Down

0 comments on commit b7ef3a6

Please sign in to comment.