#pragma once
#include <opencv\cv.h>
#include <opencv\highgui.h>

#include "VideoCaptureProperties.h"
#include "Mat.h"

namespace Domination {
	namespace Unmanaged {
		namespace OpenCV {

			public ref class VideoCapture {
			private:
				cv::VideoCapture* ref;

			public:
				/// <summary>VideoCapture constructors.</summary>
				VideoCapture();
				/// <summary>VideoCapture constructors.</summary>
				VideoCapture(int device);
				/// <summary>VideoCapture constructors.</summary>
				VideoCapture(const System::String^ filename);

				~VideoCapture();

				/// <summary>Open video file or a capturing device for video capturing</summary>
				bool open(int device);
				/// <summary>Open video file or a capturing device for video capturing</summary>
				bool open(const System::String^ filename);

				/// <summary>Returns true if video capturing has been initialized already.</summary>
				bool isOpened();

				/// <summary>Closes video file or capturing device.</summary>
				void release();

				/// <summary>Grabs the next frame from video file or capturing device.</summary>
				bool grab();
				/// <summary>Decodes and returns the grabbed video frame.</summary>
				bool retrieve(Mat^ image);
				/// <summary>Decodes and returns the grabbed video frame.</summary>
				bool retrieve(Mat^ image, int channel);
				/// <summary>Grabs, decodes and returns the next video frame.</summary>
				bool read(Mat^ image);

				/// <summary>Returns the specified VideoCapture property</summary>
				double get(VideoCaptureProperties prop);
				/// <summary>Sets a property in the VideoCapture.</summary>
				void set(VideoCaptureProperties prop, double value);
			};

		}
	}
}