Add offset for Text output and add converted y

This commit is contained in:
Simon Rieger 2023-12-15 21:23:11 +01:00
parent b4ccf6315b
commit 1a2e74507c

View file

@ -26,10 +26,11 @@ struct ContentView: View {
.stroke(Color.green, lineWidth: 2) .stroke(Color.green, lineWidth: 2)
.frame(width: rectangleData.rect.width, height: rectangleData.rect.height) .frame(width: rectangleData.rect.width, height: rectangleData.rect.height)
.position(x: rectangleData.rect.midX, y: rectangleData.rect.midY) .position(x: rectangleData.rect.midX, y: rectangleData.rect.midY)
.rotationEffect(Angle(degrees: 270)) .rotationEffect(Angle(degrees: 90))
} }
//Text("Recognized Text: \(recognizedText)") Text("Recognized Text: \(recognizedText)")
// .padding() .padding()
.offset(x: 0, y: 200)
} }
.alert(isPresented: $isShowingPopup) { .alert(isPresented: $isShowingPopup) {
Alert( Alert(
@ -169,7 +170,9 @@ struct CameraView: UIViewControllerRepresentable {
func transformRect(_ rect: CGRect) -> CGRect { func transformRect(_ rect: CGRect) -> CGRect {
let previewSize = UIScreen.main.bounds.size let previewSize = UIScreen.main.bounds.size
var transformedRect = VNImageRectForNormalizedRect(rect, Int(previewSize.width), Int(previewSize.height)) var transformedRect = VNImageRectForNormalizedRect(rect, Int(previewSize.width), Int(previewSize.height))
transformedRect.origin.x = previewSize.width - transformedRect.origin.x - transformedRect.size.width
// Spiegelung der Y-Achse anpassen
transformedRect.origin.y = previewSize.height - transformedRect.origin.y - transformedRect.size.height
return transformedRect return transformedRect
} }