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

Unified Diff: media/capture/video/linux/camera_characteristics.h

Issue 2508803002: Rotate frames correctly for back camera (Closed)
Patch Set: remove unused header 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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/linux/camera_characteristics.h
diff --git a/media/capture/video/linux/camera_characteristics.h b/media/capture/video/linux/camera_characteristics.h
new file mode 100644
index 0000000000000000000000000000000000000000..18062b02bbe290cafcb194fb34fd6b4e84dd0aa9
--- /dev/null
+++ b/media/capture/video/linux/camera_characteristics.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_
+#define MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_
+
+#include <stddef.h>
+#include <string>
+#include <vector>
+
+namespace media {
+
wuchengli 2016/11/16 12:15:19 Document where we can find the definition of lens_
shenghao 2016/11/17 08:41:44 Done.
+struct DeviceInfo {
+ 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.
+ std::string usb_vid; // USB vender id
+ std::string usb_pid; // USB product id
+ uint32_t
+ lens_facing; // Direction the camera faces relative to device screen.
+ // Clockwise angle through which the output image needs to be rotated to be
+ // upright on the device screen in its native orientation.
+ int32_t sensor_orientation;
+ 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.
+ float horizontal_view_angle_16_9;
+ float horizontal_view_angle_4_3;
+ std::vector<float> lens_info_available_focal_lengths;
+ float lens_info_minimum_focus_distance;
+ float lens_info_optimal_focus_distance;
+ float vertical_view_angle_16_9;
+ float vertical_view_angle_4_3;
+};
+
+typedef std::vector<DeviceInfo> DeviceInfos;
+
+// CameraCharacteristics reads the file /etc/camera/camera_characteristics.conf
+// and stores the content in |device_infos_|. There are several assumptions of
+// the config file:
+// 1. Each line should be at most 256 characters long.
+// 2. camera id should be in ascending order (i.e., 0, 1, 2, ...).
+// 3. usb_vid_pid should be the first subkey.
+// 4. All configs of a module should be put together.
+//
+// Example of the config file:
+// camera0.lens_facing=0
+// camera0.sensor_orientation=0
+// camera0.module0.usb_vid_pid=0123:4567
+// camera0.module0.horizontal_view_angle=68.4
+// camera0.module0.lens_info_available_focal_lengths=1.64
+// camera0.module0.lens_info_minimum_focus_distance=0.22
+// camera0.module0.lens_info_optimal_focus_distance=0.5
+// camera0.module0.vertical_view_angle=41.6
+// camera0.module1.usb_vid_pid=89ab:cdef
+// camera0.module1.lens_info_available_focal_lengths=1.69,2
+// camera1.lens_facing=1
+// camera1.sensor_orientation=180
+class CameraCharacteristics {
+ public:
+ CameraCharacteristics();
+ ~CameraCharacteristics();
+
+ // Parses /etc/camera/camera_characteristics.conf.
+ // Returns DeviceInfos with default characteristics if the config file doesn't
+ // exist.
+ const DeviceInfos GetCharacteristicsFromFile(
+ const std::vector<std::string>& devices);
+
+ // Get camera facing by specifying vid and pid. |model_id| should be formatted
+ // as "vid:pid".
+ // Returns 0 as front facing and 1 as back facing. Default is 0.
+ int GetCameraFacing(const std::string& model_id);
+
+ private:
+ DeviceInfos device_infos_;
+
+ void AddPerCameraCharacteristic(uint32_t camera_id,
+ const char* characteristic,
+ const char* value);
+ void AddPerModuleCharacteristic(uint32_t camera_id,
+ const char* characteristic,
+ const char* value);
+ void AddFloatValue(const char* value,
+ const char* characteristic_name,
+ float* characteristic);
+};
+
+} // namespace arc
+
+#endif // MEDIA_CAPTURE_VIDEO_LINUX_CAMERA_CHARACTERISTICS_H_

Powered by Google App Engine
This is Rietveld 408576698