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 | |
| 14 // DeviceInfo can be found in /etc/camera/camera_characteristics.conf on device. | |
| 15 struct DeviceInfo { | |
| 16 static const int LENS_FACING_UNKNOWN = -1; | |
|
wuchengli
2016/11/17 09:26:04
There's no LENS_FACING_UNKNOWN. This has to be con
shenghao
2016/11/17 10:15:55
Done.
| |
| 17 static const int LENS_FACING_FRONT = 0; | |
| 18 static const int LENS_FACING_BACK = 1; | |
| 19 | |
| 20 std::string device_path; // Ex. "/dev/video2" | |
| 21 std::string usb_vid; // USB vender id | |
| 22 std::string usb_pid; // USB product id | |
| 23 uint32_t | |
| 24 lens_facing; // Direction the camera faces relative to device screen. | |
| 25 // Clockwise angle through which the output image needs to be rotated to be | |
| 26 // upright on the device screen in its native orientation. | |
| 27 int32_t sensor_orientation; | |
| 28 // There might be some corrupted frames at the beginning after stream on. We | |
| 29 // need to skip them. | |
| 30 uint32_t frames_to_skip_after_streamon; | |
| 31 float horizontal_view_angle_16_9; | |
| 32 float horizontal_view_angle_4_3; | |
| 33 std::vector<float> lens_info_available_focal_lengths; | |
| 34 float lens_info_minimum_focus_distance; | |
| 35 float lens_info_optimal_focus_distance; | |
| 36 float vertical_view_angle_16_9; | |
| 37 float vertical_view_angle_4_3; | |
| 38 }; | |
| 39 | |
| 40 typedef std::vector<DeviceInfo> DeviceInfos; | |
| 41 | |
| 42 // CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf | |
| 43 // and stores the content in |device_infos_|. There are several assumptions of | |
| 44 // the config file: | |
| 45 // 1. Each line should be at most 256 characters long. | |
| 46 // 2. camera id should be in ascending order (i.e., 0, 1, 2, ...). | |
| 47 // 3. usb_vid_pid should be the first subkey. | |
| 48 // 4. All configs of a module should be put together. | |
| 49 // | |
| 50 // Example of the config file: | |
| 51 // camera0.lens_facing=0 | |
| 52 // camera0.sensor_orientation=0 | |
| 53 // camera0.module0.usb_vid_pid=0123:4567 | |
| 54 // camera0.module0.horizontal_view_angle=68.4 | |
| 55 // camera0.module0.lens_info_available_focal_lengths=1.64 | |
| 56 // camera0.module0.lens_info_minimum_focus_distance=0.22 | |
| 57 // camera0.module0.lens_info_optimal_focus_distance=0.5 | |
| 58 // camera0.module0.vertical_view_angle=41.6 | |
| 59 // camera0.module1.usb_vid_pid=89ab:cdef | |
| 60 // camera0.module1.lens_info_available_focal_lengths=1.69,2 | |
| 61 // camera1.lens_facing=1 | |
| 62 // camera1.sensor_orientation=180 | |
| 63 class CameraCharacteristics { | |
| 64 public: | |
| 65 CameraCharacteristics(); | |
| 66 ~CameraCharacteristics(); | |
| 67 | |
| 68 // Parses /etc/camera/camera_characteristics.conf. | |
| 69 // Returns DeviceInfos with default characteristics if the config file doesn't | |
| 70 // exist. | |
| 71 const DeviceInfos GetCharacteristicsFromFile( | |
| 72 const std::vector<std::string>& devices); | |
| 73 | |
| 74 // Get camera facing by specifying vid and pid. |model_id| should be formatted | |
| 75 // as "vid:pid". | |
| 76 // Returns DeviceInfo::LENS_FACING_FRONT, DeviceInfo::LENS_FACING_BACK or | |
| 77 // DeviceInfo::UNKNOWN. | |
| 78 int GetCameraFacing(const std::string& model_id); | |
| 79 | |
| 80 private: | |
| 81 DeviceInfos device_infos_; | |
| 82 | |
| 83 void AddPerCameraCharacteristic(uint32_t camera_id, | |
| 84 const char* characteristic, | |
| 85 const char* value); | |
| 86 void AddPerModuleCharacteristic(uint32_t camera_id, | |
| 87 const char* characteristic, | |
| 88 const char* value); | |
| 89 void AddFloatValue(const char* value, | |
| 90 const char* characteristic_name, | |
| 91 float* characteristic); | |
| 92 }; | |
| 93 | |
| 94 } // namespace arc | |
| 95 | |
| 96 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_ | |
| OLD | NEW |