Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Utilidades/src/OpenCVCamera.cpp
blob: e868480b5ee2eaafd53c86436b1a944480bb87e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * OpenCVCamera.cpp
 *
 *  Created on: 22/02/2011
 * @author Sebastián Marichal
 * 		   sebastian_marichal@hotmail.com
 * 		   sebarocker@gmail.com
 *
 * Universidad de la República, Montevideo , Uruguay
 */

#include "OpenCVCamera.h"


	//Constructor
	OpenCVCamera::OpenCVCamera(){
		printf("OpenCVCamera construido\n");
	}

	//Destructor
	OpenCVCamera::~OpenCVCamera(){
		if(capture!=NULL){
			cvReleaseCapture(&capture);
		}
		if(frame!=NULL){
			cvReleaseImage(&frame);
		}
	}

	void OpenCVCamera::getInfo(){
		printf("OpenCVCamera es una utilidad para leer el video desde la camara web o desde un archivo\n");
	}
	/**
	 * tipo = 0 lee de la camara web
	 * tipo = 1 lee del archivo file
	 */
	int OpenCVCamera::initCamera(int tipo, const char * file,int width,int height){
		if(tipo==READ_FROM_CAM){
			capture = cvCreateCameraCapture(0);
			if(capture==NULL)
				return 0;
			cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,320);
			cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,240);
			/*	NO FUNCIONA SETEAR EL FPS
			 * cvSetCaptureProperty(capture, CV_CAP_PROP_FPS,5);
			 * */
		}else if(tipo==READ_FROM_FILE){
			printf("1\n");
			capture = cvCreateFileCapture(file);
			printf("2\n");
			if(capture==NULL){
				printf("3\n");
				return 0;
			}
			printf("4\n");
			cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,320);
			cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,240);
		}

		return 1;
	}

	IplImage* OpenCVCamera::queryFrame(){
		frame = cvQueryFrame(capture);
		return frame;
	}

	IplImage* OpenCVCamera::getLastFrame(){
		return frame;
	}