1 /* 2 * Copyright 2016 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef CAMERA_CHARACTERISTICS_H_ 8 #define CAMERA_CHARACTERISTICS_H_ 9 10 #include "common_types.h" 11 12 #include <unordered_map> 13 14 #include <base/macros.h> 15 16 // CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf. 17 // There are several assumptions of the config file: 18 // 1. Each line should be at most 256 characters long. 19 // 2. camera id should be in ascending order (i.e., 0, 1, 2, ...). 20 // 3. usb_vid_pid should be the first subkey. 21 // 4. All configs of a module should be put together. 22 // 23 // Example of the config file: 24 // camera0.lens_facing=0 25 // camera0.sensor_orientation=0 26 // camera0.module0.usb_vid_pid=0123:4567 27 // camera0.module0.horizontal_view_angle=68.4 28 // camera0.module0.lens_info_available_focal_lengths=1.64 29 // camera0.module0.lens_info_minimum_focus_distance=0.22 30 // camera0.module0.lens_info_optimal_focus_distance=0.5 31 // camera0.module0.vertical_view_angle=41.6 32 // camera0.module1.usb_vid_pid=89ab:cdef 33 // camera0.module1.lens_info_available_focal_lengths=1.69,2 34 // camera1.lens_facing=1 35 // camera1.sensor_orientation=180 36 class CameraCharacteristics { 37 public: 38 CameraCharacteristics(); 39 ~CameraCharacteristics(); 40 41 // Parses /etc/camera/camera_characteristics.conf. 42 // Returns DeviceInfos with default characteristics if the config file doesn't 43 // exist. 44 const DeviceInfos GetCharacteristicsFromFile( 45 const std::unordered_map<std::string, std::string>& devices); 46 47 private: 48 void AddPerCameraCharacteristic( 49 uint32_t camera_id, const char* characteristic, const char* value, 50 DeviceInfos* device_infos); 51 void AddPerModuleCharacteristic( 52 uint32_t camera_id, const char* characteristic, const char* value, 53 DeviceInfos* device_infos); 54 void AddFloatValue(const char* value, const char* characteristic_name, 55 float* characteristic); 56 57 DISALLOW_COPY_AND_ASSIGN(CameraCharacteristics); 58 }; 59 60 #endif // CAMERA_CHARACTERISTICS_H_ 61