How a dictionary is loaded in C++ OpenCV Program?

asked 2017-07-07 05:44:12 -0500

Helal Uddin Mullah gravatar image

Suppose, I have a dictionary which is in dot mat file format. This can be loaded in a MATLAB program as show below.

% load dictionary load('Dictionary/D_1024_0.15_5.mat');

Now, I would want to use the same dictionary in C++ based OpenCV program. What will be the equivalent instruction to perform the task?

Thanks in advance.

Helal, TU

edit retag flag offensive close merge delete


you can't read matlab .mat files from opencv. chances will get better, if you're able to save this in some kind of text based format.

berak gravatar imageberak ( 2017-07-07 05:47:34 -0500 )edit

Thank you Sir Berak.

However this .mat file is possible to load in python. Is there any useful guide available for converting the .mat file into .txt file & how it is loaded in C++ opencv program?

Helal Uddin Mullah gravatar imageHelal Uddin Mullah ( 2017-07-07 07:00:43 -0500 )edit

Mat file is just a binary file. If you know its structure, it's no magic.

KjMag gravatar imageKjMag ( 2017-07-07 12:39:32 -0500 )edit

What is the C++ instruction for loading the converted .txt file in an OpenCV program ?

Helal Uddin Mullah gravatar imageHelal Uddin Mullah ( 2017-07-11 09:33:44 -0500 )edit

Kindly provide a proper C++ instruction for it.

Helal Uddin Mullah gravatar imageHelal Uddin Mullah ( 2017-07-11 09:36:08 -0500 )edit

show what you did, and the result, ofc.

berak gravatar imageberak ( 2017-07-11 10:34:08 -0500 )edit

You have to adjust the code to suit your needs, there is no generic code. Google opening Matlab files and binary files in C++ - there's a plenty of material in the web. And it doesn't have much to do with openCV by the way, so it's the wrong place to ask these questions.

KjMag gravatar imageKjMag ( 2017-07-11 10:34:51 -0500 )edit

@KjMag - i whish i could honestly say: "I never had that problem" ;(

berak gravatar imageberak ( 2017-07-11 10:48:04 -0500 )edit

Which problem? :D

KjMag gravatar imageKjMag ( 2017-07-11 10:54:08 -0500 )edit

getting some matlab generated data ito opencv.

berak gravatar imageberak ( 2017-07-11 10:55:11 -0500 )edit