protected static WebcamDriver findDriver ( List < String > names , List < Class < ? > > classes ) { for ( String name : names ) { LOG . info ( "Searching driver {}" , name ) ; Class < ? > clazz = null ; for ( Class < ? > c : classes ) { if ( c . getCanonicalName ( ) . equals ( name ) ) { clazz = c ; break ; } } if ( clazz == null ) { try { clazz = Class . forName ( name ) ; } catch ( ClassNotFoundException e ) { LOG . trace ( "Class not found {}, fall thru" , name ) ; } } if ( clazz == null ) { LOG . debug ( "Driver {} not found" , name ) ; continue ; } LOG . info ( "Webcam driver {} has been found" , name ) ; try { return ( WebcamDriver ) clazz . newInstance ( ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } } return null ; }
Find webcam driver . Scan packages to search drivers specified in the argument .