Trying to test out opencv example from matlab and get error opencv2/opencv.hpp not found
3 次查看(过去 30 天)
显示 更早的评论
I followed the directions from the Matlab video (https://www.mathworks.com/matlabcentral/fileexchange/47953-computer-vision-toolbox-interface-for-opencv-in-matlab).
I downloaded the apps Computer Vision Toolbox, Image Processing Toolbox, and Computer Vision Toolbox Interface for OpenCV in Matlab.
When I run this code: mexOpenCV matchTemplateOCV.cpp
I get the error: 'opencv2/opencv.hpp' file not found
I didn't change anything and I'm following their instructions from the README.txt file. I also can't find an opencv2 folder or opencv.hpp file, but I'm using exactly what they gave me when I downloaded the apps. Can someone explain why this doesn't work?
2 个评论
Malay Agarwal
2024-5-23
Could you please share the commands that you are running and the complete error message?
回答(1 个)
Chandrika
2024-7-19
编辑:Chandrika
2024-7-19
Hello Sophie,
For being able to create MEX file from OpenCV C++ file using the support package 'Computer Vision Toolbox Interface for OpenCV in MATLAB', ensure that you have installed the support package using the instructions provided in the 'Installation' section within the following MathWorks documentation:
Once you are done with the support package installation, to create the MEX file from "matchTemplateOCV.cpp", execute the following code in MATLAB Command Window in the following sequence:
fileparts(which('mexOpenCV'))
% The above command would return the path of the support package 'Computer Vision Toolbox Interface for OpenCV in MATLAB'installed in your
% system
% supposing you are using MATLAB R2024a, the above command should return
% the following output:
%'C:\ProgramData\MATLAB\SupportPackages\R2024a\toolbox\vision\supportpackages\visionopencv'
cd C:\ProgramData\MATLAB\SupportPackages\R2024a\toolbox\vision\supportpackages\visionopencv
cd(fullfile(fileparts(which('mexOpenCV')),'example',filesep,'TemplateMatching'))
mexOpenCV matchTemplateOCV.cpp
In the above code, replace the path of the support package as per the output you obtain once upon executing the "fileparts(which('mexOpenCV'))" command.
You may find more information regarding the same in the following MathWorks documentation:
Additionally, before attempting to create the MEX file from "matchTemplateOCV.cpp", please ensure that you have set up the environment at your end for C++ MEX applications. To do so, you would first require to install a supported compiler, details regarding which may be found in the link provided below:
Further, for more details regarding setting up the environment for building C++ MEX file using "mex" command, you can refer the following link:
Hope it helps!
Regards,
Chandrika
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!