diff --git a/README.md b/README.md index b669dac..f86ae12 100644 --- a/README.md +++ b/README.md @@ -6,35 +6,33 @@ Overview This is the python3 wrapper for AprilTag implemented in cv2cg. -Currently it is tested under Windows10(VC2017, x64), OpenCV3.4.7(official prebuilt version), and python3.6 in Anaconda3. +Currently it is tested under Windows10(VC2017, x64)/Ubuntu 18.04, OpenCV3.4.7(official prebuilt version), +and python3.7/3.6 in Anaconda3. Version ------- -0.0.4 +0.0.5 Installation ------------ ### Install from Pip -For Linux and Windows users, simply run the following command: +For Linux and Windows users, download the proper wheel file from https://github.com/ai4ce/pyAprilTag/releases, +then simply run the following command under the same folder of the wheel file to install: ``` -pip install pyAprilTag -python -m pyAprilTag.demo -# expected output: -#[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 -# 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39] +pip install pyAprilTag-0.0.4-cp37-cp37m-win_amd64.whl ``` ### Install by Compiling from Source -For Mac users, you need to compile from source. **First install the C++ version of OpenCV 3.4.x.** -Then: +Following is for Mac users who need to compile from source, or other users who want to try installing from source. -0. clone repository recursively: +0. clone repository **recursively**, and install pre-built opencv 3.4.7 for python from conda-forge: ``` git clone --recursive https://github.com/ai4ce/pyAprilTag.git + conda install -c conda-forge opencv=3.4.7 ``` 1. prepare your build environment: @@ -44,18 +42,26 @@ Then: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" ``` -2. **Check the setup.py file, modify the OpenCV include and libs path according to your system.** - -3. compile the project: +2. compile the project and you are done: ``` pip install -e . ``` + +Usage +----- -4. Enjoy! - ``` - python -m pyAprilTag.demo - ``` +``` +python -m pyAprilTag.demo +# expected output: +#[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 +# 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39] +python -m pyAprilTag.demo_plt +python -m pyAprilTag.demo_calib +python -m pyAprilTag.demo_calib_by_photo #remember to remove the calib_log folder in the current working directory +python -m pyAprilTag.vdemo_cv +python -m pyAprilTag.vdemo_plt +``` Contact ------- diff --git a/python/pyAprilTag/vdemo_cv.py b/python/pyAprilTag/vdemo_cv.py index 3ed305c..876d4fa 100644 --- a/python/pyAprilTag/vdemo_cv.py +++ b/python/pyAprilTag/vdemo_cv.py @@ -29,6 +29,7 @@ # Read until video is completed cnt = 0 +cv2.namedWindow('Frame', cv2.WINDOW_NORMAL) while cap.isOpened(): # Capture frame-by-frame ret, frame = cap.read() diff --git a/setup.py b/setup.py index b36d52b..ec8ea00 100644 --- a/setup.py +++ b/setup.py @@ -38,9 +38,11 @@ def get_conda_opencv_info(sys_name): except ImportError as e: print(str(e)) print('Please install opencv for python in your current Anaconda environment via the following:\n' - 'conda install -c conda-forge opencv') + 'conda install -c conda-forge opencv=3.4.7') exit(-1) + assert(cv2.getVersionMajor() == 3) #currently we do not support opencv4 + if sys_name == 'Linux': opencv_lib_dir = os.path.abspath(os.path.join(os.path.dirname(cv2.__file__), *(['..'] * 2))) available_opencv_libs = glob.glob(os.path.join(opencv_lib_dir, 'libopencv*.so')) @@ -60,14 +62,18 @@ def get_conda_opencv_info(sys_name): available_opencv_libs = [os.path.splitext(os.path.basename(it))[0].lstrip('lib') for it in available_opencv_libs] - opencv_libs = [lib for lib in required_opencv_modules if lib in available_opencv_libs] + if sys_name == 'Windows': + opencv_libs = [lib for lib in available_opencv_libs + if any([lib.startswith(it) for it in required_opencv_modules])] + else: + opencv_libs = [lib for lib in required_opencv_modules if lib in available_opencv_libs] return opencv_lib_dir, opencv_inc_dir, opencv_libs sys_name = platform.system() opencv_lib_dir, opencv_inc_dir, opencv_libs = get_conda_opencv_info(sys_name) -# print(opencv_lib_dir) -# print(opencv_inc_dir) -# print(opencv_libs) +print(opencv_lib_dir) +print(opencv_inc_dir) +print(opencv_libs) extensions = [ Extension('pyAprilTag._apriltag', @@ -82,7 +88,7 @@ def get_conda_opencv_info(sys_name): setup( name="pyAprilTag", - version="0.0.4", + version="0.0.5", author="Chen Feng", author_email="cfeng@nyu.edu", description="python wrapper for AprilTag implemented in library cv2cg", @@ -92,6 +98,7 @@ def get_conda_opencv_info(sys_name): package_data={'pyAprilTag': ['data/*.png', 'data/**/*']}, include_package_data=True, license="BSD", - cmdclass={'build_ext': BuildExt}, - ext_modules=cythonize(extensions, compiler_directives={'language_level' : sys.version_info[0]}) + cmdclass={'build_ext': build_ext if sys_name=='Windows' else BuildExt}, + ext_modules=cythonize(extensions, compiler_directives={'language_level' : sys.version_info[0]}), + install_requires=['opencv>2,<4',] ) \ No newline at end of file