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

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



                                                                                   CHAPTER 6  ■  VISION  175




























                        Figure 6-6. The Video Source window

                        Example 6-6. FindCamera.java
                        package com.scottpreston.javarobot.chapter6;


                        import javax.media.Manager;
                        import javax.media.MediaLocator;
                        import javax.media.Processor;


                        public class FindCamera {
                            public static void main(String[] args) {


                                String url = "vfw://0";
                                try {
                                    MediaLocator ml = new MediaLocator(url);
                                    Processor p = Manager.createProcessor(ml);
                                    System.out.println("Found camera at: " + url);
                                } catch (Exception e) {
                                    System.out.println("Can not find camera at:" + url + ", ➥
                        or problem with JMF install.");
                                } finally {
                                    System.exit(0);
                                }


                            }
                        }
   189   190   191   192   193   194   195   196   197   198   199