Partager via


Camera Rotation (Windows Embedded CE 6.0)

1/6/2010

If you are creating a camera application that will run on a portable device, your application should account for both the physical orientation of the device and the orientation of the shell on the device. The physical orientation of the device relates directly to the orientation of the imaging sensor relative to the physical world. The orientation of the device's shell is the orientation of your application's display environment relative to the physical device.

It is important for your application to be orientation-aware so that it can make the correct compensations both when it displays images to the user, and also when it writes the captured image data to a file. The tables and diagrams later in this topic show how your camera application should handle the various combinations of image, device, and shell orientations.

The following design principles will help you create camera applications that maximize image quality and provide an intuitive experience for the user.

  • Use as many of the pixels on your sensor as possible.
  • Align the output from the viewfinder with the subject. What the user sees in the viewfinder should align with what they see in the real world.
  • Thumbnails should align with the subject, provided device has not moved. Another way to understand this is that the thumbnail should be recorded in the orientation that the user saw the subject.

Implementation Considerations for Camera Applications

When the shell is rotated, the camera application must change the aspect ratio of the preview window by transposing the height and width of the image size reported by the camera driver. For example, if the camera reports a still image resolution of with a 4:3 aspect ration, the camera application must create a preview window that has the same 4:3 aspect ratio when the shell is rotated.

The Microsoft Image Sink Filter has built-in support for both sensor and shell orientation. If you use this filter, you do not need to make any additions to the filter graph to handle rotation. Third party image sink filters and encoder DMOs must consider the shell rotation when persisting images from the source filter to storage. In particular, the file sink must counter-rotate images. For example, if the shell is rotated +90 degrees (to the right), then the sink filter must rotate the image by -90 (to the left). This guarantees that when the file is viewed, it will exhibit the same image as was seen in the viewfinder at the time of capture.

Implementation Considerations for Drivers

Camera drivers must mark all captured images as pre-rotated and flip the image vertically. This way, if the device is rotated, the display driver will apply the correct rotation when the image is rendered. Camera driver developers must add the BI_SRCPREROTATE flag to the biCompression field of the BITMAPINFOHEADER structure for each media type.

Display drivers must respect the BI_SRCPREROTATE flag on bitmaps. They also must be able to efficiently execute scaling and cropping operations.

Landscape Sensor Orientation

A device with a landscape sensor orientation has its sensor mounted to the device in a way that produces an image in landscape orientation when the device is not physically rotated.   In all the tables below, viewfinder rotation is noted as the amount the shell is rotated relative to the viewfinder

Shell and device are aligned

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.275ff0ce-274d-4d2e-a0ff-2b7a7580b868(en-US,WinEmbedded.60).gif
Ee493185.ee509d67-91a3-4fb6-be00-90d70f82e3f5(en-US,WinEmbedded.60).gif
Ee493185.346b5a4b-402c-41e9-ad39-634abccd6e7a(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.99e09da1-a48e-40fc-bb03-c0f13b3cc646(en-US,WinEmbedded.60).gif
Ee493185.4672ed5a-6e00-4ca7-85de-62d4c0ad74f2(en-US,WinEmbedded.60).gif
Ee493185.ca9abc03-45fd-4835-8181-306dbe92dce9(en-US,WinEmbedded.60).gif

Shell is rotated -90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.04beec91-eb29-4dbe-8a7a-6394d65485fb(en-US,WinEmbedded.60).gif
Ee493185.f73748a7-f355-4d38-b27b-67a4aba8b76c(en-US,WinEmbedded.60).gif
Ee493185.0e6acd1d-f624-4844-a4cb-4b23752a21e8(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.7546ac47-9f47-4aa8-92a7-77b5eecfbe66(en-US,WinEmbedded.60).gif
Ee493185.a3d3f8e1-fb54-489b-bf5b-1bad0879937d(en-US,WinEmbedded.60).gif
Ee493185.63d6a6fc-4da8-4ea5-b1f4-4783fa29b710(en-US,WinEmbedded.60).gif

Shell is rotated +90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.fd79c231-b2df-41f5-9fb1-43a370464a48(en-US,WinEmbedded.60).gif
Ee493185.c8b76d43-149a-4e8d-9956-e5d6e57a0a40(en-US,WinEmbedded.60).gif
Ee493185.fe540a5a-610e-481e-8a11-7b3dbbb8bb24(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.7546ac47-9f47-4aa8-92a7-77b5eecfbe66(en-US,WinEmbedded.60).gif
Ee493185.a3d3f8e1-fb54-489b-bf5b-1bad0879937d(en-US,WinEmbedded.60).gif
Ee493185.63d6a6fc-4da8-4ea5-b1f4-4783fa29b710(en-US,WinEmbedded.60).gif

Portrait Sensor Orientation

A device with a portrait sensor orientation has its sensor mounted to the device in a way that produces an image in portrait orientation when the device is not physically rotated.   In all the tables below, viewfinder rotation is noted as the amount the shell is rotated relative to the viewfinder.

Shell and device are aligned

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.103f1b45-1864-4b14-93d4-c6c07bb7e5d5(en-US,WinEmbedded.60).gif
Ee493185.8e572a6e-d68f-4b51-b459-4effbb937d74(en-US,WinEmbedded.60).gif
Ee493185.f2dff35f-b441-4cf3-8186-e79d338a3fbc(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.7546ac47-9f47-4aa8-92a7-77b5eecfbe66(en-US,WinEmbedded.60).gif
Ee493185.a3d3f8e1-fb54-489b-bf5b-1bad0879937d(en-US,WinEmbedded.60).gif
Ee493185.63d6a6fc-4da8-4ea5-b1f4-4783fa29b710(en-US,WinEmbedded.60).gif

Shell is rotated -90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.9c7d7313-268d-4820-9627-5ca1bf80cd11(en-US,WinEmbedded.60).gif
Ee493185.5e1f3245-b4dd-4c4a-b8d8-44419f03bea4(en-US,WinEmbedded.60).gif
Ee493185.e4729824-18a9-4c88-b07a-4c5cbcdca4e9(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.99e09da1-a48e-40fc-bb03-c0f13b3cc646(en-US,WinEmbedded.60).gif
Ee493185.ca9abc03-45fd-4835-8181-306dbe92dce9(en-US,WinEmbedded.60).gif
Ee493185.4672ed5a-6e00-4ca7-85de-62d4c0ad74f2(en-US,WinEmbedded.60).gif

Shell is rotated +90º relative to the device

  Viewfinder = 0º Viewfinder = -90º Viewfinder = +90º

Device orientation

Ee493185.edf070e4-3037-4c59-b783-1f5db5602f60(en-US,WinEmbedded.60).gif
Ee493185.6d1ea5dd-ef74-4239-aef2-0677e3110345(en-US,WinEmbedded.60).gif
Ee493185.5477d13e-ac8e-41a4-b9b7-5338f059e3dc(en-US,WinEmbedded.60).gif

Orientation of image as written to storage

Ee493185.99e09da1-a48e-40fc-bb03-c0f13b3cc646(en-US,WinEmbedded.60).gif
Ee493185.ca9abc03-45fd-4835-8181-306dbe92dce9(en-US,WinEmbedded.60).gif
Ee493185.4672ed5a-6e00-4ca7-85de-62d4c0ad74f2(en-US,WinEmbedded.60).gif

See Also

Concepts

Video Capture