Ergebnis 1 bis 1 von 1
-
- 15.02.2012, 10:15
- #1
Hallo
Wer Interesse hat, kann sich gerne meine kleine Demo App ansehen. Einfach aus Interesse durchstöbern wie sowas grundsätzlich beim WP7 funktioniert.
Die App liest die Videokamera Bilder frameweise ein und kann sie RGB-Manipuliert anzeigen.
Code:<UserControl x:Class="Nachtscanner.CamControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" d:DesignHeight="480" d:DesignWidth="480"> <Grid x:Name="LayoutRoot" > <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <!--Camera viewfinder >--> <Rectangle> <Rectangle.Fill> <VideoBrush x:Name="viewfinderBrush" Stretch="Uniform"/> </Rectangle.Fill> </Rectangle> <!--Overlay for the viewfinder region to display grayscale WriteableBitmap objects--> <Image x:Name="MainImage" Stretch="UniformToFill"/> <TextBlock x:Name="txtDebug" HorizontalAlignment="Left" VerticalAlignment="Bottom" TextWrapping="Wrap" Grid.Row="1" /> </Grid> </UserControl>
Code:Private Sub StartCapture() ' Start ARGB to grayscale pump. 'MainImage.Visibility = Visibility.Visible If _FrameCheckActive = True Then Exit Sub Me._FrameCheckActive = True ' Start pump. thFrameWorker = New System.Threading.Thread(AddressOf PumpARGBFrames) thFrameWorker.IsBackground = True thFrameWorker.Name = "thFrameWorker" thFrameWorker.Start() 'Me.Dispatcher.BeginInvoke(Sub() txtDebug.Text = "ARGB to Grayscale") End Sub 'ARGB frame pump Private Sub PumpARGBFrames() 'Speicherbereich reservieren Dim ARGBPx(CInt(cam.PreviewResolution.Width) * CInt(cam.PreviewResolution.Height) - 1) As Integer Try Dim phCam As PhotoCamera = CType(cam, PhotoCamera) 'Frames einlesen bis die Camera beendet wird Do While Me._FrameCheckActive 'Warten bis die Daten bereit sind PauseFramesEvent.WaitOne() 'Frame als Bytearray einlesen phCam.GetPreviewBufferArgb32(ARGBPx) 'Bildauflösung auslesen Dim NewVideoSize As Size = phCam.PreviewResolution 'Daten verarbeiten und Speicher klonen Deployment.Current.Dispatcher.BeginInvoke(Sub() If Me._Run = True Then NachScanner.SetImageData(ARGBPx, NewVideoSize) End If End Sub) PauseFramesEvent.Reset() 'Bildframe verändern und ausgeben Deployment.Current.Dispatcher.BeginInvoke(Sub() If Me._bm Is Nothing Then Me._bm = New Imaging.WriteableBitmap(CInt(NewVideoSize.Width), CInt(NewVideoSize.Height)) Me.MainImage.Source = Me._bm End If ARGBPx.CopyTo(_bm.Pixels, 0) _bm.Invalidate() PauseFramesEvent.Set() End Sub) Loop Catch e As Exception ' Display error message. Me.Dispatcher.BeginInvoke(Sub() txtDebug.Text = e.Message End Sub) End Try Me._FrameCheckActive = False End Sub
Download Sourcecode WP7 VB.Net
http://www.goldengel.ch/temp/Nachtscanner.zip
Auf Wunsch hab ich noch 101 andere Apps mit Source hier die dann auch komplexer sind.
lg
Timo
Ähnliche Themen
-
ein erstes MANGO Build with market place [07/07] inkl. Download ;-)
Von m.klauke im Forum HTC HD2 Windows Phone 7 ROM EntwicklungAntworten: 10Letzter Beitrag: 10.07.2011, 07:44 -
WP7 inkl. Android jetzt möglich!
Von Dilate im Forum HTC HD2 AndroidAntworten: 6Letzter Beitrag: 28.01.2011, 01:12 -
2D Ping Pong - Sourcecode steht zum download bereit
Von danielm im Forum Windows Phone 7 EntwicklungAntworten: 4Letzter Beitrag: 21.05.2010, 21:05 -
Jabberoid Sourcecode veröffentlicht
Von Fredjam im Forum T-Mobile G1Antworten: 9Letzter Beitrag: 29.01.2009, 08:19
Pixel 10 Serie mit Problemen:...