opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.41k stars 5.76k forks source link

Matlab's binding does not work as expected from the tutorial #1471

Open eladar opened 6 years ago

eladar commented 6 years ago
System information (version)

Platform OS: Windows-10.0.14393 Architecture: 64-bit AMD64 Compiler: MSVC 19.0.24215.1

Matlab Version: 9.2.0.556344 (R2017a) Mex extension: mexw64 Architecture: win64 Mex path: C:/Program Files/MATLAB/R2017a/bin/mex.bat Mex flags: -largeArrayDims CXX flags: /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi

OpenCV Version: 3.3.0 Commit: None Configuration: Release Modules: dnn, core, imgproc, ml, imgcodecs, videoio, highgui, objdetect, flann, features2d, photo, video, videostab, calib3d, stitching, superres, xfeatures2d

Detailed description

@alalek I've built opencv with Matlab's binding as instructed in the tutorial and completed the compilation successfully. Trying the cv.dft() as shown in the tutorial I get an error massage :

K>> X = imread('cameraman.tif');
K>> Xf = cv.dft(X, 'nonzeroRows', 7)

Error using dft cv::exception caught: C:\ocv\opencv-3.3.0\modules\core\src\dxt.cpp:3343: error: (-215) type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 in function cv::dft

Steps to reproduce

opencv source code and contrib where placed in c:\ocv\opencv-3.3.0 & C:\ocv\opencv_contrib-3.3.0\. i've configured with cmake and complied with VS 14 2015 in c:\opencv3\ . Following compilation I added C:\opencv3\install\x64\vc14\bin to windows environment path and C:\opencv3\modules\matlab\ to Matlab's path. When i'm trying to run cv.dft() I got the above error msg. Is'nt weird that it looking for dxt.cpp in c:\ocv\opencv-3.3.0\ (where I placed the source) while I've built everything to @c:\opencv3\ ?

Does anyone knows how to bring opencv to life within Matlab?

alalek commented 6 years ago

Assertion means that cv.dft expects float/double data (1 or 2 channels - real or complex values). You need to satisfy this requirement. imread() (cv?) produces 8UC3/8UC1 (BGR/GRAY) in general.

eladar commented 6 years ago

Thank you for your replay.

I get what you mean, that off-course make sense. I guess writing this down under the 'RUN' section of the readme.md would have prevent the confusion.

If = cv.dft(double(I(:,:,1)), cv.DFT_COMPLEX_OUTPUT);

(As a Matlab user i'm used to apply fft2 on uint8 matrices).

In addition, the help documentation does not work. That added to my (wrong) impression that the Matlab's binding is not working.

Any idea how to enable it?

help cv.dft
help cv.bilateralFilter

cv.dft not found.

Use the Help browser search field to search the documentation, or type "help help" for help command options, such as help for methods.

cv.bilateralFilter not found.

Use the Help browser search field to search the documentation, or type "help help" for help command options, such as help for methods.

it seems that only - help cv works