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

Confusion about colorchecker.py #2

Open
CN-HaoJiang opened this issue Mar 14, 2019 · 6 comments
Open

Confusion about colorchecker.py #2

CN-HaoJiang opened this issue Mar 14, 2019 · 6 comments

Comments

@CN-HaoJiang
Copy link

In 'build/colorchecker.py' ,there is a line as follows.

mcclib = utils.ffi_module_import( 'build/mcclib/libmcclib' )

I can't find libmcclib.
I hope that you could help solve my problem .
Thank you!

@pedrodiamel
Copy link
Owner

Hello CnJsJh

  1. make the project.
    You need Linux and OpenCV v3.1.0 for mccfind solution
export OpenCV_DIR="./extern/opencv"
mkdir build
cd build
cmake -D OpenCV_DIR=$OpenCV_DIR ..
make 
  1. test mccfind

create mccfiend.py

vim mccfiend.py


from cffi import FFI
from sys import exit, platform
import cv2

import detectlib.visualizationutl as view
import colorchecker
import utils

def main():
    image = cv2.imread( './rec/img-colorchecker.jpg' )    
    box = colorchecker.find( image[:,:,(2,1,0)] )

    image_output = image.copy()
    image_output = view.plotpolycv( image_output, box, thickness=4 )
    image_output = view.drawcolorchecker(image_output, box, [0,255,0], thickness=4)

    cv2.imshow('frame processing:', image_output)
    cv2.waitKey(0)

if __name__ == '__main__':
    main()

python mccfiend.py

see output

for mccfindnet you need NVidia Caffe.

@CN-HaoJiang
Copy link
Author

Thank you very much for your explanation!
Well, could I use Windows to make the project and test mccfind?
And when I use Linux, whether should I run the mccfind.py directly or type in one of
'./build/src/mcc ../db/img-colorchecker.jpg -o=../out -t=1 -sh -gt -nc=0
./build/src/mcc ../db/vdo-colorchecker.mp4 -o=../out -t=2 -sh -gt -nc=2
./build/src/mcc ../db/sec-colchecker-0.jpg -o=../out -t=3 -sh -gt -nc=2 -me=10.0'
in the command line?

@pedrodiamel
Copy link
Owner

I think that this could work for Windows:

Windows (MS Visual Studio):

set OpenCV_DIR="./extern/opencv"
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" -D OpenCV_DIR=%OpenCV_DIR% ..

MacOSX (Xcode):

export OpenCV_DIR="./extern/opencv"
mkdir build
cd build
cmake -G Xcode -D OpenCV_DIR=$OpenCV_DIR ..

@CN-HaoJiang
Copy link
Author

Thank you for your explanation!
I have installed opencv-python in my pc.
In the sentence "OpenCV_DIR=%OpenCV_DIR%", should I put the .whl file path in the %OpenCV-DIR%?

@erkandiken
Copy link

erkandiken commented Nov 8, 2019

Hello all,

I have managed to have a complete installation:

======= prepare environment ========

mkdir ccd  &&  cd ccd # create a directory and go to directory
virutalenv -p python3.6 .  # inside the directory create a virtual environment
source bin/activate  # activate the environment 
git clone https://github.com/pedrodiamel/colorchecker-detection.git  # clone the library
pip install numpy # install numpy  
https://github.com/opencv/opencv/releases  # get the opencv release 
# Copy the opencv release (I used opencv-3.4.1.zip) in ccd/colorchecker-detection/extern
# unzip the  opencv-3.4.1

====== configure, build, install openCV =======

mkdir opencv && cd opencv # make a directory for installing opencv  
cd opencv-3.4.1
mkdir build && cd build
# run the cmake command below for python3 and pay attention to CMAKE_INSTALL_PREFIX=../../opencv, should point to the correct directory for opencv installation 
# (Reference: https://www.pyimagesearch.com/2018/08/17/install-opencv-4-on-macos/)
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=../../opencv -D PYTHON3_LIBRARY=`python -c 'import subprocess ; import sys ; s = subprocess.check_output("python-config --configdir", shell=True).decode("utf-8").strip() ; (M, m) = sys.version_info[:2] ; print("{}/libpython{}.{}.dylib".format(s, M, m))'` -D PYTHON3_INCLUDE_DIR=`python -c 'import distutils.sysconfig as s; print(s.get_python_inc())'`  -D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D BUILD_EXAMPLES=ON ..
make -j 4
sudo make install

======configure, build mcc lib =======

mkdir build # go to main directory of project (ccd) and create a build folder
cd build # go to the build directory
export OpenCV_DIR= full path to openCV installation 
cmake -G "Unix Makefiles" OpenCV_DIR=$OpenCV_DIR ..
make

You might get the warning below:

CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

ClangWrapper
Structure
WCETXML

This warning is for project developers. Use -Wno-dev to suppress it.

adding the line below in CMakeLists.txt should resolve it
set(CMAKE_MACOSX_RPATH 1))
Source: https://stackoverflow.com/questions/31561309/cmake-warnings-under-os-x-macosx-rpath-is-not-specified-for-the-following-targe

As a last step, do not forget to pip install the following packages:

pip install cffi
pip install opencv-python 
pip install matplotlib
pip install scikit-image

Now you should be able run mccfiend.py python file.

@LiuLei-beep
Copy link

Thanks to the author for his answer. I'm On Windows, and I've executed :
--set OpenCV_DIR="./extern/opencv"
--mkdir build
--cd build
--cmake -G "Visual Studio 14 2015 Win64" -D OpenCV_DIR=%OpenCV_DIR% ..
And the result of running it is:
-- Selecting Windows SDK version to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.0.23026.0
-- The CXX compiler identification is MSVC 19.0.23026.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/软件安装/VC/bin/x86_amd64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/软件安装/VC/bin/x86_amd64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/colorchecker-detection-master/build

When I run mccfiend.py,
But The mistake happened again:
--OSError: cannot load library 'build/mcclib/libmcclib.dll': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'build/mcclib/libmcclib.dll'

I can't solve this problem. I really hope you can help me. Thanks again!

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

4 participants