Ask Your Question

tivadj's profile - activity

2013-11-25 03:54:30 -0600 received badge  Editor (source)
2013-11-25 03:47:26 -0600 asked a question Matlab binding for cv.calcHist

Hi,

The Python's sample in OpenCV-2.4.7\sources\samples\python2\color_histogram.py has warking code below

h = cv2.calcHist( [hsv], [0, 1], None, [180, 256], [0, 180, 0, 256] )

What is the corresponding syntax for Matlab mex binding?

I tried different syntax such as

image = imread('coloredChips.png');
cv.imshow('main', image)
h = cv.calcHist({image}, [0 1], [], [180, 256], [0 180 0 256]);
h = cv.calcHist( image , [0 1], [], [180, 256], [0 180 0 256]);

And for every calcHist call got the error

Error using calcHist cv::exception caught: ..\..\..\modules\imgproc\src\histogram.cpp:1421: 
error: (-215) nimages > 0 && dims > 0 in function cv::calcHist

The error is reproduced under:

  1. OpenCV 3 latest sources from GitHub.
  2. Compiler=VS2010 or VS2012.
  3. Arch=x86 or x64
  4. Configuration=Release
  5. Matlab=R2013b
2013-10-25 17:15:54 -0600 received badge  Student (source)
2013-10-25 16:43:06 -0600 asked a question Calling OpenCV from Matlab (via Python generated stubs)

Hi,

I have a problem running OpenCV auto-generated wrappers from Matlab (perhaps *.mexw64 binaries were not created).

I've successfully compiled OpenCV 3 (sources from GitHub) with Matlab 2013b support. Also I successfully build an install folder (VS 2012, x64). I see a bunch of headers, .m files for OpenCV API in build\modules\matlab+cv folder and build\modules\matlab\src has .cpp routines, but how to create *.mexw64 binaries?
Testing
I executed in Matlab (expected call to cv.log function):

>> addpath('C:\devb\cplex\opencv\build-vs2012-x64\install\matlab\');
>> cv.log(5)
Error using cv.log
Attempt to execute SCRIPT log as a function:
C:\devb\cplex\opencv\build-vs2012-x64\install\matlab\+cv\log.m

Then for valid RGB image imgRgb (expected initial image with a line drawn):

i2=cv.line(imgRgb, [10 10], [100 100], [0 255 255]);
Error using cv.line
Attempt to call constructor line with incorrect letter case.

Thanks in advance!

Details:
Cmake configuration (header and Python/Matlab sections)

General configuration for OpenCV 3.0.0-dev =====================================
  Version control:               2.4.6.2-2929-g31f0ab6

  Platform:
    Host:                        Windows 6.2 x86
    CMake:                       2.8.9
    CMake generator:             Visual Studio 11 Win64
    CMake build tool:            C:/PROGRA~2/MICROS~1.0/Common7/IDE/devenv.com
    MSVC:                        1700
  Python:
    Interpreter:                 C:/progs/Python27.amd64/python.exe (ver 2.7.4)
  Matlab:
    mex:                         e:/Programs/MATLAB/R2013b/bin/mex.bat

CMake properties

MATLAB_MEX_SCRIPT e:/Programs/MATLAB/R2013b/bin/mex.bat
MATLAB_ROOT_DIR e:/Programs/MATLAB/R2013b


cv.buildInformation()

  ------------------------------------------------------------------------
                              OpenCV Toolbox
                     Build and diagnostic information
  ------------------------------------------------------------------------

  Platform
  OS:            Windows-6.2
  Architecture:  64-bit x86
  Compiler:      MSVC

  Matlab
  Version:       8.2.0.701 (R2013b)
  Mex extension: mexw64
  Architecture:  win64
  Mex path:      e:/Programs/MATLAB/R2013b/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.0.0-dev
  Commit:        31f0ab6c80a0e8ae0c92ddf65fa86ca8bbde599a
  Configuration: Release
  Modules:       core, imgproc, ml, highgui, objdetect, flann, features2d,
                 photo, video, videostab, calib3d, stitching, superres,
                 nonfree