Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| 6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 namespace media { | |
| 13 | |
|
wuchengli
2016/11/16 12:15:19
Document where we can find the definition of lens_
shenghao
2016/11/17 08:41:44
Done.
| |
| 14 struct DeviceInfo { | |
| 15 std::string device_path; | |
|
wuchengli
2016/11/16 12:15:19
Give an example of device_path.
shenghao
2016/11/17 08:41:44
Done.
| |
| 16 std::string usb_vid; // USB vender id | |
| 17 std::string usb_pid; // USB product id | |
| 18 uint32_t | |
| 19 lens_facing; // Direction the camera faces relative to device screen. | |
| 20 // Clockwise angle through which the output image needs to be rotated to be | |
| 21 // upright on the device screen in its native orientation. | |
| 22 int32_t sensor_orientation; | |
| 23 uint32_t frames_to_skip_after_streamon; | |
|
wuchengli
2016/11/16 12:15:19
Document frames_to_skip_after_streamon.
shenghao
2016/11/17 08:41:44
Done.
| |
| 24 float horizontal_view_angle_16_9; | |
| 25 float horizontal_view_angle_4_3; | |
| 26 std::vector<float> lens_info_available_focal_lengths; | |
| 27 float lens_info_minimum_focus_distance; | |
| 28 float lens_info_optimal_focus_distance; | |
| 29 float vertical_view_angle_16_9; | |
| 30 float vertical_view_angle_4_3; | |
| 31 }; | |
| 32 | |
| 33 typedef std::vector<DeviceInfo> DeviceInfos; | |
| 34 | |
| 35 // CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf | |
| 36 // and stores the content in |device_infos_|. There are several assumptions of | |
| 37 // the config file: | |
| 38 // 1. Each line should be at most 256 characters long. | |
| 39 // 2. camera id should be in ascending order (i.e., 0, 1, 2, ...). | |
| 40 // 3. usb_vid_pid should be the first subkey. | |
| 41 // 4. All configs of a module should be put together. | |
| 42 // | |
| 43 // Example of the config file: | |
| 44 // camera0.lens_facing=0 | |
| 45 // camera0.sensor_orientation=0 | |
| 46 // camera0.module0.usb_vid_pid=0123:4567 | |
| 47 // camera0.module0.horizontal_view_angle=68.4 | |
| 48 // camera0.module0.lens_info_available_focal_lengths=1.64 | |
| 49 // camera0.module0.lens_info_minimum_focus_distance=0.22 | |
| 50 // camera0.module0.lens_info_optimal_focus_distance=0.5 | |
| 51 // camera0.module0.vertical_view_angle=41.6 | |
| 52 // camera0.module1.usb_vid_pid=89ab:cdef | |
| 53 // camera0.module1.lens_info_available_focal_lengths=1.69,2 | |
| 54 // camera1.lens_facing=1 | |
| 55 // camera1.sensor_orientation=180 | |
| 56 class CameraCharacteristics { | |
| 57 public: | |
| 58 CameraCharacteristics(); | |
| 59 ~CameraCharacteristics(); | |
| 60 | |
| 61 // Parses /etc/camera/camera_characteristics.conf. | |
| 62 // Returns DeviceInfos with default characteristics if the config file doesn't | |
| 63 // exist. | |
| 64 const DeviceInfos GetCharacteristicsFromFile( | |
| 65 const std::vector<std::string>& devices); | |
| 66 | |
| 67 // Get camera facing by specifying vid and pid. |model_id| should be formatted | |
| 68 // as "vid:pid". | |
| 69 // Returns 0 as front facing and 1 as back facing. Default is 0. | |
| 70 int GetCameraFacing(const std::string& model_id); | |
| 71 | |
| 72 private: | |
| 73 DeviceInfos device_infos_; | |
| 74 | |
| 75 void AddPerCameraCharacteristic(uint32_t camera_id, | |
| 76 const char* characteristic, | |
| 77 const char* value); | |
| 78 void AddPerModuleCharacteristic(uint32_t camera_id, | |
| 79 const char* characteristic, | |
| 80 const char* value); | |
| 81 void AddFloatValue(const char* value, | |
| 82 const char* characteristic_name, | |
| 83 float* characteristic); | |
| 84 }; | |
| 85 | |
| 86 } // namespace arc | |
| 87 | |
| 88 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| OLD | NEW |