Friday 15 August 2014

c# - rotation of videobrush for photocapturedevice -


I have some problems with the orientation of my videobos displaying photocapturedevice on my phone. It is actually a built-in camera app , Which means that

  • all aspect ratio
  • should work for both cameras (back and front)
  • And all page orientation

    At least one of these is always wrong I get this job Shaw, but still this is the best way, it is rotating the different page and not working for me on the front camera is wrongly rotating (counterclockwise when I rotate my phone clockwise, I am inverted).

    Is there any code snippet with a full working camera camera videobrish?

    To properly display the viewfinder, you need two notifications:

    • Orientation : Preview image orientation relative to your page orientation
    • Scale : The factor between preview image size and xaml control. canvas x;

      In the first you need a canvas with background videobrush

        & lt: name = "viewfinderCanvas" width = "480" height = "800" & gt; & Lt; Canvas.Background & gt; & Lt; VideoBrush x: Name = "Viewfinder Brush" Stretch = "None" /> & Lt; /Canvas.Background> & Lt; / Canvas & gt;   

      You have to scale Stretch = "None" or XML using Scenebrush. Now you need a viewfinder brush conversion to display it correctly. By default, the canvas center corresponds to the preview image center, so we need to use the canvas center as an angle, scale factor calculation and change center

      The angle you need to calculate for:.

      • Relative sensor orientation of device portrait orientation is given by this value property.
      • Your page orientation related to device portrait orientation.

        Code:

          Double Computeangle (Page Orientation Orientation) (If ((Orientation and Page Orientation Portrait) == Page Orientation. Portrait) {Return MCCapteware Device.SensorRotationInDegrees ;} Else if ((orientation & amp; PageOrientation.LandscapeLeft) == PageOrientation.LandscapeLeft) {return m_captureDevice.SensorRotationInDegrees - 90;} // other Prishtorenteshn. Landscape Wright {return Mkapcrr device. sensor rotation Indigrijh + 90;}} < / Code>  

        scale only canvas dimensions and preview But the picture factor between dimensions:

          // Orient preview picture size calculation Var tmp = new composite conversion (from anel) {rotation = Kanputangl (current page Orenteshn)}; var previewSize = Tmp.TransformBounds (New Rect (New Point), New Size (m_captureDevice.PreviewResolution.Width, m_captureDevice.PreviewResolution.Height)) Size.Speed ​​S1 = Viewfinder Conv. With / with Double SelectionSize: Double S2 = Viewfinder Canvas. Light / (double) previewSyzom.High;   
        • if come Use the maximum factor, a Fit = & gt; Scale = math Max (S1, S2)
        • If you use the lowest factor, you can convert to a Fit = & gt; Scale = monastery (s1, s2)

          The front and back camera has the opposite direction of your eye. So to correctly display the front camera you need to place a mirror in one dimension. The WP8 sensor is usually 90 degrees on the orientation, so that the Y dimension is the opposite.

            if (sensor location == camera sensor location. Back) {viewfinderBrush.Transform = new compositeTransform () {rotation = ComputeAngle (currentPageOrientation), Center X = viewfinder Kanwas. With / 2, center e = viewfinder cannes High / 2, Scale X = Scale, Scale Y = Scale}; } Else {viewfinderBrush.Transform = new CompositeTransform () {rotation = ComputeAngle (currentPageOrientation), CenterX = viewfinderCanvas.Width / 2, CenterY = viewfinderCanvas.Height / 2, ScaleX = scale, scaleY = -1 * scale}; // Y mirror}   

          You can find it on github previous version of the sample:

No comments:

Post a Comment