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

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

Issue 558663006: Linux video capture: rotate image if V4L2_IN_ST_VFLIP is set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check number of input types Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/linux/video_capture_device_linux.cc
diff --git a/media/video/capture/linux/video_capture_device_linux.cc b/media/video/capture/linux/video_capture_device_linux.cc
index 0192daba3e7e2807a827edd1e6f35a9e8512bbcf..e7f2e23e1edd1d04ba4669428bb8e70091090ada 100644
--- a/media/video/capture/linux/video_capture_device_linux.cc
+++ b/media/video/capture/linux/video_capture_device_linux.cc
@@ -250,6 +250,32 @@ void VideoCaptureDeviceLinux::OnAllocateAndStart(int width,
return;
}
+ // Check sensor orientation.
+ struct v4l2_input first_input;
+ first_input.index = 0; // First input type.
+ if (HANDLE_EINTR(ioctl(device_fd_.get(),
+ VIDIOC_ENUMINPUT, &first_input)) == 0) {
+ struct v4l2_input second_input;
+ second_input.index = 1;
+ if (HANDLE_EINTR(ioctl(device_fd_.get(), VIDIOC_ENUMINPUT,
+ &second_input)) < 0) {
+ // Only one input type
+ if (first_input.status & V4L2_IN_ST_VFLIP) {
+ DVLOG(1) << "Sensor is flipped vertically, rotating 180 deg.";
+ if (!(first_input.status & V4L2_IN_ST_HFLIP)) {
+ DVLOG(1) << "Sensor is only flipped vertically, "
+ "image will be mirrored";
+ }
+ SetRotation(180);
+ }
+ } else {
+ // More than one input type, don't try to fix sensor orientation.
+ DVLOG(1) << "Video capture device has more than one input type";
+ }
+ } else {
+ DVLOG(1) << "Failed to enumerate video input";
+ }
+
// Set format and frame size now.
v4l2_format video_fmt;
memset(&video_fmt, 0, sizeof(v4l2_format));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698