#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "psvideophot.h"

int main(int argc, char **argv) {

    psLibInit(NULL);

    psTimerStart(TIMER_TOTAL);

    // Parse the configuration and arguments
    // Open the input image(s)
    // Determine camera, format from header if not already defined
    // Construct camera in preparation for reading
    pmConfig *config = psvideophotArguments(argc, argv);
    if (config == NULL) {
        psErrorStackPrint(stderr, "Unable to parse command-line arguments.");
        psvideophotCleanup(config, NULL);
        exit(PS_EXIT_CONFIG_ERROR);
    }

    psvideophotVersionPrint();

    // define recipe options
    // define the active I/O files
     psvideophotOptions *options = psvideophotParseCamera(config);
    if (options == NULL) {
        psErrorStackPrint(stderr, "Unable to parse camera.");
        psvideophotCleanup(config, options);
        exit(PS_EXIT_CONFIG_ERROR);
    }

    // Image Arithmetic Loop
    if (!psvideophotLoop(config, options)) {
        psErrorStackPrint(stderr, "Unable to loop over input");
        psvideophotCleanup(config, options);
        exit(PS_EXIT_SYS_ERROR);
    }

    psLogMsg("psvideophot", PS_LOG_INFO, "Complete psvideophot run: %f sec\n", psTimerMark(TIMER_TOTAL));

    // Cleaning up
    //    psvideophotCleanup(config, options);

    return PS_EXIT_SUCCESS;
}
