Page 186 - The Definitive Guide to Building Java Robots
P. 186

Preston_5564C06.fm  Page 167  Friday, September 23, 2005  5:13 AM



                                                                                   CHAPTER 6  ■  VISION  167



                            White = 255, 255, 255
                            Black = 0, 0, 0
                            This is the color model we’ll use for this chapter.
                            Other models include
                           • CMYK: This employs subtractive color and is used in printing because it describes the
                             light that needs to be reflected so you can see a specific color.
                           • YIQ: This is used in NTSC video signaling or broadcast television in North America. The
                             YIQ stores luminance and two chrominance values.
                           • YUV: This color model is close to PAL video signaling or broadcast television in much of
                             the rest of the world. It contains one luminance and two chrominance components.
                           • YPbPr: This is used in video compression such as MPEG and JPEG. You also might notice
                             these labels on the back of your component video of your DVD player or television.

                            It’s important to note that these different color models are interchangeable. For example,
                        there are equations that will match Y, U, and V values from R, G, and B values, and vice versa.
                        Also, of the two webcams I have, the first Logitech Webcam encodes in RGB, but my Pyro 1394 uses
                        YUV. This won’t make a difference since all the video streams get converted to BufferedImages of
                        the ColorModel equal to RGB.
                            Now let’s create a few helper classes and a simple Swing component before we move on to
                        the next section, which involves capturing an image from our webcam.

                        Code Objective
                        The objective of the code in this section is to create a simple Swing component with the current
                        operating system look and feel.

                        Code Discussion

                        In Example 6-1, I’ll use the java.swing.UIManager class to set the look and feel of the window.
                        You can choose a number of look and feels (LAFs). The one we’ll use in all our examples will be
                        the native look and feel.

                        Example 6-1. WindowUtilities.java
                        package com.scottpreston.javarobot.chapter6;


                        import javax.swing.UIManager;
                        public class WindowUtilities {
   181   182   183   184   185   186   187   188   189   190   191