@@ -88,9 +88,9 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
88
88
ImageProcessor .Builder ()
89
89
.add(ResizeWithCropOrPadOp (cropSize, cropSize))
90
90
.add(
91
- ResizeOp (
92
- tfInputSize.height, tfInputSize.width, ResizeOp .ResizeMethod .NEAREST_NEIGHBOR
93
- )
91
+ ResizeOp (
92
+ tfInputSize.height, tfInputSize.width, ResizeOp .ResizeMethod .NEAREST_NEIGHBOR
93
+ )
94
94
)
95
95
.add(Rot90Op (imageRotationDegrees / 90 ))
96
96
.add(NormalizeOp (0f , 1f ))
@@ -100,8 +100,8 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
100
100
101
101
private val tflite by lazy {
102
102
Interpreter (
103
- FileUtil .loadMappedFile(this , MODEL_PATH ),
104
- Interpreter .Options ().addDelegate(NnApiDelegate ())
103
+ FileUtil .loadMappedFile(this , MODEL_PATH ),
104
+ Interpreter .Options ().addDelegate(NnApiDelegate ())
105
105
)
106
106
}
107
107
@@ -172,9 +172,9 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
172
172
173
173
// Set up the view finder use case to display camera preview
174
174
val preview = Preview .Builder ()
175
- .setTargetAspectRatio(AspectRatio .RATIO_4_3 )
176
- .setTargetRotation(view_finder.display.rotation)
177
- .build()
175
+ .setTargetAspectRatio(AspectRatio .RATIO_4_3 )
176
+ .setTargetRotation(view_finder.display.rotation)
177
+ .build()
178
178
179
179
// Obtain the current frame from ARSession. When the configuration is set to
180
180
// UpdateMode.BLOCKING (it is by default), this will throttle the rendering to the
@@ -271,7 +271,7 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
271
271
// Apply declared configs to CameraX using the same lifecycle owner
272
272
cameraProvider.unbindAll()
273
273
val camera = cameraProvider.bindToLifecycle(
274
- this as LifecycleOwner , cameraSelector, preview/* , imageAnalysis*/
274
+ this as LifecycleOwner , cameraSelector, preview/* , imageAnalysis*/
275
275
)
276
276
277
277
// Use the camera object to link our preview use case with the view
@@ -316,10 +316,10 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
316
316
317
317
// Step 1: map location to the preview coordinates
318
318
val previewLocation = RectF (
319
- location.left * view_finder.width,
320
- location.top * view_finder.height,
321
- location.right * view_finder.width,
322
- location.bottom * view_finder.height
319
+ location.left * view_finder.width,
320
+ location.top * view_finder.height,
321
+ location.right * view_finder.width,
322
+ location.bottom * view_finder.height
323
323
)
324
324
325
325
// Step 2: compensate for camera sensor orientation and mirroring
@@ -330,10 +330,10 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
330
330
(isFrontFacing && ! isFlippedOrientation)
331
331
) {
332
332
RectF (
333
- view_finder.width - previewLocation.right,
334
- view_finder.height - previewLocation.bottom,
335
- view_finder.width - previewLocation.left,
336
- view_finder.height - previewLocation.top
333
+ view_finder.width - previewLocation.right,
334
+ view_finder.height - previewLocation.bottom,
335
+ view_finder.width - previewLocation.left,
336
+ view_finder.height - previewLocation.top
337
337
)
338
338
} else {
339
339
previewLocation
@@ -346,17 +346,17 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
346
346
val midY = (rotatedLocation.top + rotatedLocation.bottom) / 2f
347
347
return if (view_finder.width < view_finder.height) {
348
348
RectF (
349
- midX - (1f + margin) * requestedRatio * rotatedLocation.width() / 2f ,
350
- midY - (1f - margin) * rotatedLocation.height() / 2f ,
351
- midX + (1f + margin) * requestedRatio * rotatedLocation.width() / 2f ,
352
- midY + (1f - margin) * rotatedLocation.height() / 2f
349
+ midX - (1f + margin) * requestedRatio * rotatedLocation.width() / 2f ,
350
+ midY - (1f - margin) * rotatedLocation.height() / 2f ,
351
+ midX + (1f + margin) * requestedRatio * rotatedLocation.width() / 2f ,
352
+ midY + (1f - margin) * rotatedLocation.height() / 2f
353
353
)
354
354
} else {
355
355
RectF (
356
- midX - (1f - margin) * rotatedLocation.width() / 2f ,
357
- midY - (1f + margin) * requestedRatio * rotatedLocation.height() / 2f ,
358
- midX + (1f - margin) * rotatedLocation.width() / 2f ,
359
- midY + (1f + margin) * requestedRatio * rotatedLocation.height() / 2f
356
+ midX - (1f - margin) * rotatedLocation.width() / 2f ,
357
+ midY - (1f + margin) * requestedRatio * rotatedLocation.height() / 2f ,
358
+ midX + (1f - margin) * rotatedLocation.width() / 2f ,
359
+ midY + (1f + margin) * requestedRatio * rotatedLocation.height() / 2f
360
360
)
361
361
}
362
362
}
@@ -445,6 +445,8 @@ class CameraActivity : AppCompatActivity(), GLSurfaceView.Renderer {
445
445
val approximateDistanceMeters = 2.0f
446
446
// Performs a ray cast given a screen tap position.
447
447
val results = frame.hitTestInstantPlacement(0F , 0F , approximateDistanceMeters)
448
+ val displayRotation = display!! .rotation
449
+ session.setDisplayGeometry(displayRotation, 256 , 256 )
448
450
if (results.isNotEmpty()) {
449
451
val point = results[0 ].trackable as InstantPlacementPoint
450
452
// Create an Anchor from the point's pose.
0 commit comments