read matlab .mat file in opencv

asked 2016-01-04 11:15:52 -0600

theodore gravatar image

How I can read a matlab .mat file in opencv? I was searching around but I couldn't find something clear. I found a post here plus I know that there is the matlab module here but I couldn't find an example. Does anyone know how to do it.

There is also this post in SO which uses a library from the same person appearing in the first link above and it is quite clear how to use it. However, I would like to know if there is already something embedded in the Opencv library.

Thanks.

edit retag flag offensive close merge delete

Comments

may be you can find some answer here

LBerger gravatar imageLBerger ( 2016-01-04 14:25:19 -0600 )edit

Thanks @LBerger I think I found a solution by using an external library or Matlab's libraries (working on this now). However, I would like to know if it is possible to load a .mat file using only Opencv and if that requires Opencv to be compiled with matlab enabled or without.

theodore gravatar imagetheodore ( 2016-01-04 15:11:24 -0600 )edit

Sorry my link doesn't help. Just to say I use to work with scilab and sometime I call scilab form my C++ program and that's another way to access scilab memory without using intermediate file. In matlab you can do something similar in matlab

LBerger gravatar imageLBerger ( 2016-01-05 01:33:22 -0600 )edit

@LBerger finally I could not manage to make it work even with an external lib, therefore I just transformed the .mat file to .csv and did my job. Using Matlab function has the drawback that you need Matlab installed, and that is not always the case for everyone. Anyways, if anyone knows something that we do not I think it would be helpful to add a solution here for the future.

theodore gravatar imagetheodore ( 2016-01-06 09:16:19 -0600 )edit

Have you try this module used in scilab?

LBerger gravatar imageLBerger ( 2016-01-06 09:32:18 -0600 )edit

yes I was playing with this library, because cvmatio from the link above seems to be outdated. However, the result matrix was totally something else from what I was expecting no matter what I was trying. Therefore, I gave up since I was also quite time pressed.

theodore gravatar imagetheodore ( 2016-01-06 10:05:04 -0600 )edit

Hi all, Does anyone have idea about read the .mat file in opencv?

vps gravatar imagevps ( 2017-09-06 02:36:56 -0600 )edit