Skip to content

Commit

Permalink
Updates Wikitude Cordova plugin to use Wikitude SDK 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pnagele committed Mar 31, 2020
1 parent 99846f2 commit e7c8030
Show file tree
Hide file tree
Showing 57 changed files with 388 additions and 118 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "com.wikitude.phonegap.wikitudeplugin",
"version": "8.10.1",
"version": "9.0.0",
"description": "Augmented Reality Wikitude SDK Plugin \n The Wikitude Cordova Plugin enables developers to embed an augmented reality view into their Cordova project. You can create a fully featured app with advanced augmented reality features, including image recognition, object recognition purely using HTML, CSS and JavaScript.\n ",
"cordova": {
"id": "",
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.wikitude.phonegap.WikitudePlugin"
version="8.10.1">
id="com.wikitude.phonegap.wikitudeplugin"
version="9.0.0">

<name>Augmented Reality - Wikitude SDK Plugin</name>

Expand Down
5 changes: 2 additions & 3 deletions src/android/WikitudePlugin.java
Expand Up @@ -49,15 +49,14 @@
import com.wikitude.architect.ArchitectView.CaptureScreenCallback;
import com.wikitude.architect.ArchitectStartupConfiguration;
import com.wikitude.common.camera.CameraSettings;
import com.wikitude.phonegap.WikitudePlugin.ArchitectViewPhoneGap.OnKeyUpDownListener;
import com.wikitude.tools.device.features.MissingDeviceFeatures;



/**
* Basic PhoneGap Wikitude ARchitect Plugin
*
* You must add "<plugin name="WikitudePlugin" value="com.wikitude.phonegap.WikitudePlugin"/>"
* You must add "<plugin name="wikitudeplugin" value="com.wikitude.phonegap.wikitudeplugin"/>"
* in config.xml to enable this plug-in in your project
*
* Also ensure to have wikitudesdk.jar in your libs folder
Expand Down Expand Up @@ -834,7 +833,7 @@ private void addArchitectView( final String apiKey, String filePath, int feature

WikitudePlugin.releaseFocusInCordovaWebView(cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content));

this.architectView = new ArchitectViewPhoneGap( this.cordova.getActivity() , new OnKeyUpDownListener() {
this.architectView = new ArchitectViewPhoneGap( this.cordova.getActivity() , new ArchitectViewPhoneGap.OnKeyUpDownListener() {

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
Expand Down
2 changes: 1 addition & 1 deletion src/android/build-extras.gradle
@@ -1,6 +1,6 @@
dependencies {
compile (name: 'wikitudesdk', ext:'aar')
compile 'com.google.ar:core:1.5.0'
compile 'com.google.ar:core:1.15.0'
}

repositories {
Expand Down
Binary file modified src/android/wikitudesdk.aar
Binary file not shown.
19 changes: 18 additions & 1 deletion src/ios/WTWikitudePlugin.m
Expand Up @@ -79,6 +79,7 @@ @interface WTWikitudePlugin () <WTArchitectViewDelegate, WTArchitectViewControll
@property (nonatomic, strong) NSString *accessRequestCallbackId;
@property (nonatomic, strong) NSString *deviceSensorsNeedCalibrationCallbackId;
@property (nonatomic, strong) NSString *deviceSensorsFinishedCalibrationCallbackId;
@property (nonatomic, strong) NSString *onBackButtonCallbackId;

@property (nonatomic, assign) BOOL isUsingInjectedLocation;
@property (nonatomic, assign) BOOL isDeviceSupported;
Expand Down Expand Up @@ -607,6 +608,18 @@ - (void)onResume:(CDVInvokedUrlCommand *)command
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)setBackButtonCallback:(CDVInvokedUrlCommand *)command
{
CDVPluginResult* pluginResult = nil;

self.onBackButtonCallbackId = command.callbackId;

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
[pluginResult setKeepCallbackAsBool:YES];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)onPause:(CDVInvokedUrlCommand *)command
{

Expand Down Expand Up @@ -941,7 +954,11 @@ - (void)didReceiveArchitectDebugMessageNotification:(NSNotification *)aNotificat

- (void)architectViewControllerWillDisappear:(WTArchitectViewController *)architectViewController
{
[self close:nil];
CDVPluginResult* pluginResult = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[pluginResult setKeepCallbackAsBool:YES];

[self.commandDelegate sendPluginResult:pluginResult callbackId:self.onBackButtonCallbackId];
}


Expand Down
38 changes: 38 additions & 0 deletions src/ios/WikitudeSDK.framework/Headers/CameraFocusMode.hpp
@@ -0,0 +1,38 @@
//
// CameraFocusMode.hpp
// WikitudeUniversalSDK
//
// Created by Aitor Font on 11.03.20.
// Copyright © 2020 Wikitude. All rights reserved.
//

#ifndef CameraFocusMode_hpp
#define CameraFocusMode_hpp

#ifdef __cplusplus

#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {

namespace impl {

/**
* @brief Use this enum to determine the focus mode of the camera.
*/
enum class WT_EXPORT_API CameraFocusMode {
/** Once: The device automatically adjusts the focus once. */
Once,
/** Continuous: The device continuously monitors focus and autofocuses when necessary. */
Continuous,
/** Off: The device has its focus locked */
Off
};
}
using impl::CameraFocusMode;
}}

#endif /* __cplusplus */

#endif /* CameraFocusMode_hpp */
9 changes: 5 additions & 4 deletions src/ios/WikitudeSDK.framework/Headers/CameraFrame.hpp
Expand Up @@ -21,6 +21,7 @@
#include "DepthDataFormat.hpp"
#include "CameraFramePlane.hpp"
#include "Matrix4.hpp"
#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {
Expand All @@ -30,7 +31,7 @@ namespace wikitude { namespace sdk {
/** @class DepthCameraFrameMetadata
* @brief A class that encapsulates additional information about depth camera frames.
*/
class DepthCameraFrameMetadata {
class WT_EXPORT_API DepthCameraFrameMetadata {
public:
DepthCameraFrameMetadata(float horizontalFov_, sdk::Size<int> pixelSize_, unsigned int dataSize_, DepthDataFormat depthDataFormat_, bool inverted_, std::int32_t timestampTimescale_);

Expand Down Expand Up @@ -74,7 +75,7 @@ namespace wikitude { namespace sdk {
Atan = 3,
};

class IntrinsicsCalibration {
class WT_EXPORT_API IntrinsicsCalibration {
public:
IntrinsicsCalibration(DistortionMode distortionMode_, Point<double> principalPoint_, Point<double> focalLength_, const std::vector<double>& distortion_);

Expand All @@ -93,7 +94,7 @@ namespace wikitude { namespace sdk {
/** @class ColorCameraFrameMetadata
* @brief A class that encapsulates additional information about color camera frames.
*/
class ColorCameraFrameMetadata {
class WT_EXPORT_API ColorCameraFrameMetadata {
public:
ColorCameraFrameMetadata(float horizontalFov_, sdk::Size<int> pixelSize_, CameraPosition cameraPosition_, ColorSpace frameColorSpace_, std::int32_t timestampTimescale_);

Expand Down Expand Up @@ -141,7 +142,7 @@ namespace wikitude { namespace sdk {
/** @class CameraFrame
* @brief A class that color and depth frames, along with their metadata and optional pose. The CameraFrame class doesn't copy or retain the color and depth data in any way.
*/
class CameraFrame {
class WT_EXPORT_API CameraFrame {
public:
CameraFrame(long id_, std::int64_t colorTimestamp_, ColorCameraFrameMetadata colorMetadata_, const std::vector<CameraFramePlane>& colorData_);
CameraFrame(long id_, std::int64_t colorTimestamp_, ColorCameraFrameMetadata colorMetadata_, const std::vector<CameraFramePlane>& colorData_, const Matrix4& pose_);
Expand Down
Expand Up @@ -15,6 +15,8 @@
#include <functional>

#include "Error.hpp"
#include "ErrorHandling.hpp"
#include "CameraFocusMode.hpp"
#include "CameraFrame.hpp"
#include "CompilerAttributes.hpp"

Expand Down Expand Up @@ -48,6 +50,11 @@ namespace wikitude { namespace sdk {
virtual void pauseCameraFrameUpdates();
virtual void resumeCameraFrameUpdates();

/**
* Implement this method if this plugin module supports camera focus mode changes.
*/
virtual sdk::CallStatus setFocusMode(CameraFocusMode focusMode_);

/**
* Default: false
*/
Expand All @@ -57,6 +64,7 @@ namespace wikitude { namespace sdk {
void registerOnPluginCameraReleasedHandler(std::function<void()> onPluginCameraReleasedHandler_);
void registerNotifyNewUnmanagedCameraFrameHandler(std::function<void(const sdk::CameraFrame& cameraFrame_)> notifyNewUnmanagedCameraFrameHandler_);
void registerCameraToSurfaceAngleChangedHandler(std::function<void(float cameraToSurfaceAngle_)> cameraToSurfaceAngleChangedHandler_);
void registerOnPluginCameraErrorHandler(std::function<void(const sdk::Error& error_)> onPluginCameraErrorHandler_);

protected:
/**
Expand All @@ -72,6 +80,8 @@ namespace wikitude { namespace sdk {

void setCameraToSurfaceAngle(float cameraToSurfaceAngle_);

void onPluginCameraError(const sdk::Error& error_);

protected:
bool _requestsCameraFrameRendering = false;
bool _userDisabledCameraFrameUpdates = false;
Expand All @@ -80,6 +90,7 @@ namespace wikitude { namespace sdk {
std::function<void()> _onPluginCameraReleasedHandler;
std::function<void(const sdk::CameraFrame&)> _notifyNewUnmanagedCameraFrameHandler;
std::function<void(float)> _cameraToSurfaceAngleChangedHandler;
std::function<void(const sdk::Error&)> _onPluginCameraErrorHandler;
};
}
using impl::CameraFrameInputPluginModule;
Expand Down
4 changes: 3 additions & 1 deletion src/ios/WikitudeSDK.framework/Headers/CameraFramePlane.hpp
Expand Up @@ -11,14 +11,16 @@

#ifdef __cplusplus

#include "CompilerAttributes.hpp"

namespace wikitude { namespace sdk {

namespace impl {

/** @class CameraFramePlane
* @brief A single plane of image data.
*/
class CameraFramePlane {
class WT_EXPORT_API CameraFramePlane {
public:
CameraFramePlane(const void* data_, unsigned int dataSize_, int pixelStride_ = -1, int rowStride_ = -1);
virtual ~CameraFramePlane() = default;
Expand Down
3 changes: 2 additions & 1 deletion src/ios/WikitudeSDK.framework/Headers/CameraParameters.hpp
Expand Up @@ -13,6 +13,7 @@

#include "Geometry.hpp"
#include "CameraPosition.hpp"
#include "CompilerAttributes.hpp"

#include "PlatformCameraHandler.hpp"

Expand All @@ -38,7 +39,7 @@ namespace wikitude { namespace sdk {
*
* PlatformComponent developer typically create a subclass and add more getter that are related to platform specific camera information.
*/
class CameraParameters {
class WT_EXPORT_API CameraParameters {
public:

/**
Expand Down
5 changes: 4 additions & 1 deletion src/ios/WikitudeSDK.framework/Headers/CameraPosition.hpp
Expand Up @@ -11,14 +11,17 @@

#ifdef __cplusplus

#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {

namespace impl {

/** @enum CameraPosition
* @brief An enum indicating the physical position of the camera used to capture frames.
*/
enum class CameraPosition : int {
enum class WT_EXPORT_API CameraPosition : int {
/** @brief Indicates that the camera position is undefined. Desktop web cams might return this value.
*/
Unspecified,
Expand Down
4 changes: 3 additions & 1 deletion src/ios/WikitudeSDK.framework/Headers/ColorSpace.hpp
Expand Up @@ -11,13 +11,15 @@

#ifdef __cplusplus

#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {

namespace impl {


enum ColorSpace {
enum WT_EXPORT_API ColorSpace {
/**
* Represents a color space where image data is given in a YUV 420 format, arranged to be compliant to the NV21 standard.
* The data size is frame width * frame height * 3/2, meaning full luminance resolution and half the size for chroma red * chroma blue
Expand Down
4 changes: 4 additions & 0 deletions src/ios/WikitudeSDK.framework/Headers/CompilerAttributes.hpp
Expand Up @@ -20,7 +20,11 @@
#endif

#if defined(_WIN32) || defined(__WIN32__)
#if defined(WKTD_EXPORT_LIBRARY_API)
#define WT_EXPORT_API __declspec(dllexport)
#else
#define WT_EXPORT_API
#endif
#else
#define WT_EXPORT_API __attribute__ ((visibility("default")))
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/ios/WikitudeSDK.framework/Headers/DepthDataFormat.hpp
Expand Up @@ -11,12 +11,15 @@

#ifdef __cplusplus

#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {

namespace impl {


enum class DepthDataFormat {
enum class WT_EXPORT_API DepthDataFormat {
FLOAT_32,
FLOAT_32_NORMALIZED,
INTEGER_8,
Expand Down
14 changes: 11 additions & 3 deletions src/ios/WikitudeSDK.framework/Headers/Error.hpp
Expand Up @@ -15,6 +15,8 @@
#include <memory>
#include <sstream>

#include "CompilerAttributes.hpp"


namespace wikitude { namespace sdk {

Expand All @@ -25,14 +27,17 @@ namespace wikitude { namespace sdk {
* A simple data type to represent an error. Domains help to reduce the amount of unique codes by introducing an additional layer of separation.
* Underlying erros can be specified to build up a chain of erros that explain the problem from various different layers. This should help explain where the error originates from.
*/
class Error {
class WT_EXPORT_API Error {
public:
Error(const int code_, const std::string& domain_, const std::string& message_, std::unique_ptr<Error> underlyingError_ = nullptr);
/* Use this to construct an empty error, if certain APIs require an error object even if no error was actually triggered */
static Error NoError();

Error(const int code_, const std::string& domain_, const std::string& message_, std::unique_ptr<Error> underlyingError_ = nullptr, bool suppressErrorLogging_ = false);
Error(const Error& other_);
virtual ~Error() = default;

Error& operator = (const Error& other_);
friend std::ostream& operator << (std::ostream& os_, const Error& error_);
friend WT_EXPORT_API std::ostream& operator << (std::ostream& os_, const Error& error_);


int getCode() const;
Expand Down Expand Up @@ -71,6 +76,9 @@ namespace wikitude { namespace sdk {

private:
std::string getUnderlyingFormattedDescription() const;

/* This is private in order to force the usage of the more explicit NoError static function */
Error();

protected:
int _code;
Expand Down
8 changes: 4 additions & 4 deletions src/ios/WikitudeSDK.framework/Headers/ErrorHandling.hpp
Expand Up @@ -20,10 +20,10 @@ namespace wikitude { namespace sdk {
namespace impl {


struct CallStatus {
struct WT_EXPORT_API CallStatus {
public:
static CallStatus Success() {
return {true, {0, "", ""}};
return {true, Error::NoError()};
}

public:
Expand All @@ -43,10 +43,10 @@ namespace wikitude { namespace sdk {


template <typename T>
struct CallValue {
struct WT_EXPORT_API CallValue {
public:
static CallValue<T> SuccessCallValue(T value_) {
return {value_, {true, {0, "", ""}}};
return {value_, {true, Error::NoError()}};
}

public:
Expand Down

0 comments on commit e7c8030

Please sign in to comment.