When i am attempting to load a 3dmodel in to the actual world utilizing realitykit it’s loaded accurately however the issue i am going through proper now could be this mannequin seems to be tilted from proper or can say as barely rotated on its y axis
I am at present utilizing “VNDetectRectanglesRequest” to detect any rectangle and place an 3dModel on it like proven in picture
`
personal func searchForRect(from currentCapturedPixelBuffer: CVPixelBuffer) {
/// Create a request handler
let handler = VNImageRequestHandler(cvPixelBuffer: currentCapturedPixelBuffer, orientation: .up)
currentCameraImage = currentCapturedPixelBuffer
/// Create a rewuest
let request = VNDetectRectanglesRequest { [weak self] request, error in
if error == nil {
guard let self else { return }
self.handleRequest(request: request)
} else {
print("Error: (error)")
}
}
request.minimumConfidence = 0.8
request.minimumSize = 0.25
request.minimumAspectRatio = 4/3
request.maximumObservations = 1
request.quadratureTolerance = 20
request.usesCPUOnly = false
do {
strive handler.carry out([request])
} catch {
print("Error: Rectangle detection failed - imaginative and prescient request failed.")
}
}
`
As soon as rectangle is detected i am attempting to put a 3Dmodel on the detected rectangle which can be a hit (have tried to put it on the midpoint of detected rectangle utilizing raycasting) like this picture
Additionally i’ve a timer which hold looking for rectangles each 2 seconds and each time it finds a rectangle it seems to be barely tilted
I am anticipating it to all the time be parallel to the sides like proven in following picture i’ve tried many various fashions however with all rectangular fashions i attempt to load it all the time seems to be considerably tilted, Is there someway to repair this or is there every other strategy to get the angle of how a lot it is tilted so we are able to distinction out that angle from the loaded entity’s rotation?