Coming soon: Visualization Refactoring

At first, the visualization module of the Orfeo ToolBox was designed as a lightweight tool to view results at the end of a pipeline and to be integrated into graphical OTB applications. But as the number of these applications increases, we started adding more and more features to this tool: polygonal ROI selection, link betweeen displays, histograms … Since the initial design was not supposed to handle such things, code was growing and side-effects became more and more frequent. Needless to say, the cost of adding new functions tends to grow along with the code … It was about time to do something.

For a few weeks now, the OTB development team has been working on this task called refactoring. In software development, the purpose of refactoring is to rewrite parts of the code to enhance its robustness and clarity, to make it easier to maintain and re-usable in other contexts, without modifying its external functional behaviour (source: wikipedia). That is why end users should not notice a lot of changes appart from minor changes in the way it looks. But behind the curtains, it makes a big difference.

The whole visualization module is now fully compliant with the Model-View-Controller architecture in use in the most recent OTB applications. The initial limited set of classes has been splitted into several lighter classes and customization entry points have been carefully introduced in each critical part in order to provide maximum extensibility at minimal cost. Adding a new user interaction, a new type of curve to display or a new eyecandy object rendering onto the image is now as simple as rewriting a light class with about no code overhead.

The otbFeatureExtractionApplication was chosen to beta-test the refactored module, and was therefore modified to use the new visualization tool. Migrating the applications essentially involved removing hundreds of lines of code without compromising any of its functions, and therefore greatly improved its clarity, robustness and maintainabilty. We are already on the way to migrate other applications in order to make everyone benefit from the changes.

The otbFeatureExtractionApplication now uses the new visualization module

The otbFeatureExtractionApplication now uses the new visualization module

Using the new design, we also built a new overlay component to render the content of a shapefile or a kml file over an image in about no time.

Using the new design, a tool to quickly render vector data files (shapefile or kml) has been built

Using the new design, a tool to quickly render vector data files (shapefile or kml) has been built

Of course, this does not extend the functionnal scope of the Orfeo ToolBox or its applications, but in the future, it will help us to reduce the cost and improve the robustness of new applications. Developping users will also find it easier to extend it to suit their needs. For further technical details, you might want to read the OTB wiki page on this topic, which includes a small tutorial to start using the new visualization module.