mex C++ use opencv library in Matlab 2020b

8 views (last 30 days)
asmaa atalaa
asmaa atalaa on 18 Dec 2022
Answered: Ujwal Durgam on 30 Jan 2023
I have amatlab code downloaded from the internet, this code has .cpp function and need opencv library.
I installed opencv 4.6.0, visual studio 2017, and installed opencvinterface.mlpkginstall toolbox, and added the path of opencv2 on matlab
but i still hav this error
mexOpenCV Keypoint_Detector.cpp
Building with 'Microsoft Visual C++ 2017'.
Error using mexOpenCV (line 135)
Keypoint_Detector.cpp
E:\New codes\IterativeCMFD-master\Functions\Keypoint_Detector.cpp(3):
fatal error C1083: Cannot open include file:
'\opencv2\highgui\highgui.hpp': No such file or directory
mex Keypoint_Detector.cpp
Building with 'Microsoft Visual C++ 2017'.
Error using mex
Keypoint_Detector.cpp
E:\New
codes\IterativeCMFD-master\Functions\Keypoint_Detector.cpp(2):
fatal error C1083: Cannot open include file:
'opencv2\core\core.hpp': No such file or directory
can anyone helping me solving this error?

Answers (1)

Ujwal Durgam
Ujwal Durgam on 30 Jan 2023
mexOpenCV does not include the highgui module. Do not include highgui, if you want to use mexOpenCV.
However your code does not use this module, try to comment out the line 2.
Try using OpenCV Support - MATLAB & Simulink (mathworks.com) Mex Interface support for converting opencv data type to MATLAB datatype and display images in MATLAB.
If you want to use you installed opencv, you can use mex Keypoint_Detector.cpp.
However, you need to specify the Path to the OpenCV include files path and Libs path using -I and -L and link library using -l
example: mex Keypoint_Detector.cpp. -I/usr/local/include -L/us/local/lib -lopencv_world

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!