在matlab中直接調用opencv

來源:互聯網
上載者:User

原來在一個優秀的電腦視覺部落格中看到過,這次要用,記下這個網址:

http://www.cs.stonybrook.edu/~kyamagu/mexopencv/

需要的童鞋自取。

初體驗:

我的環境win7+VS2010+matlab2011b+opencv2.4.5

下載mexopencv-master.zip解壓後,按README.markdown,在matlab2011b中輸入命令

>mexopencv.make('opencv_path', 'D:\Program Files\opencv244')

----------------------------------------------------------------------------------------------

如果使用VS2008會提示缺標頭檔

 'stdint.h': No such file or directory 

在這裡找到了標頭檔放入mexopencv-master的include檔案夾中即可:

http://msinttypes.googlecode.com/svn/trunk/stdint.h

----------------------------------------------------------------------------------------------

mex成功後給出如下資訊:

To finish the setup, add OpenCV bin folder to the systemPATH, then restart MATLAB for changes to take effect. set PATH=%PATH%;D:\Program Files\opencv\build\x64\vc10\binTo use mexopencv, add its root folder to MATLAB search path.

環境變數設定後,運行下面的例子報錯(估計是因為’haarcascade_frontalface_alt.xml‘這個分類器不存在):

 

% Load a face detector and an imagedetector = cv.CascadeClassifier('haarcascade_frontalface_alt.xml');im = imread('myface.jpg');% Preprocessgr = cv.cvtColor(im, 'RGB2GRAY');gr = cv.equalizeHist(gr);% Detectboxes = detector.detect(gr, 'ScaleFactor',  1.3, ...                            'MinNeighbors', 2, ...                            'MinSize',      [30, 30]);% Draw resultsimshow(im);for i = 1:numel(boxes)    rectangle('Position',  boxes{i}, ...              'EdgeColor', 'g');end

錯誤如下:

Error using CascadeClassifier_Invalid path or file specifiedError in cv.CascadeClassifier (line 33)            this.id = CascadeClassifier_(filename);

可以運行第2個例子:

%Would you like to use a camera input? No problem.camera = cv.VideoCapture();pause(2);for i = 1:50    % Capture and show frame    frame = camera.read;    imshow(frame);    pause(0.3);end

在matlab中輸入這行代碼,也可以運行:

>> hog = cv.HOGDescriptor();


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.