#include "Stdafx.h"
#include "VideoCapture.h"

namespace Domination {
	namespace Unmanaged {
		namespace OpenCV 
		{
			VideoCapture::VideoCapture()
			{
				ref = new cv::VideoCapture();
			}
			VideoCapture::VideoCapture(int device)
			{
				ref = new cv::VideoCapture(device);
			}
			VideoCapture::VideoCapture(const System::String^ filename)
			{
				interior_ptr<const System::Char> ppchar = PtrToStringChars(filename);
				ref = new cv::VideoCapture(*ppchar);
			}

			VideoCapture::~VideoCapture()
			{
				delete ref;
			}

			bool VideoCapture::open(int device)
			{
				return ref->open(device);
			}
			bool VideoCapture::open(const System::String^ filename)
			{
				interior_ptr<const System::Char> ppchar = PtrToStringChars(filename);
				return ref->open(*ppchar);
			}

			bool VideoCapture::isOpened()
			{
				return ref->isOpened();
			}

			void VideoCapture::release()
			{
				ref->release();
			}

			bool VideoCapture::grab()
			{
				return ref->grab();
			}
			bool VideoCapture::retrieve(Mat^ image)
			{
				return ref->retrieve(*image->ref);
			}
			bool VideoCapture::retrieve(Mat^ image, int channel)
			{
				return ref->retrieve(*image->ref, channel);
			}
			bool VideoCapture::read(Mat^ image)
			{
				return ref->read(*image->ref);
			}

			double VideoCapture::get(VideoCaptureProperties prop)
			{
				return ref->get((int)prop);
			}

			void VideoCapture::set(VideoCaptureProperties prop, double value)
			{
				ref->set((int)prop, value);
			}
		}
	}
}