tsdconseil / opencv-demonstrator

OpenCV demonstrator (GUI)
http://www.tsdconseil.fr/log/opencv/demo/index-en.html
GNU Lesser General Public License v3.0
141 stars 57 forks source link

cfg.xml #53

Closed applemuncy closed 8 years ago

applemuncy commented 8 years ago

<?xml version="1.0" encoding="ISO-8859-1"?>

Fist of all, encoding is wrong. Second, nothing seems to be getting written.

juliena82 commented 8 years ago

On my PC (Windows), I have this content (2 lines):

<?xml version="1.0" encoding="ISO-8859-1"?>
<global-schema />

Haven't you the second line? Also, at which location have you found the cfg.xml file (it should be in ~/.ocvdemo/cfg.xml) ?

Also, this file contains only ASCII data, so the encoding is not so important (it is both ISO and UTF8 ;) ) . Yet, now that all the rest is utf8, i will change that.

applemuncy commented 8 years ago

Yes,<global-schema /> in mine also but because I didn't use markdown, it didn't show.

But shouldn't other data be persistent like language choice and input sources?

juliena82 commented 8 years ago

Yes, totally right, input sources should be there : it will be added when it is managed in the image selecteur. As for language selection, the XML tree do not save attributes when they are equal to their default values, and as you have probably selected English as language, and as English is the default language, it is implied...

juliena82 commented 8 years ago

Last commit changed the output encoding to UTF-8.

applemuncy commented 8 years ago

OK @juliena82, I see that it is in fact writing langue = "0" to cfg.xml I'm a bit surprised to see "0" instead of "fr"

I've been looking into how Gtkmm, Glade, and also libxml++ I know you have put years of work into your library but I'm wondering if many of the things your library does could be done more easily using those where they have become stable.

juliena82 commented 8 years ago

Yes of course, you're right, we should't reinvent the Wheel ;) But now I don't want to spend too much time on it, and I prefer to reuse old libraries which I already know...

applemuncy commented 8 years ago

@juliena82 I think we should keep this issue open and talk about configuration enhancements here.

I think a default copy of cfg.xml should be stored in opencv-demo/ocvdemo/data with as many of opencv-demo's default settings encoded in it as practical. At program start-up the main thread check for the existence of .ocvdemo/cfg.xml and then does a system copy if it doesn't exist. Then the main thread should try to read it in but, on failure, complain to the user that configuration could not be written and halt. As it is now, many configuration options are buried as magic numbers in code.
I'm wondering now if gtk already has a command line arg that deals with user supplying a config.file path?

One of the defaults that should be in cfg.xml is which demo gets run at program start. Another default needed is default image sources.

As it is now, a user must pick a demo to run before the user can use the image_selection class.

applemuncy commented 8 years ago

By the way, IMO using the absence of the langue = "" as indication of default should be changed along with using standard encoding of fr en ru de etc rather than a number.

juliena82 commented 8 years ago

Can you elaborate please?

juliena82 commented 8 years ago

I close the issue since the original question has been answered, but I see that I didn't answer to all your remarks @applemuncy. In fact, you suggest to have an additionnal cfg.xml file with the default values for the démos, but this is not required, as the default values are already stored in the file schema.xml (see the default field in each attribute).