IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

Mémoire insuffisante pour affichage caméra


Sujet :

Windows Presentation Foundation

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut Mémoire insuffisante pour affichage caméra
    Bonjour,

    J'essaye d'afficher une caméra de résolution 2592*1944 sur mon écran. Or au bout de quelques dizaines de secondes j'ai un message indiquant mémoire insuffisante qui s'affiche.



    Mon but est d'afficher l'image de la caméra en live et de faire un snapshot afin de travailler sur l'image obtenue. Quand je mets en route ma webcam au bout de 50 secondes environs j'ai le message suivant "An error ocurred while capturing the video image. The video capture will now be terminated. une erreur générique s'est produite dans GDI+"

    si je fais le snapshot sur l'image alors arrétée et que je relance, j'obtiens l'exception suivante :

    System.OutOfMemoryException: Mémoire insuffisante pour continuer l'exécution du programme.
    à System.Windows.Media.Imaging.BitmapEncoder.SaveFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions, BitmapFrame frame)
    à System.Windows.Media.Imaging.BitmapEncoder.Save(Stream stream)
    à Placement.Window1.bntCapture_Click(Object sender, RoutedEventArgs e) dans C:\Users\Anthony kamax\Documents\Visual Studio 2013\Projects\Placement3\Placement\Window1.xaml.vb:ligne 61
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    à System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
    à System.Windows.Controls.Primitives.ButtonBase.OnClick()
    à System.Windows.Controls.Button.OnClick()
    à System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
    à System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
    à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
    à System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
    à System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
    à System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
    à System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
    à System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
    à System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    à System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
    à System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
    à System.Windows.Input.InputManager.ProcessStagingArea()
    à System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
    à System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
    à System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
    à System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
    à System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
    à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    à System.Windows.Threading.Dispatcher.Run()
    à System.Windows.Application.RunDispatcher(Object ignore)
    à System.Windows.Application.RunInternal(Window window)
    à System.Windows.Application.Run(Window window)
    à System.Windows.Application.Run()
    à Placement.Application.Main()
    code vb.net correspondant (la ligne 61 correspond à encoder.save(ms)) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    Imports System
    Imports System.IO
    Imports System.Linq
    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel
    Imports System.Text
     
    Imports System.Windows.Threading
    Imports System.Windows.Media.Animation
    Imports System.Threading
    Imports System.Windows.Resources
    Imports System.Reflection
    Imports WebCam_Capture
     
     
    Imports System.Windows
    Imports System.Windows.Controls
     
    Imports System.Windows.Data
    Imports System.Windows.Documents
    Imports System.Windows.Input
    Imports System.Windows.Media
    Imports System.Windows.Media.Imaging
    Imports System.Windows.Shapes
    Imports System.Drawing
    Imports System.Drawing.Imaging
    Imports System.Net
    Imports System.Threading.Tasks
     
     
    Class Window1
     
        Private bi As BitmapImage
        Private webcam As WebCam
        Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam = New WebCam()
            webcam.InitializeWebCam(imgVideo)
        End Sub
     
        Private Sub bntStart_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Start()
     
        End Sub
     
        Private Sub bntStop_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Stop()
        End Sub
        Private Sub bntContinue_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Continue()
        End Sub
     
        Private Sub bntCapture_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            imgCapture.Source = imgVideo.Source
            Dim frame As BitmapFrame
            ' = DirectCast(Me.imgCapture.Source, BitmapFrame)
            frame = BitmapFrame.Create(imgCapture.Source)
     
            Dim ms As New MemoryStream()
            Dim encoder As New BmpBitmapEncoder()
            encoder.Frames.Add(BitmapFrame.Create(frame))
            encoder.Save(ms)
     
     
     
            'AFFICHE DU MemoryStream
            bi = New BitmapImage()
            'bi.BeginInit()
            'ms.Position = 0
            ' TRES TRES IMPORTANT CECI ...!!!
            'bi.CacheOption = BitmapCacheOption.OnLoad
            'Mise en cached memoire
            'bi.CreateOptions = BitmapCreateOptions.PreservePixelFormat
            'bi.StreamSource = ms
            'bi.EndInit()
            '
     
     
            '  WHATEVER YOU WANT : storage dans un buffer pixels
            Dim buffer As Byte() = New Byte(ms.Length - 1) {}
            ms.Position = 0
            ms.Read(buffer, 0, CInt(ms.Length) - 1)
     
            'test  buffer modifié mis dans image
            Dim buffer2 As Byte() = New Byte(ms.Length - 1) {}
            buffer2 = buffer
     
            Dim a As Long = 76854
            Do While a < 254000
                buffer2(a) = 255
                a = a + 1
     
     
            Loop
            MsgBox(buffer.Length)
            ms.Position = 0
            ms.Write(buffer2, 0, CInt(ms.Length) - 1)
            bi.BeginInit()
            ms.Position = 0
            ' TRES TRES IMPORTANT CECI ...!!!
            bi.CacheOption = BitmapCacheOption.OnLoad
            'Mise en cached memoire
            bi.CreateOptions = BitmapCreateOptions.PreservePixelFormat
            bi.StreamSource = ms
            bi.EndInit()
            ' Dim destRect1 As Rect(200, 10, 20, 16)
     
     
     
            ' Me.imgFromByte.Source = bi.SourceRect(0, 0, 100, 100)
     
     
            'Libere Ressources
            ms.Close()
            encoder = Nothing
            webcam.Stop()
        End Sub
     
        Private Sub bntSaveImage_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            Helper.SaveImageCapture(DirectCast(imgCapture.Source, BitmapSource))
        End Sub
     
        ' Private Sub bntResolution_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        '     webcam.ResolutionSetting()
        ' End Sub
     
        ' Private Sub bntSetting_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        '  webcam.AdvanceSetting()
        '  End Sub
     
    End Class
    le code correspondant à webcam.vb :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    Imports System
    Imports System.IO
    Imports System.Linq
    Imports System.Text
    Imports WebCam_Capture
    Imports System.Windows.Controls
    Imports System.Collections.Generic
    Imports System.Windows.Media.Imaging
     
    'Design by Pongsakorn Poosankam
    Class WebCam
        Private webcam As WebCamCapture
        Private _FrameImage As System.Windows.Controls.Image
        Private FrameNumber As Integer = 2
        Public Sub InitializeWebCam(ByRef ImageControl As System.Windows.Controls.Image)
            webcam = New WebCamCapture()
            webcam.FrameNumber = CULng((0))
            webcam.TimeToCapture_milliseconds = FrameNumber
            AddHandler webcam.ImageCaptured, AddressOf webcam_ImageCaptured
            _FrameImage = ImageControl
        End Sub
     
        Private Sub webcam_ImageCaptured(ByVal source As Object, ByVal e As WebcamEventArgs)
            _FrameImage.Source = Helper.LoadBitmap(DirectCast(e.WebCamImage, System.Drawing.Bitmap))
            ' webcam.[Stop]()
        End Sub
     
        Public Sub Start()
            webcam.TimeToCapture_milliseconds = FrameNumber
            webcam.CaptureHeight = 1944
            webcam.CaptureWidth = 2592
            webcam.Start(0)
     
     
        End Sub
     
        Public Sub [Stop]()
            webcam.[Stop]()
        End Sub
     
        Public Sub [Continue]()
            ' change the capture time frame
            webcam.TimeToCapture_milliseconds = FrameNumber
     
            ' resume the video capture from the stop
            webcam.Start(Me.webcam.FrameNumber)
        End Sub
     
        'Public Sub ResolutionSetting()
        '  webcam.Config()
        'End Sub
     
        'Public Sub AdvanceSetting()
        '   webcam.Config2()
        ' End Sub
     
    End Class
    et celui correspondant à helper.vb :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    Imports System
    Imports System.IO
    Imports System.Linq
    Imports System.Text
    Imports System.Collections.Generic
    Imports System.Windows.Media.Imaging
     
    'Design by Pongsakorn Poosankam
    Class Helper
        'Block Memory Leak
        <System.Runtime.InteropServices.DllImport("gdi32.dll")> _
        Public Shared Function DeleteObject(ByVal handle As IntPtr) As Boolean
        End Function
        Public Shared bs As BitmapSource
        Public Shared ip As IntPtr
        Public Shared Function LoadBitmap(ByVal source As System.Drawing.Bitmap) As BitmapSource
     
            ip = source.GetHbitmap()
     
     
            bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, System.Windows.Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions())
     
            DeleteObject(ip)
     
            Return bs
     
        End Function
        Public Shared Sub SaveImageCapture(ByVal bitmap As BitmapSource)
            Dim encoder As New JpegBitmapEncoder()
            encoder.Frames.Add(BitmapFrame.Create(bitmap))
            encoder.QualityLevel = 100
     
     
            ' Configure save file dialog box
            Dim dlg As New Microsoft.Win32.SaveFileDialog()
            dlg.FileName = "Image"
            ' Default file name
            dlg.DefaultExt = ".Jpg"
            ' Default file extension
            dlg.Filter = "Image (.jpg)|*.jpg"
            ' Filter files by extension
            ' Show save file dialog box
            Dim result As Nullable(Of Boolean) = dlg.ShowDialog()
     
            ' Process save file dialog box results
            If result = True Then
                ' Save Image
                Dim filename As String = dlg.FileName
                Dim fstream As New FileStream(filename, FileMode.Create)
                encoder.Save(fstream)
                fstream.Close()
            End If
     
        End Sub
    End Class

    Je suppose que le souci est lié à la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, System.Windows.Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions())
    .

    Merci d'avance pour votre aide.
    ce qui ne te tue pas te rend plus fort

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Bonjour,

    il semblerait que la ligne posant problème soit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ip = source.GetHbitmap()
    ce qui ne te tue pas te rend plus fort

  3. #3
    Membre chevronné
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2007
    Messages
    677
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Décembre 2007
    Messages : 677
    Points : 2 137
    Points
    2 137
    Par défaut
    Bonjour,
    Je me suis arrêté de lire à la ligne "une erreur générique s’est produite dans GDI+". D’expérience, quand on développe une application WPF, la cohabitation avec ce dinosaure que représente GDI n’est pas des plus viables.

    Je t’invite à jeter un œil sur ces projets qui répondraient certainement à ton besoin :
    http://wpfcap.codeplex.com/
    http://wpfmediakit.codeplex.com/
    Le WIP de The last bastion, mon projet de jeu-vidéo (un TD en 3D)

    Mon portfolio / Ma page fb

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Bonjour,

    En effet, jai cru comprendre la même chose sur GDI+.
    J'ai déjà regardé le projet concernant mediakit, or je suis assez débutant et j'ai du mal à mettre ça en place d'autant que les exemples sont en c# et que moi je suis en VB.net
    j'essaye de voir l'autre projet, si je comprends mieux la mise en place
    ce qui ne te tue pas te rend plus fort

  5. #5
    Expert confirmé Avatar de DonQuiche
    Inscrit en
    Septembre 2010
    Messages
    2 741
    Détails du profil
    Informations forums :
    Inscription : Septembre 2010
    Messages : 2 741
    Points : 5 485
    Points
    5 485
    Par défaut
    Bonjour.

    Cela se résoudra sans doute en appelant un Dispose au bon endroit. Appelle-le donc sur "ms" et vérifie également si "bi" en est doté.

    A défaut mets en commentaire des parties croissantes de tes handlers récurrents, jusqu'à trouver la partie qui pose problème.

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    En fait dans la partie posant le premier problème, ms n'est pas utilisé donc je ne pense pas que ça vienne de la.

    Je pense qu'il en faudrai un au niveau de webcam_ImageCaptured, mais je ne vois pas sur quoi le faire porter, ça ne fonctionne pas sur _FrameImage.

    La partie posant problème est le LoadBitmap de Helper.vb ou son appel.
    ce qui ne te tue pas te rend plus fort

  7. #7
    Membre éprouvé Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Points : 1 118
    Points
    1 118
    Par défaut
    En même temps, comme l'a souligné DonQuiche, si tu ne dispose jamais tes ressources, c'est tout à fait normal......
    "Le train de tes injures roule sur le rail de mon indifférence."

    "Monde de merde !!"

    Georges Abitbol.

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Oui ça je sais, merci mais lors de mes tests précédent, l'acquisition se faisait en 320*240. Cela fonctionnait sans dispose().
    J'apprends tout cela sur le tas en avançant sur d'autre sujet à coté donc je suis un peu paumé et n'arrive pas à trouver ou le mettre.

    J'ai testé le dispose sur le ms cela ne fonctionne pas non plus.
    ce qui ne te tue pas te rend plus fort

  9. #9
    Membre éprouvé Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Points : 1 118
    Points
    1 118
    Par défaut
    Non mais tu me parle d'image qui pèse 1M de fois plus, tu te rend compte que sur un Pc de maintenant tu peux stocker des heures d'image en 320*240 dans la mémoire. Je peux t'assurer que le problème viens du fais qu'une Bitmap ça se dispose, que les ressources Gdi aussi, si ce n'est plus, car ce n'est pas le GC qui va le faire à ta place. Tu n'as pas mis assez de Dispose (tu n'as pas disposé tout ce qui devait l'être).

    PS : Qui plus es tu ne te sert pas du ms, mais tu l'instancie, il faut donc le libérer, je te conseille de te renseigner sur le fonctionnement des ressources utilisant le marshal et du GC.
    PS2 : Très souvent quand un objet a un Open et un Close, il à aussi un Dispose, mais le principale problème viens du fait que tu ne libère JAMAIS ta Bitmap, et vu le poids de ton image (dû à sa grande résolution) tu vois apparaitre des phénomènes de fuites mémoire, qui ne te gênais pas, mais qui existait lorsque tu faisait du 320*240.

    Cordialement.
    "Le train de tes injures roule sur le rail de mon indifférence."

    "Monde de merde !!"

    Georges Abitbol.

  10. #10
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Arf on s'est mal compris je crois.
    Je sais que ma résolution actuelle est beaucoup plus grande et que j'ai besoin de Dispose.

    J'expliquais juste que du fait que ma résolution précédente soit largement inférieure, c'est pour ça que je n'avais pas de Dispose et que pour ce que je voulais faire, cela fonctionnait même si ce n'était pas propre.

    Pour le ms en effet il faut surement aussi un Dispose, mais ce n'est pas celui là qui pose problème dans mon cas. J'y reviendrais plus tard

    La partie posant problème est le LoadBitmap de Helper.vb ou son appel dans webcam_ImageCaptured qui tournent en boucle et à ce niveau je ne vois pas sur quoi faire le dispose.

    Pour le fonctionnement des ressources avec marshal et GC en effet j'ai des lacunes. J'essaye de me mettre au point sur mon temps libre mais guère le temps.

    Cdt
    ce qui ne te tue pas te rend plus fort

  11. #11
    Expert confirmé Avatar de DonQuiche
    Inscrit en
    Septembre 2010
    Messages
    2 741
    Détails du profil
    Informations forums :
    Inscription : Septembre 2010
    Messages : 2 741
    Points : 5 485
    Points
    5 485
    Par défaut
    Voici ce que je te propose :
    * Dans webcam_ImageCaptured, avant d'assigner _FrameImage.Source, vérifie si la valeur actuelle est différente de null et le cas échant dispose-la.
    * Dans tous les cas essaie avec et sans ton appel à DeleteObject.

  12. #12
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    J'ai fait ce test ce matin j'avais comme erreur 'Dispose' n'est pas un membre de System.Windows.Media.ImageSource.

    En ayant comme condition de test
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    If _FrameImage.Source IsNot Nothing Then
    _FrameImage.Source.Dispose()
     
    End If
    par contre je n'avais pas testé avec ou sans DeleteObject
    ce qui ne te tue pas te rend plus fort

  13. #13
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Je confirme que _FrameImage.Source.Dispose() me cause une erreur à la compilation .
    En l'enlevant, j'ai essyé avec et sans deleteObject , toujours le même souci de saturation.

    Merci à vous pour vos idées/coup de main
    ce qui ne te tue pas te rend plus fort

  14. #14
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    hello,

    J'étais passé à autre chose, mais j'ai toujours mon soucis de saturation sur la caméra, je n'ai pas trop avancé sur le sujet.
    L'un d'entre vous aurait il une piste à m'indiquer?
    ce qui ne te tue pas te rend plus fort

  15. #15
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Points : 42
    Points
    42
    Par défaut
    Bonjour,

    J'ai pris du temps pour passer par mediakit et cela fonctionne correctement ! J'ai juste mes autres fonctions à adapter mais ça devrait le faire, Merci à vous
    ce qui ne te tue pas te rend plus fort

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 8
    Dernier message: 02/09/2009, 13h18
  2. mémoire insuffisante pour charger une image
    Par benj63 dans le forum C++Builder
    Réponses: 3
    Dernier message: 07/11/2007, 18h22
  3. Réponses: 0
    Dernier message: 24/07/2007, 11h38
  4. Réponses: 1
    Dernier message: 29/06/2007, 11h21
  5. Réponses: 5
    Dernier message: 12/02/2007, 13h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo