-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcamera.h
82 lines (65 loc) · 1.82 KB
/
camera.h
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
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (C) 2009 Giacomo Spigler
* 2013 - George Jordanov - improve in performance for HSV conversion and improvements
* 2016 - Tolga Ceylan - ported to robot code with limited mmap only features.
*
* CopyPolicy: Released under the terms of the GNU GPL v3.0.
*/
#ifndef __CAMERA__H__
#define __CAMERA__H__
#include "common.h"
#include <stdint.h>
#include <string.h>
namespace robo {
class Camera
{
public:
enum SettingType {
SETTING_BRIGHTNESS,
SETTING_CONTRAST,
SETTING_SATURATION,
SETTING_HUE,
SETTING_HUE_AUTO,
SETTING_SHARPNESS,
SETTING_MAX
};
struct Buffer {
void *start;
size_t length;
};
struct Setting {
const char *tag;
int vl_id;
int min;
int max;
int def;
int err;
};
int m_width_h;
int m_height;
unsigned char *m_data;
int m_fd;
const char *m_name;
Buffer *m_buffers;
Setting m_settings[SETTING_MAX];
Camera();
~Camera();
int initialize(const char *name, int w, int h, int fps = 30);
void shutdown();
int update(uint64_t now);
int toIplImage(unsigned char *buf, int width) const;
int toGrayScaleIplImage(unsigned char *buf, int width) const;
int toGrayScaleMat(unsigned char *buf, int channels, int cols) const;
int toMat(unsigned char *buf, int channels, int cols) const;
Setting getSetting(SettingType set_type) const;
int setSetting(SettingType set_type, int v);
private:
int start_capture();
int init_mmap();
int open_cam_device();
int initialize_device(int fps);
int capture();
void initialize_setting(SettingType set_type);
};
} // namespace robo
#endif // __CAMERA__H__