Reputation: 21
Scenario:
I'm developing application to detect the surface for measurement, I'm using ARCore SDK for this purpose which works perfectly fine for HORIZONTAL VIEW
but the issue is on vertical analyzing part as it didn't show any dots to detect the surface.
sceneView = findViewById<ARSceneView?>(R.id.sceneView).apply {
planeRenderer.isEnabled = true
configureSession { session, config ->
config.depthMode = when (session.isDepthModeSupported(Config.DepthMode.AUTOMATIC)) {
true -> {Config.DepthMode.AUTOMATIC
}
else -> Config.DepthMode.DISABLED
}
config.planeFindingMode = Config.PlaneFindingMode.VERTICAL
config.depthMode = Config.DepthMode.AUTOMATIC
config.instantPlacementMode = Config.InstantPlacementMode.LOCAL_Y_UP
config.lightEstimationMode = Config.LightEstimationMode.ENVIRONMENTAL_HDR
// config.updateMode=Config.UpdateMode.LATEST_CAMERA_IMAGE
}
onSessionUpdated = { _, frame ->
if (anchorNode == null) {
frame.getUpdatedPlanes()
.firstOrNull { it.type == Plane.Type.VERTICAL }
?.let { plane ->
// addAnchorNode(plane.createAnchor(plane.centerPose))
}
}
}
onTrackingFailureChanged = { reason ->
[email protected] = reason
Toast.makeText(this@MainActivity, "$reason", Toast.LENGTH_SHORT).show()
}
onSessionFailed={ fail->
Toast.makeText(this@MainActivity, "$fail", Toast.LENGTH_SHORT).show()
}
onSessionUpdated={
session, frame ->
// Toast.makeText(this@MainActivity, "$session", Toast.LENGTH_SHORT).show()
}
}
Above code works fine on Horizontal plane but when we change the configureSession to Vertical it didn't detect any vertical plane for any vertical texture.
Already tried
config.planeFindingMode = Config.PlaneFindingMode.VERTICAL
Upvotes: 1
Views: 155
Reputation: 58043
Despite the fact that vertical plane detection has never been a strong side of either ARCore or ARKit, following some rules will allow you to improve the quality and speed of vertical planes detection in ARCore 1.45. The two most important aspects when tracking vertical surfaces are that the room has sufficient level of illumination and that the walls have rich texture and some objects on them. Below is the working Kotlin code that allows you to switch from horizontal to vertical tracking and back.
class MainActivity : AppCompatActivity() {
private lateinit var frag: ArFragment
private lateinit var session: Session
private var counter: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
frag = supportFragmentManager.findFragmentByTag("frag") as ArFragment
val button = findViewById<Button>(R.id.button_id)
this.session = Session(this)
val config = Config(session)
config.updateMode = Config.UpdateMode.LATEST_CAMERA_IMAGE
config.planeFindingMode = Config.PlaneFindingMode.HORIZONTAL
session.configure(config)
frag.arSceneView.setupSession(session)
button.setOnClickListener {
counter += 1
if (counter % 2 == 1) {
config.planeFindingMode = Config.PlaneFindingMode.VERTICAL
session.configure(config)
} else {
config.planeFindingMode = Config.PlaneFindingMode.HORIZONTAL
session.configure(config)
}
}
}
}
Upvotes: 0