Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert mat model to opencv storage xml/yaml model #14

Closed
TimSC opened this issue Apr 1, 2013 · 8 comments
Closed

Convert mat model to opencv storage xml/yaml model #14

TimSC opened this issue Apr 1, 2013 · 8 comments

Comments

@TimSC
Copy link
Contributor

TimSC commented Apr 1, 2013

I have compiled PartsBasedDetector without MatlabIO. This can only read models with xml or yaml format. The model training_demo.m code (which I run in octave) saves the model as mat format.

model = trainmodel(name,pos,neg,K,pa,sbin);
save('Demo_model.mat', 'model', 'pa', 'sbin', 'name');

There does not seem to be a clear way to covert from .mat to .xml, or am I missing something?

Has matio been considered to read models in C++? http://sourceforge.net/projects/matio/

Regards,

Tim

@TimSC
Copy link
Contributor Author

TimSC commented Apr 1, 2013

@vrabaud I just noticed the conversion is in ModelTransfer.cpp but I can't compile it without MatlabIO. I probably will try to do the conversion using matio. Is it possible for someone to send me a model in both formats so I can check my result is correct?

@vrabaud
Copy link
Member

vrabaud commented Apr 1, 2013

Not sure we have models around with both format. Why not use the cvmatio by @hbristow ?
https://github.com/hbristow/cvmatio

@TimSC
Copy link
Contributor Author

TimSC commented Apr 1, 2013

cvmatio depends on MatlabIO.hpp (which I don't currently have). I assumed this was included in Matlab but I could be wrong...

Can someone generate a model in mat format and convert it, if they have compiled ModelTransfer.cpp with MatlabIO enabled?

@TimSC
Copy link
Contributor Author

TimSC commented Apr 2, 2013

I just realized that MatlabIO is provided by cvmatio. Ooops!

cvmatio probably should be a submodule of this project or perhaps just use matio because it supports a wider range of matlab formats such as hdf.

@hbristow
Copy link
Contributor

hbristow commented Apr 3, 2013

Glad you found it :)
The reason I developed cvmatio, was so that eventually we could tightly integrate it as part of cv::FileStorage(). See: http://answers.opencv.org/question/9487/matlab-api-for-opencv/#post-id-9585. The code-base for matio is too fragmented for my liking, and doesn't make use of C++ constructs for type-safe generic storage. You're right though, cvmatio should be made a submodule like models.

H

On 03/04/2013, at 8:40 AM, Tim Sheerman-Chase notifications@github.com wrote:

I just realized that MatlabIO is provided by cvmatio. Ooops!

cvmatio probably should be a submodule of this project or perhaps just use matio because it supports a wider range of matlab formats such as hdf.


Reply to this email directly or view it on GitHub.

@TimSC
Copy link
Contributor Author

TimSC commented Apr 13, 2013

@hbristow I have trained a model based on the buffy stickmen data using octave and I have saved it in matlab v7 format. I am using cvmatio to open the file but it doesn't deserialise correctly.

It appears that the call to name_ = cvmatio.findstd::string(variables, "name"); in MatlabIO.cpp line 84 throws an exception. Any ideas on what to check? Does cvmatio support octave exported matlab v7 files?

Model: http://www.sheerman-chase.org.uk/temp/buffy_model_v7.mat

Tim

@TimSC
Copy link
Contributor Author

TimSC commented Apr 13, 2013

I found I made a mistake in converting the file in octave to v7. Problem solved! Model is convertible.

@TimSC TimSC closed this as completed Apr 13, 2013
@kinjali
Copy link

kinjali commented Jan 10, 2017

@hbristow i am converting .mat file into opencv style using opencv 3.0 and i am getting this
error: /tmp/ccOrkTWM.o: In function main': matlabopencv.cpp:(.text+0xb6): undefined reference to MatlabIO::open(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)'
matlabopencv.cpp:(.text+0x147): undefined reference to MatlabIO::read()' matlabopencv.cpp:(.text+0x184): undefined reference to MatlabIO::close()'
/tmp/ccOrkTWM.o: In function MatlabIO::~MatlabIO()': matlabopencv.cpp:(.text._ZN8MatlabIOD2Ev[_ZN8MatlabIOD5Ev]+0xe): undefined reference to MatlabIO::close()'
collect2: error: ld returned 1 exit status
please help me how to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants