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

Unified Diff: media/capture/video/linux/video_capture_device_linux.cc

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 side-by-side diff with in-line comments
Download patch
Index: media/capture/video/linux/video_capture_device_linux.cc
diff --git a/media/capture/video/linux/video_capture_device_linux.cc b/media/capture/video/linux/video_capture_device_linux.cc
index a1b2855055e853b5e1d9210f5da139f8740ef7ec..13e01af5c2ccfe9440f741e2226af9233d2b2a9c 100644
--- a/media/capture/video/linux/video_capture_device_linux.cc
+++ b/media/capture/video/linux/video_capture_device_linux.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
#include "build/build_config.h"
+#include "media/capture/video/linux/camera_characteristics.h"
#include "media/capture/video/linux/v4l2_capture_delegate.h"
#if defined(OS_OPENBSD)
@@ -37,8 +38,12 @@ std::list<uint32_t> VideoCaptureDeviceLinux::GetListOfUsableFourCCs(
VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(
const VideoCaptureDeviceDescriptor& device_descriptor)
- : v4l2_thread_("V4L2CaptureThread"),
- device_descriptor_(device_descriptor) {}
+ : v4l2_thread_("V4L2CaptureThread"), device_descriptor_(device_descriptor) {
+ CameraCharacteristics characteristics;
+ is_back_camera_ =
+ characteristics.GetCameraFacing(device_descriptor.model_id) ==
+ DeviceInfo::LENS_FACING_BACK;
+}
VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() {
// Check if the thread is running.
@@ -113,6 +118,12 @@ void VideoCaptureDeviceLinux::SetPhotoOptions(
void VideoCaptureDeviceLinux::SetRotation(int rotation) {
if (v4l2_thread_.IsRunning()) {
+ if (is_back_camera_) {
wuchengli 2016/11/18 05:08:50 Add a comment to explain we assume an external cam
shenghao 2016/11/21 06:24:53 Done.
+ // For back camera, we need to rotate (360 - screen_rotation).
+ // Ex: when screen rotation is 90, we have to rotate the frame by 270
+ // clockwise.
wuchengli 2016/11/18 05:08:50 Use ascii art to explain the image of front facing
shenghao 2016/11/21 06:24:53 Done.
+ rotation = (360 - rotation) % 360;
+ }
v4l2_thread_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation));

Powered by Google App Engine
This is Rietveld 408576698