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

Import openpose in different script Python API on Windows #2296

Open
vincenzomarotta opened this issue May 18, 2024 · 0 comments
Open

Import openpose in different script Python API on Windows #2296

vincenzomarotta opened this issue May 18, 2024 · 0 comments

Comments

@vincenzomarotta
Copy link

Windows 11 / Latest Openpose / Python 3.9

Hello, I built openpose correctly on my Windows machine, everything works, imports work perfectly too.

I wanted to create a python script where I wanted to put openpose import and in my main file I wanted to execute it, Is there any way to import pyopenpose in a simpler way?

For example:
oenpose_importer.py

import os
import cv2
import sys
from sys import platform
import argparse
import time

# Import Openpose (Windows/Ubuntu/OSX)
#dir_path = os.path.dirname(os.path.realpath(__file__))
dir_path = "path_to/openpose
try:
    # Windows Import
    if platform == "win32":
        # Change these variables to point to the correct folder (Release/x64 etc.)
        sys.path.append(dir_path + '/build/python/openpose/Release');
        os.add_dll_directory(dir_path + '/build/x64/Release')
        os.add_dll_directory(dir_path + '/build/bin')
        #print("Openpose imported correctly")
        import pyopenpose as op
    else:
        # Change these variables to point to the correct folder (Release/x64 etc.)
        sys.path.append('../../python');
        # If you run `make install` (default path is `/usr/local/python` for Ubuntu), you can also access the OpenPose/python module from there. This will install OpenPose and the python library at your desired installation path. Ensure that this is in your python path in order to use it.
        # sys.path.append('/usr/local/python')
        from openpose import pyopenpose as op
except ImportError as e:
    print('Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?')
    raise e

in my main.py

import os
import cv2
import sys
from sys import platform
import argparse
import time
import openpose_importer as op
# CODE HERE

Right now I'm getting the error:
module 'openpose_importer' has no attribute 'WrapperPython'

Is there any way to achive what I'm trying to do?

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

1 participant