class FileRetriever implements ImageRetrieverInterface {

    @Override
    public void setupDataRetrieval(Map<String, ?> dataSourceConfig, ObjectRecognitionCore source) throws Exception {
        // Check if the file is a video
        if (dataSourceConfig.get(FILE_EXTENSION) instanceof String) {
            String ext = (String) dataSourceConfig.get(FILE_EXTENSION);
            if (ext.equals("mov") || ext.equals("mp4")) {
                isMov = true;
            }
        }

        // Load OpenCV
        try {
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        } catch (Throwable t) {
            throw new Exception(this.getClass().getCanonicalName() + ".opencvDependency" 
                    + ": Could not load OpenCv for FileRetriever."
                    + "This is most likely due to a missing .dll/.so/.dylib. Please ensure that the environment "
                    + "variable 'OPENCV_LOC' is set to the directory containing '" + Core.NATIVE_LIBRARY_NAME
                    + "' and any other library requested by the attached error", t);
        }
        
        // Save the initial file location
        if (dataSourceConfig.get(FILE_LOCATION) instanceof String) {
            defaultImageLocation = (String) dataSourceConfig.get(FILE_LOCATION);
            // Setup OpenCV to read the video if the file is a video
            if (isMov) {
                // Open the requested file
                capture = new VideoCapture(defaultImageLocation);
                
                // Exit if the video cannot be read
                if (!capture.isOpened()) {
                    capture.release();
                    if (!new File(defaultImageLocation).exists()) {
                        throw new ImageAcquisitionException(this.getClass().getCanonicalName() + ".mainVideoDoesNotExist: "
                                + "The requested video '" + defaultImageLocation + "' does not exist");
                    }
                    throw new IllegalArgumentException(this.getClass().getCanonicalName() + ".invalidMainVideo: " 
                            + "Intended video '" + defaultImageLocation + "' could not be opened. Most likely OpenCV is not "
                            + "compiled with the codecs required to read this video type");
                }
                
                // Obtain the frame rate of the video, defaulting to 24
                double videoFps = capture.get(Videoio.CAP_PROP_FPS);
                if (videoFps == 0) {
                    videoFps = 24;
                }
                
                // Calculate the number of frames to move each capture
                double fps = 0;
                if (dataSourceConfig.get(FPS) instanceof Number) {
                    fps = ((Number) dataSourceConfig.get(FPS)).doubleValue();
                }
                if (fps <= 0) {
                    frameInterval = 1;
                } else {
                    frameInterval = (int) Math.ceil(videoFps / fps);
                }
                
            }
        }
    }

}