O'Reilly logo

Practical Computer Vision with SimpleCV by Katherine Scott, Nathan Oostendorp, Anthony Oliver, Kurt Demaagd

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required