brianadvent / 3dobjectscanninganddetection Goto Github PK
View Code? Open in Web Editor NEWLearn how to detect 3D Object with ARKit 2
Learn how to detect 3D Object with ARKit 2
2018-09-25 16:59:33.442397+0300 FlowerShop[1573:295387] Execution of the command buffer was aborted due to an error during execution. Caused GPU Hang Error (IOAF code 3)
2018-07-04 11:37:24.970087+0200 FlowerShop[278:13584] [framework] -[CUINamedRecognitionGroup initWithName:contentsFromCatalog:usingRenditionKey:fromTheme:] couldn't find image named 'MyPot' skipping
2018-07-04 11:37:25.329133+0200 FlowerShop[278:13658] [Technique] ARWorldTrackingTechnique(0x108009270) error resetting object detection: ObjectDetectionCallbackNotSet
2018-07-04 11:37:25.400514+0200 FlowerShop[278:13702] [Technique] Failed to add 3D objects to VIO database
2018-07-04 11:37:25.401412+0200 FlowerShop[278:13702] [Session] Session (0x106513520): did fail with error: Error Domain=com.apple.arkit.error Code=301 UserInfo={NSLocalizedDescription=, NSLocalizedFailureReason=}
How can I adjust this project to start tracking more than one object?
`
class ViewController: UIViewController, ARSCNViewDelegate {
@IBOutlet var sceneView: ARSCNView!
@IBOutlet var sceneView2: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView.delegate = self
// Show statistics such as fps and timing information
sceneView.showsStatistics = false
// Create a new scene
let scene = SCNScene(named: "art.scnassets/GameScene.scn")!
// Set the scene to the view
sceneView.scene = scene
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingConfiguration()
let configuration2 = ARWorldTrackingConfiguration()
// Object Detection
configuration.detectionObjects = ARReferenceObject.referenceObjects(inGroupNamed: "CentroObjects", bundle: Bundle.main)!
// Object Detection
configuration2.detectionObjects = ARReferenceObject.referenceObjects(inGroupNamed: "SofaObjects", bundle: Bundle.main)!
// Run the view's session
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Pause the view's session
sceneView.session.pause()
}
// MARK: - ARSCNViewDelegate
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
let node2 = SCNNode()
if let objectAnchor = anchor as? ARObjectAnchor {
let plane = SCNPlane(width: CGFloat(objectAnchor.referenceObject.extent.x * 0.6), height: CGFloat(objectAnchor.referenceObject.extent.y * 0.5))
plane.cornerRadius = plane.width / 8
let spriteKitScene = SKScene(fileNamed: "ProductInfo_2")
plane.firstMaterial?.diffuse.contents = spriteKitScene
plane.firstMaterial?.isDoubleSided = true
plane.firstMaterial?.diffuse.contentsTransform = SCNMatrix4Translate(SCNMatrix4MakeScale(1, -1, 1), 0, 1, 0)
let planeNode = SCNNode(geometry: plane)
planeNode.position = SCNVector3Make(objectAnchor.referenceObject.center.x, objectAnchor.referenceObject.center.y + 0.70, objectAnchor.referenceObject.center.z)
node.addChildNode(planeNode)
}
if let objectAnchor2 = anchor as? ARObjectAnchor {
let plane2 = SCNPlane(width: CGFloat(objectAnchor2.referenceObject.extent.x * 0.6), height: CGFloat(objectAnchor2.referenceObject.extent.y * 0.5))
plane2.cornerRadius = plane2.width / 8
let spriteKitScene2 = SKScene(fileNamed: "sofacama")
plane2.firstMaterial?.diffuse.contents = spriteKitScene2
plane2.firstMaterial?.isDoubleSided = true
plane2.firstMaterial?.diffuse.contentsTransform = SCNMatrix4Translate(SCNMatrix4MakeScale(1, -1, 1), 0, 1, 0)
let planeNode2 = SCNNode(geometry: plane2)
planeNode2.position = SCNVector3Make(objectAnchor2.referenceObject.center.x, objectAnchor2.referenceObject.center.y + 0.70, objectAnchor2.referenceObject.center.z)
node.addChildNode(<#T##child: SCNNode##SCNNode#>)
}
return node
}
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user
}
func sessionWasInterrupted(_ session: ARSession) {
// Inform the user that the session has been interrupted, for example, by presenting an overlay
}
func sessionInterruptionEnded(_ session: ARSession) {
// Reset tracking and/or remove existing anchors if consistent tracking is required
}
}
`
I've tried to add multiple anchors but when I add it to the node it only loads the last one.
I'm unable to build the project available on github. Could you please help me
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.