Display camera output in Windows Phone 7

I am writing an augmented reality application for Windows Phone 7 as a school project. I want to get the camera output, and then add a data layer on top of it. Is there any way for the camera output to be displayed on the panel?

+3
source share
5 answers

FYI: on the Windows Phone SDK 7.1 (aka "Mango") you can now write applications that use the device’s camera as you describe. See the App Hub for a link to the latest 7.1 development tools. The documentation describes how to do this at the following link:

How to create a base camera application for Windows Phone

, , (a.k.a. "" ). , , :

    <!--Camera viewfinder >-->
    <Rectangle Width="640" Height="480" 
               HorizontalAlignment="Left" 
               x:Name="viewfinderContainer">

        <Rectangle.Fill>
            <VideoBrush x:Name="viewfinderBrush" />
        </Rectangle.Fill>
    </Rectangle>

, Microsoft.XNA.Framework :

// Directives
using Microsoft.Devices;
using System.IO;
using System.IO.IsolatedStorage;
using System.Windows.Media.Imaging;
using Microsoft.Xna.Framework.Media;

: , . Visual Studio (Pro, ) , : | .

, , OnNavigatedTo...

    //Code for initialization and setting the source for the viewfinder
    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {

        // Initialize camera
        cam = new Microsoft.Devices.PhotoCamera();

        //Set the VideoBrush source to the camera.
        viewfinderBrush.SetSource(cam);
    }

... OnNavigatingFrom.

    protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
    {
        // Dispose camera to minimize power consumption and to expedite shutdown.
        cam.Dispose();

        // Good place to unhook camera event handlers too.
    }

7.1 . , Silverlight, Mango.

API Windows Phone

, PhotoCamera Windows Phone OS 7.1.

+7

Microsoft [PDF], .

127:

, Microsoft.Phone.Tasks .

+4

(1/19/2010) , CameraCaptureTask. , PhotoCamera Microsoft.Phone.Media.Extended, Dan Ardelean Kevin Marshall. - . , , , SDK.

+1

: no.

CameraCaptureTask, API Windows Phone 7 (), , , .

Microsoft , .

CameraCaptureTask:

public partial class MainPage : PhoneApplicationPage
{
   // Declare the CameraCaptureTask object with page scope.
   CameraCaptureTask cameraCaptureTask;

   // Constructor
   public MainPage()
   {
      InitializeComponent();

      // Initialize the CameraCaptureTask and assign the Completed handler in the page constructor.
      cameraCaptureTask = new CameraCaptureTask();
      cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
   }

   // In this example, the CameraCaptureTask is shown in response to a button click.                
   private void button1_Click(object sender, RoutedEventArgs e)
   {
      cameraCaptureTask.Show();
   }
   // The Completed event handler. In this example, a new BitmapImage is created and
   // the source is set to the result stream from the CameraCaptureTask
   void cameraCaptureTask_Completed(object sender, PhotoResult e)
   {
      if (e.TaskResult == TaskResult.OK)
      {
         BitmapImage bmp = new BitmapImage();
         bmp.SetSource(e.ChosenPhoto);
         myImage.Source = bmp;
      }
   }
}
0

, CameraCaptureTask.

, AR .

0

Source: https://habr.com/ru/post/1771591/


All Articles