Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickpose Landmark Demo #14

Open
SL06 opened this issue Feb 27, 2024 · 6 comments
Open

Quickpose Landmark Demo #14

SL06 opened this issue Feb 27, 2024 · 6 comments

Comments

@SL06
Copy link

SL06 commented Feb 27, 2024

I have the following error: Value of type 'QuickPose.Landmarks' has no member 'isFrontCamera' related to : flippedHorizontally: landmarks.isFrontCamera) at 2 places

and also Pattern with associated values does not match enum case 'success' related to this line : .success(_, _) = status, let landmarks = landmarks {

@SL06 SL06 changed the title Qucikpose Landmark Demo Quickpose Landmark Demo Feb 27, 2024
@SL06
Copy link
Author

SL06 commented Feb 27, 2024

I assume that the demo print landmark coordinates and from those, I will be able to calculate distance between to landmark as in measureLineBody ex: shoulder to elbow and print the result. I could not found how to print with .measureLineBody

@DanielGuarnizo
Copy link

I assume that the demo print landmark coordinates and from those, I will be able to calculate distance between to landmark as in measureLineBody ex: shoulder to elbow and print the result. I could not found how to print with .measureLineBody

have you solve this issue ?

@SL06
Copy link
Author

SL06 commented Jul 11, 2024 via email

@DanielGuarnizo
Copy link

I have the following error: Value of type 'QuickPose.Landmarks' has no member 'isFrontCamera' related to : flippedHorizontally: landmarks.isFrontCamera) at 2 places

and also Pattern with associated values does not match enum case 'success' related to this line : .success(_, _) = status, let landmarks = landmarks {

I mean, I need help with this issue because right now, I am not able to resolve it

@SL06
Copy link
Author

SL06 commented Jul 11, 2024 via email

@DanielGuarnizo
Copy link

i solve the problem in the following way, I remove "landmarks.isFrontCamera" from line code "scaledToViewPoint = bodyNose.cgPoint(scaledTo: geometry.size, flippedHorizontally: landmarks.isFrontCamera)", because 'QuickPose.Landmarks' has no member 'isFrontCamera', now is in the following way "scaledToViewPoint = bodyNose.cgPoint(scaledTo: geometry.size, flippedHorizontally: isUsingFrontCamera)" adding a variable that I define in the view. here the code `import SwiftUI
import QuickPoseCore
import QuickPoseSwiftUI
import AVFoundation

struct QuickPoseBasicView: View {

private var quickPose = QuickPose(sdkKey: "YOUR KEY") // register for your free key at https://dev.quickpose.ai
@State private var overlayImage: UIImage?
@State private var scaledToViewPoint = CGPoint(x: 1080/2, y: 1920/2)
@State private var isUsingFrontCamera = false // variable that I added 

var body: some View {
    GeometryReader { geometry in
        ZStack(alignment: .top) {
            if true, let url = Bundle.main.url(forResource: "happy-dance", withExtension: "mov") {
                QuickPoseSimulatedCameraView(useFrontCamera: false, delegate: quickPose, video: url, videoGravity: .resizeAspect)
            } else {
                QuickPoseCameraView(useFrontCamera: false, delegate: quickPose, videoGravity: .resizeAspect)
            }
            QuickPoseOverlayView(overlayImage: $overlayImage, contentMode: .fit)
        }
        .overlay(alignment: .topLeading) {
            Circle()
                .position(x: scaledToViewPoint.x, y: scaledToViewPoint.y)
                .frame(width: 12, height: 12)
                .foregroundColor(Color.green.opacity(1.0))
            
        }
        .frame(width: geometry.size.width)
        .edgesIgnoringSafeArea(.all)
        .onAppear {
            quickPose.start(features: [.showPoints()], onFrame: { status, image, features, feedback, landmarks in
                overlayImage = image
                if case .success = status, let landmarks = landmarks {
                    print(landmarks)
                    
                    let bodyNose = landmarks.landmark(forBody: .nose)
                    let bodyNoseWorld = landmarks.worldLandmark(forBody: .nose)

                  
                    scaledToViewPoint = bodyNose.cgPoint(scaledTo: geometry.size, flippedHorizontally: isUsingFrontCamera)

                    if let nose = landmarks.landmark(forFace: .faceNose) {
                        //print(nose.cgPoint(scaledTo: geometry.size, flippedHorizontally: landmarks.isFrontCamera))
                        print(nose.cgPoint(scaledTo: geometry.size))
                        print(nose)
                    }
                } else {
                    // show error feedback
                }
            })
        }.onDisappear {
            quickPose.stop()
        }
        .overlay(alignment: .bottom) {
            Text("Powered by QuickPose.ai v\(quickPose.quickPoseVersion())") // remove logo here, but attribution appreciated
                .font(.system(size: 16, weight: .semibold)).foregroundColor(.white)
                .frame(maxHeight:  40 + geometry.safeAreaInsets.bottom, alignment: .center)
                .padding(.bottom, 0)
        }
        
    }
}

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants