/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/************************************************************************/
/*  This example demonstrates:                                          */
/*      - Working with a camera.                                        */
/*      - Calculating refocus image                                     */
/*      - Displaying result                                             */
/************************************************************************/


// Example heavily reworked into RxCamera class

#include "RxCamera.h"


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// 	Main entry-point for this application.
/// </summary>
///
/// <param name="argc"> Number of command-line arguments. </param>
/// <param name="argv"> Array of command-line argument strings. </param>
///
/// <returns> Exit-code for the process - 0 for success, else an error code. </returns>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{

	std::cout << "creating and starting camera..." << std::endl;

	RxCamera cam;

	if (!cam.haveCamera()) {
		std::cout << "No camera found, check power to camera." << std::endl;
		return 0;
	}

	cam.start();

	bool bEnd = false;

	while (!bEnd) {

		if (_kbhit()) {
			switch (_getch()) {
			case 'r':
				if (cam.isRecording())
					cam.stopRecording();
				else
					cam.startRecording();
				break;
			case 'q':
				bEnd = true;
				break;
			}

		}
		_sleep(100);
	}

	cam.stop();

	// The example is finished
	printf("finished.\n");

	// Wait for user to press any key.
	printf("Press any key...\n");
	_getch();

	return 0;
}
