summaryrefslogtreecommitdiff
path: root/src/imaging/CameraInfo.cpp
blob: b33789f7c7b6b599e9a7ed4800a6456db46225f8 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
//  libavg - Media Playback Engine.
//  Copyright (C) 2003-2014 Ulrich von Zadow
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//  Current versions can be found at www.libavg.de
//
//  V4L2/libavg compliance by 02L > Outside Standing Level

#include "CameraInfo.h"

namespace avg {

CameraImageFormat::CameraImageFormat(IntPoint size, PixelFormat pixelFormat,
        FrameratesVector framerates)
{
    m_Size = size;
    m_PixelFormat = pixelFormat;
    m_Framerates = framerates;
}

CameraImageFormat::~CameraImageFormat()
{

}

IntPoint CameraImageFormat::getSize()
{
    return m_Size;
}

PixelFormat CameraImageFormat::getPixelFormat()
{
    return m_PixelFormat;
}

FrameratesVector CameraImageFormat::getFramerates()
{
    return m_Framerates;
}


CameraControl::CameraControl(const std::string& sControlName, int min, int max,
        int defaultValue)
{
    m_sControlName = sControlName;
    m_Min = min;
    m_Max = max;
    m_DefaultValue = defaultValue;
}

CameraControl::~CameraControl()
{

}

std::string CameraControl::getControlName()
{
    return m_sControlName;
}

int CameraControl::getMin()
{
    return m_Min;
}

int CameraControl::getMax()
{
    return m_Max;
}

int CameraControl::getDefault()
{
    return m_DefaultValue;
}


CameraInfo::CameraInfo(const std::string& sDriver, const std::string& sDeviceID)
{
    m_sDriver = sDriver;
    m_sDeviceID = sDeviceID;
}

CameraInfo::~CameraInfo()
{

}

void CameraInfo::addControl(CameraControl control)
{
    m_Controls.push_back(control);
}

void CameraInfo::addImageFormat(CameraImageFormat format)
{
    m_Formats.push_back(format);
}

std::string CameraInfo::getDriver()
{
    return m_sDriver;
}

std::string CameraInfo::getDeviceID()
{
    return m_sDeviceID;
}

CameraImageFormatsVector CameraInfo::getImageFormats()
{
    return m_Formats;
}

CameraControlsVector CameraInfo::getControls()
{
    return m_Controls;
}

void CameraInfo::checkAddBayer8()
{
    CameraImageFormatsVector::iterator it = m_Formats.begin();
    CameraImageFormatsVector i8ImageFormats;
    bool hasColor = false;
    for (; it!=m_Formats.end(); it++) {
        PixelFormat pf = (*it).getPixelFormat();
        if (pf == I8) {
            i8ImageFormats.push_back(*it);
        }
        if (hasColor == false) {
            hasColor = pixelFormatIsColored(pf);
        }
    }
    if (hasColor) {
        it = i8ImageFormats.begin();
        for (; it!=i8ImageFormats.end(); it++) {
                PixelFormat format = BAYER8;
                IntPoint size = (*it).getSize();
                FrameratesVector framerates = (*it).getFramerates();
                CameraImageFormat bayerImageFormat = CameraImageFormat(size, format,
                        framerates);
                m_Formats.push_back(bayerImageFormat);
        }
    }
}

}