Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

UnboundLocalError: local variable 'steady_pose' referenced before assignment #20

Open
yubaoliu opened this issue Mar 17, 2021 · 2 comments

Comments

@yubaoliu
Copy link

Hello,
I see this error when I test demo.py:

python demo.py --debug
Downloading the face detection CNN. Please wait...
Downloading the Face Alignment Network(FAN). Please wait...
Traceback (most recent call last):
  File "demo.py", line 219, in <module>
    main()
  File "demo.py", line 154, in main
    roll = np.clip(-(180+np.degrees(steady_pose[2])), -50, 50)
UnboundLocalError: local variable 'steady_pose' referenced before assignment

Thanks

@GuaiYiHu
Copy link

Same issue

@GuaiYiHu
Copy link

GuaiYiHu commented Apr 18, 2021

Fixed

        pose+= [(ll+rl)/2.0, (lu+ru)/2.0]
        steady_pose = []

        if error > 100: # large error means tracking fails: reinitialize pose estimator
                        # at the same time, keep sending the same information (e.g. same roll)
            pose_estimator = PoseEstimator(img_size=sample_frame.shape[:2])

        else:
            # Stabilize the pose.
            steady_pose.clear()
            pose_np = np.array(pose).flatten()
            for value, ps_stb in zip(pose_np, pose_stabilizers):
                ps_stb.update([value])
                steady_pose.append(ps_stb.state[0])
        
        if len(steady_pose) == 0:
            continue

        roll = np.clip(-(180+np.degrees(steady_pose[2])), -50, 50)
        pitch = np.clip(-(np.degrees(steady_pose[1]))-15, -40, 40) # the 15 here is my camera angle.
        yaw = np.clip(-(np.degrees(steady_pose[0])), -50, 50)
        min_ear = min(eye_aspect_ratio(marks[36:42]), eye_aspect_ratio(marks[42:48]))
        mar = mouth_aspect_ration(marks[60:68])
        mdst = mouth_distance(marks[60:68])/(facebox[2]-facebox[0])

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

No branches or pull requests

2 participants