liuliu / ccv

C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library
http://libccv.org
Other
7.08k stars 1.72k forks source link

dpmdetect get wrong results in cygwin #204

Closed wandering007 closed 7 years ago

wandering007 commented 7 years ago

I trained a dpm model using dpmcreate on Linux. And to use it Windows, I compiled ccv in cygwin successfully. However, when I test the model using dpmdetect.exe in cygwin, the results are always no objects detected (https://github.com/liuliu/ccv/blob/stable/bin/dpmdetect.c#L34). But It indeed can detect objects on Linux (Same code, input image and model). On Windows, I didn't use liblinear, cuda or gsl when compiling, but they are not necessary for detecting, if I didn't get it wrong.
Pretty weird...What are the probable causes? Compiler differences? I've checked several times but didn't figure it out.

wandering007 commented 7 years ago

Problem solved.
The _ccv_dpm_write_checkpoint function (https://github.com/liuliu/ccv/blob/stable/lib/ccv_dpm.c#L169) writes model file with fprintf(w, "%la %la %la %la\n", ...). Then the float-point number is saved in hex format. And these numbers in model file is read by fscanf . However, fscanf from gcc in cygwin does not support to read hex number (0x...).
I personally suggest not to save values in hex format, which is kind of old-fashioned and not supported by fscanf on Windows.

liuliu commented 7 years ago

Thank you. That makes sense. The reason to save in hex is to keep the accuracy of the float representation. However, it won't matter in future development because we are pretty settled with SQLite as the on disk format.