On 11 Nov., 19:28, "bruno.postle" <[email protected]> wrote:
> The #-hugin lines are used by the hugin GUI to store non-critical > metadata as key=value pairs. Your parser should at least preserve > them, though we don't have a spec. No spec... sigh :-( A common problem. So what non-critical metadata are there, apart from the crop factor? Can I rely on these data preceding the line they belong to? If they are key-value pairs, that's a consolation, because at least it's easy to parse without touching semantics. I'll include some code in my parser. > > The #-imagefile lines are not used by hugin, they might be something > to do with ptgui. so yet another cook spoiling the broth. This comes from bad design. Someone starts out with an ad-hoc approach, hey, let's just use one- letter-tags and put the value right after them, great idea, scans fast, all I need. Comes time and suddenly there aren't enough letters in the alphabet that even faintly resemble the tag's purpose. Ah, heck, let's just use letter combinations. Someone else comes along, thinks, hey this is ugly, I'll use comments and key-value-pairs. So by now there are three different ways of doing it. If whoever has dreamt up the pto file format in the first place had thought ahead, they'd sure come up with something more timeproof. Maybe it's time for a new format? Like, XML-based? After all we're only talking metadata, so processing time shouldn't be that critical, and there are very good tools to parse XML efficiently (at least in Python...). The pto format by now is a bit unruly, but not beyond parsability, so it'd be a snap to write a format converter to a future- proof format that could be thoroughly thought-out and phased in as an optional alternative, and the parser should be much easier to write as well if it could rely on an underlying format like XML, where every value is typed and the whole parse finishes with a nice clean tree structure. > > Have you looked at Panotools::Script which has a perl parser for .pto > files? Perl and python are not so different... > My parser currently retains every bit of information in the source file, but it only really processes non-comment lines. I reckon your package Panotools::Script::Line does similar things, seems like you're not looking at these non-critical metadata either? I haven't really looked much at libpano's own parser, though enough to have seen that it scans with full semantic awareness (like, this member is such-and- such, so scanf it as a so-and-so)... I thought about just using that scanner, but having to emulate all it's infrastructure in Python would have been much more effort than writing something from scratch, which is the cleaner solution anyway. After all it wasn't that much work, and since parser-building is one of my hobbies, it was even fun. I found perl quite different from Python. This may be because I don't know perl, but I feel the syntax has too many non-alphanumeric characters (like, dollar signs are banned from Python syntax...). It did look terse, though. But I think I also made more of an effort to extract every bit of meaning that could be gleaned without actually touching semantics. with regards Kay -- You received this message because you are subscribed to the Google Groups "Hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hugin-ptx
