Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place anchor based on XY screen coordinates and update ARCore SDK to 1.35.0 #162

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8c1890e
upgrades
Jul 14, 2022
cd95346
parse touch location
Jul 14, 2022
3306369
fix session mgr
Jul 14, 2022
2c5aa01
Merge branch 'CariusLars:main' into main
dnkoulouris Oct 7, 2022
3015c0f
fix minor android issue
dnkoulouris Oct 7, 2022
32288e3
Merge branch 'CariusLars:main' into main
dnkoulouris Oct 26, 2022
3b1dc9c
fixes
dnkoulouris Oct 26, 2022
24830c2
core
dnkoulouris Oct 26, 2022
7d117e1
remove core
dnkoulouris Oct 26, 2022
5389f11
upgrade android versions
dnkoulouris Oct 26, 2022
a63245d
detach anchors
dnkoulouris Oct 26, 2022
1728864
prints
dnkoulouris Oct 26, 2022
873a41d
remove active notes before finish
dnkoulouris Oct 26, 2022
c6188e4
minor upgrade dep
dnkoulouris Oct 26, 2022
692a36a
fixes
dnkoulouris Oct 26, 2022
828c1fb
upgrade sceneform
dnkoulouris Oct 27, 2022
d76e03f
revert ios version
dnkoulouris Oct 27, 2022
569f632
Merge branch 'CariusLars:main' into main
dnkoulouris Dec 7, 2022
4653a6c
update arcore api to 1.35.0
dnkoulouris Dec 15, 2022
16fa29a
Bump up ARCore version to 1.33 for Apple Silicon (#164)
colejd Dec 23, 2022
e67bf7f
fixes
dnkoulouris Jan 10, 2023
3f0e74b
fixes
dnkoulouris Jan 10, 2023
795ee0c
upgrades
Jul 14, 2022
fb697c0
parse touch location
Jul 14, 2022
e5e97b4
fix session mgr
Jul 14, 2022
11d98d6
fix minor android issue
dnkoulouris Oct 7, 2022
dd760f9
fixes
dnkoulouris Oct 26, 2022
20dbfee
core
dnkoulouris Oct 26, 2022
1d4fb3a
remove core
dnkoulouris Oct 26, 2022
d754d7c
upgrade android versions
dnkoulouris Oct 26, 2022
0891366
detach anchors
dnkoulouris Oct 26, 2022
bbc7bb8
prints
dnkoulouris Oct 26, 2022
9fd0a46
remove active notes before finish
dnkoulouris Oct 26, 2022
3d2b5ee
minor upgrade dep
dnkoulouris Oct 26, 2022
81d8204
fixes
dnkoulouris Oct 26, 2022
d0d589a
upgrade sceneform
dnkoulouris Oct 27, 2022
917b30e
revert ios version
dnkoulouris Oct 27, 2022
b3f8b92
update arcore api to 1.35.0
dnkoulouris Dec 15, 2022
d1b942c
fixes
dnkoulouris Jan 10, 2023
75c6570
fixes
dnkoulouris Jan 10, 2023
3387e36
Merge remote-tracking branch 'origin/main'
dnkoulouris Jan 10, 2023
e8bfb7e
README.md updates and version bump
dnkoulouris Jan 10, 2023
32c3623
README.md updates and version bump
dnkoulouris Jan 10, 2023
33ef55e
initial geospatial api implementation
dnkoulouris May 18, 2023
2a93712
ios implementation
dnkoulouris May 19, 2023
be799e9
add alt
dnkoulouris May 29, 2023
aaa33a4
0.0.1
dnkoulouris Jun 2, 2023
2830535
test
dnkoulouris Jul 14, 2024
6ab19f7
update libraries
dnkoulouris Jul 16, 2024
9b7209a
Merge branch 'refs/heads/geospatial'
dnkoulouris Jul 16, 2024
8caf989
0.0.2
dnkoulouris Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

##0.7.4
* Uses New ARCore API 1.35.0 (ARCore API required to be enabled in Google Cloud Console)
* Place an anchor at point (X,Y) of screen programmatically

##0.7.3
* Update the examples with null-safety

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Or manually add this to your `pubspec.yaml` file (and run `flutter pub get`):

```yaml
dependencies:
ar_flutter_plugin: ^0.7.3
ar_flutter_plugin: ^0.7.4
```

### Importing
Expand Down
7 changes: 4 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.ar:core:1.22.0"
implementation "com.google.ar:core:1.35.0"

implementation 'com.google.ar.sceneform:core:1.15.0'
implementation 'com.google.ar.sceneform:assets:1.15.0'
implementation 'com.google.ar.sceneform:core:1.17.1'
implementation 'com.google.ar.sceneform:assets:1.17.1'

implementation 'com.google.android.gms:play-services-auth:16+'
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.17.1'
implementation 'androidx.appcompat:appcompat:1.3.0'

}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ import com.google.ar.sceneform.rendering.*
import android.view.ViewGroup

import com.google.ar.core.TrackingState












import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking


internal class AndroidARView(
Expand Down Expand Up @@ -116,6 +107,29 @@ internal class AndroidARView(
result.error("Error", "could not get camera pose", null)
}
}
"placeBasedOnCoordinates" -> {
if (call.arguments is Map<*,*>) {
val cpuCoordinates = floatArrayOf((call.arguments as Map<*, *>)['x'] as Float, (call.arguments as Map<*, *>)['y'] as Float)
val viewCoordinates = FloatArray(2)
if (arSceneView.arFrame != null) {
arSceneView.arFrame!!.transformCoordinates2d(
Coordinates2d.IMAGE_PIXELS,
cpuCoordinates,
Coordinates2d.VIEW,
viewCoordinates
)
val allHitResults = arSceneView.arFrame!!.hitTest(viewCoordinates[0], viewCoordinates[1])
val planeAndPointHitResults = allHitResults.filter { ((it.trackable is Plane) || (it.trackable is Point)) }
val serializedPlaneAndPointHitResults: ArrayList<HashMap<String, Any>> =
ArrayList(planeAndPointHitResults.map { serializeHitResult(it) })
result.success(serializedPlaneAndPointHitResults)
} else {
result.success(null)
}
} else {
result.success(null)
}
}
"snapshot" -> {
var bitmap = Bitmap.createBitmap(arSceneView.width, arSceneView.height,
Bitmap.Config.ARGB_8888);
Expand Down Expand Up @@ -452,16 +466,23 @@ internal class AndroidARView(

fun onDestroy() {
try {
arSceneView.session?.close()
arSceneView.destroy()
if (arSceneView.session != null) {
for (anchor in arSceneView.session!!.allAnchors) {
anchor?.detach()
}
}
cloudAnchorHandler.dispose();
arSceneView.scene?.removeOnUpdateListener(sceneUpdateListener)
arSceneView.scene?.removeOnPeekTouchListener(onNodeTapListener)
arSceneView.session?.close()
arSceneView.destroy()
}catch (e : Exception){
e.printStackTrace();
}
}

private fun initializeARView(call: MethodCall, result: MethodChannel.Result) {
Log.d(TAG, "initializeARView")
// Unpack call arguments
val argShowFeaturePoints: Boolean? = call.argument<Boolean>("showFeaturePoints")
val argPlaneDetectionConfig: Int? = call.argument<Int>("planeDetectionConfig")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class CloudAnchorHandler( arSession: Session ) {
}

private val TAG: String = CloudAnchorHandler::class.java.simpleName
private val pendingAnchors = HashMap<Anchor, Pair<String?, CloudAnchorListener?>>()
val pendingAnchors = HashMap<Anchor, Pair<String?, CloudAnchorListener?>>()
private val session: Session = arSession

@Synchronized
Expand Down Expand Up @@ -52,6 +52,14 @@ internal class CloudAnchorHandler( arSession: Session ) {
}
}

@Synchronized
fun dispose() {
for (pendingAnchor in pendingAnchors) {
pendingAnchor.key.detach()
}
clearListeners()
}

// Remove all listeners
@Synchronized
fun clearListeners() {
Expand Down
4 changes: 2 additions & 2 deletions cloudAnchorSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Follow the steps below to set up your application.

## Set up Google Cloud Anchor Service

The Google Cloud Anchor API is used by the plugin to upload, store and download AR anchors. If your app uses the plugin's shared AR experience features, the following setup steps are required:
The Google ARCore API is used by the plugin to upload, store and download AR anchors. If your app uses the plugin's shared AR experience features, the following setup steps are required:

1. Activate the [Cloud Anchor API](https://console.cloud.google.com/apis/api/arcorecloudanchor.googleapis.com) in your [Google Cloud Console](https://console.cloud.google.com) for the respective project
1. Activate the [ARCore API](https://console.cloud.google.com/apis/library/arcore) in your [Google Cloud Console](https://console.cloud.google.com) for the respective project
2. Register the Android part of your Flutter Application
* Perform the following steps to create a OAuth2 project (based on the [Android Cloud Anchors Developer Guide](https://developers.google.com/ar/develop/java/cloud-anchors/developer-guide-android?hl=en) and the [Guide for setting up OAuth 2.0](https://support.google.com/cloud/answer/6158849#zippy=)):
* Go to the [Google Cloud Platform Console](https://console.cloud.google.com).
Expand Down
Loading