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

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



                 174    CHAPTER 6  ■  VISION














                        Figure 6-4. JMStudio



























                        Figure 6-5. The JMF Registry Editor

                        Code Objective
                        The code objective in this section is to verify that the JMF was installed by finding the webcam
                        via the MediaLocator.

                        Code Discussion

                        This will be a simple test class. The String variable URL will be the locator defined by the JMF
                        Registry Editor. To find the camera, we need to create a MediaLocator object via the URL. Then
                        we’ll create a Processor object using the MediaLocator object. If there are no exceptions, every-
                        thing works and we’re ready to start doing some image capture with the webcam. If not, an
                        exception will print to System.out. See Example 6-6.



                        ■Note  If you have more than one webcam, the Java Media Framework using Video For Windows can only
                        utilize one camera per JVM. If you have this camera opened or want to use a different webcam, you’ll see a
                        Video Source window where you can select a new camera (see Figure 6-6).
   188   189   190   191   192   193   194   195   196   197   198