summaryrefslogtreecommitdiffstats
path: root/libcamera/inc/camera_parameters.h
blob: f6a0e7a2f53db8f459cd60d90072aa9e20c5f3ce (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#ifndef __CAMERA_PARAMETERS_H__
#define __CAMERA_PARAMETERS_H__

#include <vector>
#include <string>

#include "camera.h"

namespace camera
{

/**
 * Image frame dimensions
 */
struct ImageSize
{
    int width;  /*!< Image width in pixels */
    int height; /*!< Image height in pixels */

    ImageSize() : width(0), height(0) {}
    ImageSize(int w, int h) : width(w), height(h) {}
};

/**
 * Structure for storing values for ranged parameters such as
 * brightness, contrast, fps etc.
 */
struct Range
{
    int min;    /*!< minimum value */
    int max;    /*!< maximum value */
    int step;   /*!< step increment for intermediate values */

    Range() : min(0), max(0), step(0) {}
    Range(int m, int x, int s) : min(m), max(x), step(s) {}
};

/**
 * Available values for video FPS
 * 1X, 2X, 3X describes the video FPS values relative to preview
 * FPS. With video fps set to 3X, the video will run 3X the
 * speed of preview. This is also called HFR (High FrameRate)
 * mode
 * */
enum VideoFPS
{
    VIDEO_FPS_1X = 1,   /*!< 1x regular framerate mode */
    VIDEO_FPS_2X = 2,   /*!< 2x High framerate mode */
    VIDEO_FPS_3X = 3,   /*!< 3x High framerate mode */
    VIDEO_FPS_4X = 4, /*!< 4x High framerate mode */
    VIDEO_FPS_5X = 5, /*!< 5x High framerate mode */
};

/* focus mode values */
const std::string FOCUS_MODE_AUTO = "auto";
const std::string FOCUS_MODE_INFINITY = "infinity";
const std::string FOCUS_MODE_MACRO = "macro";
const std::string FOCUS_MODE_FIXED = "fixed";
const std::string FOCUS_MODE_EDOF = "edof";
const std::string FOCUS_MODE_CONTINUOUS_VIDEO = "continuous-video";
const std::string FOCUS_MODE_CONTINUOUS_PICTURE = "continuous-picture";
const std::string FOCUS_MODE_MANUAL_POSITION = "manual";

/* ISO values */
const std::string ISO_AUTO = "auto";
const std::string ISO_HJR = "ISO_HJR";
const std::string ISO_100 = "ISO100";
const std::string ISO_200 = "ISO200";
const std::string ISO_400 = "ISO400";
const std::string ISO_800 = "ISO800";
const std::string ISO_1600 = "ISO1600";
const std::string ISO_3200 = "ISO3200";

/* White Balance values */
const std::string WHITE_BALANCE_AUTO = "auto";
const std::string WHITE_BALANCE_INCANDESCENT = "incandescent";
const std::string WHITE_BALANCE_FLUORESCENT = "fluorescent";
const std::string WHITE_BALANCE_WARM_FLUORESCENT = "warm-fluorescent";
const std::string WHITE_BALANCE_DAYLIGHT = "daylight";
const std::string WHITE_BALANCE_CLOUDY_DAYLIGHT = "cloudy-daylight";
const std::string WHITE_BALANCE_TWILIGHT = "twilight";
const std::string WHITE_BALANCE_SHADE = "shade";
const std::string WHITE_BALANCE_MANUAL_CCT = "manual-cct";

enum StatsLoggingMask {
    STATS_NO_LOG           = 0,
    STATS_AEC_LOG_MASK     = (1 << 0),
    STATS_AWB_LOG_MASK     = (1 << 1),
    STATS_AF_LOG_MASK      = (1 << 2),
    STATS_ASD_LOG_MASK     = (1 << 3),
    STATS_AFD_LOG_MASK     = (1 << 4),
    STATS_ALL_LOG          = 0x1F,
};


class CameraParams : public ICameraParameters
{
public:

    CameraParams();

    virtual ~CameraParams();

    /**
     * initialize the object by getting current state of parameters
     * from device.
     *
     * @param device : A valid camera device object
     *
     * @return int : 0 on success
     */
    virtual int init(ICameraDevice* device);

    virtual int writeObject(std::ostream& ps) const;
    
    int readObject(char *paramString);

    /**
     * get a string representation of the object
     *
     * @return std::string
     */
    std::string toString() const;

    /**
     * Updates the current state of the parameters to camera device.
     * Fails for any invalid entries.
     *
     * @return int : 0 on success
     */
    virtual int commit();

    /**
     * get preview sizes supported by the camera
     *
     * @return std::vector<ImageSize> : list of preview sizes
     */
    std::vector<ImageSize> getSupportedPreviewSizes() const;

    /**
     * set preview size
     *
     * @param size
     */
    void setPreviewSize(const ImageSize& size);

    /**
     * get current preview size
     *
     * @return ImageSize
     */
    ImageSize getPreviewSize() const;

    /**
     * get video sizes supported by the camera
     *
     * @return std::vector<ImageSize> : list of video sizes
     */
    std::vector<ImageSize> getSupportedVideoSizes() const;

    /**
     * get current video size
     *
     * @return ImageSize
     */
    ImageSize getVideoSize() const;

    /**
     * set video size
     *
     * @param size
     */
    void setVideoSize(const ImageSize& size);

    /**
     * get picture sizes supported by the camera
     *
     * @return std::vector<ImageSize> : list of picture sizes
     */
    std::vector<ImageSize> getSupportedPictureSizes() const;

    /**
     * get current picture size
     *
     * @return ImageSize
     */
    ImageSize getPictureSize() const;

    /**
     * set picture size
     *
     * see @ref takePicture
     *
     * @param size
     */
    void setPictureSize(const ImageSize& size);


    /**
     * generic get function to get string representation of value of
     * a parameter using a key.
     *
     * @param key [in]
     *
     * @return std::string : value
     */
    virtual std::string get(const std::string& key) const;

    /**
     * generic get function to get string representation of value of
     * a parameter using a key.
     *
     * @param key [in]
     *
     * @return int : value
     */
    virtual int getInt(const std::string& key) const;

    /**
     * generic set function to set value of a parameter using
     * key-value pair
     *
     * @param key [in]
     * @param value [in]
     */
    virtual void set(const std::string& key, const std::string& value);

    /**
     * generic set int function to set value of a parameter using
     * key-value pair
     *
     * @param key [in]
     * @param value [in]
     */
    virtual void setInt(const std::string& key, int value);

    /**
     * get a list of supported focus modes
     *
     * @return vector<string> : focus mode values
     */
    std::vector<std::string> getSupportedFocusModes() const;

    /**
     * get current value of focus mode
     *
     * @return std::string
     */
    std::string getFocusMode() const;

    /**
     * set focus mode value
     *
     * @param value
     */
    void setFocusMode(const std::string& value);

    /**
     * get a list of supported whitebalance modes
     *
     * @return vector<string> : whitebalance values
     */
    std::vector<std::string> getSupportedWhiteBalance() const;

    /**
     * get current value of whitebalance mode
     *
     * @return std::string
     */
    std::string getWhiteBalance() const;

    /**
     * set whitebalance mode value
     *
     * @param value
     */
    void setWhiteBalance(const std::string& value);

    /**
     * get a list of supported ISO modes
     *
     * @return vector<string> : ISO values
     */
    std::vector<std::string> getSupportedISO() const;

    /**
     * get current value of ISO mode
     *
     * @return std::string
     */
    std::string getISO() const;

    /**
     * set ISO mode value
     *
     * @param value
     */
    void setISO(const std::string& value);

    /**
     * get a range of supported sharpness values
     *
     * @return Range : sharpness range
     */
    Range getSupportedSharpness() const;

    /**
     * get current sharpness value
     *
     * @return int
     */
    int getSharpness() const;

    /**
     * set sharpness value
     *
     * @param value
     */
    void setSharpness(int value);

    /**
     * get a range of supported brightness values
     *
     * @return Range : brightness range
     */
    Range getSupportedBrightness() const;

    /**
     * get current brightness value
     *
     * @return int
     */
    int getBrightness() const;

    /**
     * set brightness value
     *
     * @param value
     */
    void setBrightness(int value);

    /**
     * get a range of supported contrast values
     *
     * @return Range : contrast range
     */
    Range getSupportedContrast() const;

    /**
     * get current contrast value
     *
     * @return int
     */
    int getContrast() const;

    /**
     * set contrast value
     *
     * @param value
     */
    void setContrast(int value);

    /**
     * get supported ranges for preview FPS The FPS range has valid
     * min and max value. Actual fixed point FPS value is calculated
     * by dividing the min and max values by 1000. For example, max
     * value of 26123 represents 26.123 fps.
     *
     * @return vector<Range> : preview fps ranges
     */
    std::vector<Range> getSupportedPreviewFpsRanges() const;

    /**
     * get current preview fps range value
     *
     * @return Range
     */
    Range getPreviewFpsRange() const;

    /**
     * set preview fps range value
     *
     * @param value
     */
    void setPreviewFpsRange(const Range& value);

    /**
     * get a list of fixed FPS values for video stream.
     *
     * @return vector<VideoFPS> : video fps values
     */
    std::vector<VideoFPS> getSupportedVideoFps() const;

    /**
     * get current video fps mode
     *
     * @return VideoFPS
     */
    VideoFPS getVideoFPS() const;

    /**
     * set video fps mode.
     *
     * Note: Setting the mode to high framerate will override
     * preview FPS settings. see \ref VideoFPS for high framerate
     * values.
     *
     * @param VideoFPS
     */
    void setVideoFPS(VideoFPS value);

    /**
     * get a list of supported preview formats
     *
     * @return std::vector<std::string>
     */
    std::vector<std::string> getSupportedPreviewFormats() const;

    /**
     * get current preview format
     *
     * @return std::string
     */
    std::string getPreviewFormat() const;

    /**
     * set preview format
     *
     * @param value
     */
    void setPreviewFormat(const std::string& value);

     /**
     * set manual exposure in sensor
     *
     * @param value
     */
    void setManualExposure(int value);

    /**
     * set manual gain in sensor
     *
     * @param value
     */
    void setManualGain(int value);

    /**
     * set vertical flip bit in sensor
     *
     * @param value
     */
    void setVerticalFlip(bool value);

    /**
     * set horizontal mirror bit in sensor
     *
     * @param value
     */
    void setHorizontalMirror(bool value);


     /**
     * set stats logging mask
     *
     * @param value
     */
    void setStatsLoggingMask(int value);

private:

    /**
     * private implementation and storage handle for parameters
     */
    void *priv_;

    /**
     * handle to attached camera device
     */
    ICameraDevice *device_;
}; /* class CameraParams */

} /* namespace camera */

#endif  /* __CAMERA_PARAMETERS_H__ */