summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/camera.h
blob: f26a7a8fdbfa58140958428a7babede51a6aace2 (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
/* Copyright (c) 2012 Patrick Ruoff
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#ifndef CAMERA_H
#define CAMERA_H

#include <opencv2/opencv.hpp>

// ----------------------------------------------------------------------------
struct CamInfo
{
	int res_x;
	int res_y;
	int fps;
	float f;	// (focal length) / (sensor width)
};

// ----------------------------------------------------------------------------
class Camera
{
public:
	
	Camera();
	~Camera();

	void set_index(int index);
	void set_f(float f) { cam_info.f = f; }
	bool set_fps(int fps);
	bool set_res(int x_res, int y_res);

	// gets a frame from the camera, dt: time since last call in seconds
	cv::Mat get_frame(float dt);

	// WARNING: returned reference is valid as long as object
	const CamInfo& get_info() const { return cam_info; }

protected:
	int active_index;
	CvCapture* cap;
	CamInfo cam_info;
	float dt_valid;
	float dt_mean;
};

#endif //CAMERA_H