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

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

Issue 2648743002: Rotate frames according to camera orientation (Closed)
Patch Set: Address review comments Created 3 years, 11 months 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ 5 #ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CONFIG_CHROMEOS_H_
6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ 6 #define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CONFIG_CHROMEOS_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 #include <unordered_map> 11 #include <unordered_map>
12 12
13 #include <base/strings/string_piece.h> 13 #include <base/strings/string_piece.h>
14 #include "media/base/video_facing.h" 14 #include "media/base/video_facing.h"
15 #include "media/capture/capture_export.h" 15 #include "media/capture/capture_export.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 // CameraFacingChromeOS reads the file /etc/camera/camera_characteristics.conf 19 // CameraConfigChromeOS reads the file /etc/camera/camera_characteristics.conf
20 // and populates |camera_id_to_facing_|, |usb_id_to_camera_id_| and 20 // and populates |camera_id_to_facing_|, |usb_id_to_camera_id_| and
21 // |model_id_to_camera_id_|. 21 // |model_id_to_camera_id_|.
22 // 22 //
23 // Each line in the config file can be: 23 // Each line in the config file can be:
24 // 1. Empty line 24 // 1. Empty line
25 // 2. Line starts with '#': comments 25 // 2. Line starts with '#': comments
26 // 3. Line follows the format: 26 // 3. Line follows the format:
27 // camera[camera_id].[root_level_attribute]=[value] OR 27 // camera[camera_id].[root_level_attribute]=[value] OR
28 // camera[camera_id].module[module_id].[module_level_attribute]=[value] 28 // camera[camera_id].module[module_id].[module_level_attribute]=[value]
29 // 29 //
(...skipping 11 matching lines...) Expand all
41 // camera0.module0.usb_vid_pid=0123:4567 41 // camera0.module0.usb_vid_pid=0123:4567
42 // camera0.module0.horizontal_view_angle=68.4 42 // camera0.module0.horizontal_view_angle=68.4
43 // camera0.module0.lens_info_available_focal_lengths=1.64 43 // camera0.module0.lens_info_available_focal_lengths=1.64
44 // camera0.module0.lens_info_minimum_focus_distance=0.22 44 // camera0.module0.lens_info_minimum_focus_distance=0.22
45 // camera0.module0.lens_info_optimal_focus_distance=0.5 45 // camera0.module0.lens_info_optimal_focus_distance=0.5
46 // camera0.module0.vertical_view_angle=41.6 46 // camera0.module0.vertical_view_angle=41.6
47 // camera0.module1.usb_vid_pid=89ab:cdef 47 // camera0.module1.usb_vid_pid=89ab:cdef
48 // camera0.module1.lens_info_available_focal_lengths=1.69,2 48 // camera0.module1.lens_info_available_focal_lengths=1.69,2
49 // camera1.lens_facing=1 49 // camera1.lens_facing=1
50 // camera1.sensor_orientation=180 50 // camera1.sensor_orientation=180
51 class CAPTURE_EXPORT CameraFacingChromeOS { 51 class CAPTURE_EXPORT CameraConfigChromeOS {
52 public: 52 public:
53 CameraFacingChromeOS(); 53 CameraConfigChromeOS();
54 CAPTURE_EXPORT CameraFacingChromeOS(const std::string& config_file_path); 54 CAPTURE_EXPORT CameraConfigChromeOS(const std::string& config_file_path);
55 CAPTURE_EXPORT ~CameraFacingChromeOS(); 55 CAPTURE_EXPORT ~CameraConfigChromeOS();
56 56
57 // Get camera facing by specifying USB vid and pid and device path. |model_id| 57 // Get camera facing by specifying USB vid and pid and device path. |model_id|
58 // should be formatted as "vid:pid". |device_id| is something like 58 // should be formatted as "vid:pid". |device_id| is something like
59 // "/dev/video2". It first tries to match usb path, obtained from |device_id|. 59 // "/dev/video2". It first tries to match usb path, obtained from |device_id|.
60 // If fails, |model_id| is then used. 60 // If fails, |model_id| is then used.
61 CAPTURE_EXPORT VideoFacingMode 61 CAPTURE_EXPORT VideoFacingMode
62 GetCameraFacing(const std::string& device_id, 62 GetCameraFacing(const std::string& device_id,
63 const std::string& model_id) const; 63 const std::string& model_id) const;
64 // Get the orientation of the camera. The value is the angle that the camera
65 // image needs to be rotated clockwise so it shows correctly on the display in
66 // its natural orientation. It should be 0, 90, 180, or 270.
67 //
68 // For example, suppose a device has a naturally tall screen. The back-facing
69 // camera sensor is mounted in landscape. You are looking at the screen. If
70 // the top side of the camera sensor is aligned with the right edge of the
71 // screen in natural orientation, the value should be 90. If the top side of a
72 // front-facing camera sensor is aligned with the right of the screen, the
73 // value should be 270.
74 CAPTURE_EXPORT int GetOrientation(const std::string& device_id,
mcasas 2017/01/23 21:44:57 You don't need CAPTURE_EXPORT in every method, the
shenghao 2017/01/24 14:29:52 Done.
75 const std::string& model_id) const;
64 76
65 static const VideoFacingMode kLensFacingDefault = 77 static const VideoFacingMode kLensFacingDefault =
66 VideoFacingMode::MEDIA_VIDEO_FACING_NONE; 78 VideoFacingMode::MEDIA_VIDEO_FACING_NONE;
67 79
68 private: 80 private:
69 std::string GetUsbId(const std::string& device_id) const; 81 std::string GetUsbId(const std::string& device_id) const;
82 int GetCameraId(const std::string& device_id,
83 const std::string& model_id) const;
70 // Read file content and populate |camera_id_to_facing_|, 84 // Read file content and populate |camera_id_to_facing_|,
71 // |usb_id_to_camera_id_| and |model_id_to_camera_id_|. 85 // |usb_id_to_camera_id_| and |model_id_to_camera_id_|.
72 void InitializeDeviceInfo(const std::string& config_file_path); 86 void InitializeDeviceInfo(const std::string& config_file_path);
73 87
74 std::unordered_map<int, VideoFacingMode> camera_id_to_facing_; 88 std::unordered_map<int, VideoFacingMode> camera_id_to_facing_;
89 std::unordered_map<int, int> camera_id_to_orientation_;
75 std::unordered_map<std::string, int> usb_id_to_camera_id_; 90 std::unordered_map<std::string, int> usb_id_to_camera_id_;
76 std::unordered_map<std::string, int> model_id_to_camera_id_; 91 std::unordered_map<std::string, int> model_id_to_camera_id_;
77 }; 92 };
78 93
79 } // namespace media 94 } // namespace media
80 95
81 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_FACING_CHROMEOS_H_ 96 #endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CONFIG_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698