Appendix A. Advanced Shell Tips

Chapter 2 introduced the SimpleCV shell and some of the most common commands. This appendix covers a few additional tricks for working with the shell, including:

  • Macros to automate tasks

  • Timing to test the performance on scripts

Not all vision system developers need to know this, but power users may find that these tricks help streamline the development process.

Macro Magic

Chapter 2 described the SimpleCV shell as a tool for testing small snippets of code. However, when working with more than a few lines of code, it is often convenient to create reusable blocks of code. This is done with macros. Macro means big. In the case of a shell, this means a big block of code. Obviously, big is a relative term, in this case contrasted with the “micro” size of a few lines of code. Macros are most appropriate when testing or using the same block of code repeatedly. For example, macros are great for automatically setting up the camera object, loading a few images, or other repetitive initialization tasks.

Note

Macros probably sound a bit like functions. However, macros do not take any parameters. The closest thing to a parameter with a macro is to create variables outside of the macro, set those variables to a desired value, and then reference those variables from inside the macro.

The SimpleCV shell already has macro support built in. Shell macros are created from the history of previously used commands. These commands are bundled together into a single macro. A macro ...

Get Practical Computer Vision with SimpleCV now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.