Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: media/capture/video/linux/camera_characteristics.h

Issue 2508803002: Rotate frames correctly for back camera (Closed)
Patch Set: add some comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
mcasas 2016/11/17 17:53:07 No (c), here and in the .cc file.
shenghao 2016/11/21 06:24:53 done
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_FRONT = 0;
kcwu 2016/11/17 15:02:18 enum ?
shenghao 2016/11/21 06:24:53 I think it's better to use int here to match the v
17 static const int LENS_FACING_BACK = 1;
18
19 std::string device_path; // Ex. "/dev/video2"
20 std::string usb_vid; // USB vender id
21 std::string usb_pid; // USB product id
22 uint32_t
23 lens_facing; // Direction the camera faces relative to device screen.
kcwu 2016/11/17 15:02:18 You put some comment at the same line and some not
shenghao 2016/11/21 06:24:53 Done.
24 // Clockwise angle through which the output image needs to be rotated to be
25 // upright on the device screen in its native orientation.
26 int32_t sensor_orientation;
kcwu 2016/11/17 15:02:18 what is expected range? could it be negative?
shenghao 2016/11/21 06:24:53 Done.
27 // There might be some corrupted frames at the beginning after stream on. We
28 // need to skip them.
29 uint32_t frames_to_skip_after_streamon;
30 float horizontal_view_angle_16_9;
31 float horizontal_view_angle_4_3;
32 std::vector<float> lens_info_available_focal_lengths;
33 float lens_info_minimum_focus_distance;
34 float lens_info_optimal_focus_distance;
35 float vertical_view_angle_16_9;
36 float vertical_view_angle_4_3;
mcasas 2016/11/17 17:53:07 This structure has a number of fields, but IIUC we
shenghao 2016/11/21 06:24:53 Done.
37 };
38
39 typedef std::vector<DeviceInfo> DeviceInfos;
40
41 // CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf
kcwu 2016/11/17 15:02:18 oh, I found the comments here. but you only descri
shenghao 2016/11/21 06:24:53 Isn't the example below enough to help readers und
kcwu 2016/11/21 07:59:24 For example, 1. do you allow space before and afte
42 // and stores the content in |device_infos_|. There are several assumptions of
43 // the config file:
44 // 1. Each line should be at most 256 characters long.
45 // 2. camera id should be in ascending order (i.e., 0, 1, 2, ...).
46 // 3. usb_vid_pid should be the first subkey.
47 // 4. All configs of a module should be put together.
48 //
49 // Example of the config file:
50 // camera0.lens_facing=0
51 // camera0.sensor_orientation=0
52 // camera0.module0.usb_vid_pid=0123:4567
53 // camera0.module0.horizontal_view_angle=68.4
54 // camera0.module0.lens_info_available_focal_lengths=1.64
55 // camera0.module0.lens_info_minimum_focus_distance=0.22
56 // camera0.module0.lens_info_optimal_focus_distance=0.5
57 // camera0.module0.vertical_view_angle=41.6
58 // camera0.module1.usb_vid_pid=89ab:cdef
59 // camera0.module1.lens_info_available_focal_lengths=1.69,2
60 // camera1.lens_facing=1
61 // camera1.sensor_orientation=180
62 class CameraCharacteristics {
63 public:
64 CameraCharacteristics();
65 ~CameraCharacteristics();
66
67 // Parses /etc/camera/camera_characteristics.conf.
68 // Returns DeviceInfos with default characteristics if the config file doesn't
69 // exist.
70 const DeviceInfos GetCharacteristicsFromFile(
71 const std::vector<std::string>& devices);
72
73 // Get camera facing by specifying vid and pid. |model_id| should be formatted
74 // as "vid:pid".
75 // Returns DeviceInfo::LENS_FACING_FRONT or DeviceInfo::LENS_FACING_BACK.
76 // Default is DeviceInfo::LENS_FACING_FRONT.
77 int GetCameraFacing(const std::string& model_id);
78
79 private:
80 DeviceInfos device_infos_;
81
82 void AddPerCameraCharacteristic(uint32_t camera_id,
83 const char* characteristic,
84 const char* value);
85 void AddPerModuleCharacteristic(uint32_t camera_id,
86 const char* characteristic,
87 const char* value);
88 void AddFloatValue(const char* value,
89 const char* characteristic_name,
90 float* characteristic);
91 };
92
93 } // namespace arc
94
95 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698