// ManejoMemoria.cpp : Defines the entry point for the console application.
//
#include <stdio.h>

/*CUDA*/
#include <cuda_runtime.h>

/*OpenCV*/
#include <opencv2/highgui/highgui.hpp>

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

	cudaSetDevice(0);


	/*Host Variables*/
	int imageW, imageH;				  //Size of Image
	cv::Mat frame_Original;   			  //Original Image
	
	
	/*Device Variables*/
	uchar3 *Image_dev;

	cv::namedWindow("Original Frame",CV_WINDOW_AUTOSIZE);

	
	/*Load Image*/
	char name_imag[500];
	sprintf(name_imag,"../../Images/Estacion.jpg");
	frame_Original = cv::imread(name_imag,1);


	/*Size of Image*/
	imageW=frame_Original.cols;
	imageH=frame_Original.rows;
	size_t size=imageW*imageH*sizeof(uchar3);
	

	/*Create device memory*/
	cudaMalloc((void **)&Image_dev,size);


	/*Copy Memory (Host-->Device)*/
	cudaMemcpy(Image_dev,frame_Original.data,size,cudaMemcpyHostToDevice);


	/*----------------------*/
	/* kernel function .... */
	/*----------------------*/


	/*Copy Memory (Device-->Host)*/
	cudaMemcpy(frame_Original.data,Image_dev,size,cudaMemcpyDeviceToHost);


	cv::imshow("Original Frame",frame_Original);
	cv::waitKey(0);

	/*Clean Memory*/
	/*Host*/
	cv::destroyWindow("Original Frame");
	//frame_Original.release();


	/*Device*/
	cudaFree(Image_dev);

	return(0);
}

