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

VB.NET Discussion :

utiliser une camera avec Aforge


Sujet :

VB.NET

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 8
    Points : 6
    Points
    6
    Par défaut utiliser une camera avec Aforge
    Bonjour,

    j'ai un soucis avec mon code.
    Je voudrais afficher ma caméra, mais je n'ai rien dans ma picture box

    j'ai mis mes id, psw et url dans des textboxs et cela fonctionne avec firefox, donc pas de soucis avec mon authentification

    pas de soucis lors de la compilation...

    vous auriez une piste ?

    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
    Option Strict On
     
    Imports System.ComponentModel
    Imports System.IO
    Imports System.Management
    Imports System.Net
    Imports System.Threading
     
    Imports AForge.Controls
    Imports AForge.Video
    Imports AForge.Video.DirectShow
     
    .....
        Private Sub CloseVideoSource()
            If (Me.videoSourcePlayer.VideoSource IsNot Nothing) Then
                Me.videoSourcePlayer.SignalToStop()
                Dim num As Integer = 0
                Do
                    Thread.Sleep(100)
                    num += 1
                Loop While num < 30 AndAlso Me.videoSourcePlayer.IsRunning
                If (Me.videoSourcePlayer.IsRunning) Then
                    Me.videoSourcePlayer.[Stop]()
                End If
                Me.videoSourcePlayer.VideoSource = Nothing
            End If
        End Sub
     
     
     
     
     
     
        Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
            OpenMJPEGURL()
        End Sub
     
        Private devicesCombo As New ComboBox
        Private videodevices As New FilterInfoCollection(FilterCategory.VideoInputDevice)
     
        Public WithEvents videoSourcePlayer As New AForge.Controls.VideoSourcePlayer
        Public WithEvents le_timer As New System.Windows.Forms.Timer
     
        Private Sub OpenMJPEGURL()
            Try
                Dim stream As New MJPEGStream(box_url.Text)
                stream.Login = box_usr.Text
                stream.Password = box_psw.Text
                OpenVideoSource(stream)
            Catch ex As Exception
                MessageBox.Show("Erreur lors de la connexion au flux vidéo : " & ex.Message)
            End Try
        End Sub
     
     
        Private Sub OpenVideoSource(ByVal source As IVideoSource)
            Try
                Me.Cursor = Cursors.WaitCursor
                Me.CloseVideoSource()
                Me.videoSourcePlayer.VideoSource = source
                Me.videoSourcePlayer.Start()
                Me.le_timer.Interval = 2000
                Me.le_timer.Start()
                Me.Cursor = Cursors.[Default]
            Catch ex As Exception
                MessageBox.Show("Erreur lors de la lecture du flux vidéo : " & ex.Message)
            End Try
     
        End Sub
     
     
     
        Private Sub Le_timer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles le_timer.Tick
            Dim videoSource As IVideoSource = Me.videoSourcePlayer.VideoSource
     
            If (videoSource IsNot Nothing) Then
                Dim framesReceived As Integer = videoSource.FramesReceived
                PictureBox2.Image = videoSourcePlayer.GetCurrentVideoFrame
                PictureBox2.Refresh()
            End If
        End Sub
     
     
        Private Sub videoSourcePlayer_NewFrame(ByVal sender As Object, ByRef image As Bitmap) Handles videoSourcePlayer.NewFrame
            PictureBox2.Image = image
        End Sub

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    1 107
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 1 107
    Points : 1 611
    Points
    1 611
    Par défaut
    Pour une source MJPEG, la doc indique de démarrer le stream et d'ajouter une fonction de gestion d'événement NewFrame qui va récupérer et afficher l'image reçue => http://www.aforgenet.com/framework/f...o_streams.html

    http://www.aforgenet.com/framework/d...29f5c94d05.htm

    Autre lien https://stackoverflow.com/questions/...-video-library

    donc ton erreur semble être dans la définition de ta fonction d'événement NewFrame (tu n'as pas besoin de ton timer)

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 8
    Points : 6
    Points
    6
    Par défaut
    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
        Public WithEvents videoSourcePlayer1 As New AForge.Controls.VideoSourcePlayer
     
        Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
            Dim mjpegSource As New JPEGStream("http:// <mon ip> :<port>/mjpeg/snap.cgi?chn=1")
            mjpegSource.Login = "admin"
            mjpegSource.Password = "pass"
            videoSourcePlayer1.VideoSource = mjpegSource
     
            Controls.Add(Me.videoSourcePlayer1)
            videoSourcePlayer1.Location = New System.Drawing.Point(180, 190)
            videoSourcePlayer1.Size = New System.Drawing.Size(400, 300)
            videoSourcePlayer1.BringToFront()
            videoSourcePlayer1.Start()
     
        End Sub
    fonctionne a ca ...

  4. #4
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2012
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 8
    Points : 6
    Points
    6
    Par défaut merci
    Merci, je passe en résolu

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

Discussions similaires

  1. Afficher flux vidéo camera ip avec Aforge
    Par boby057 dans le forum C#
    Réponses: 3
    Dernier message: 12/05/2014, 12h52
  2. split screen - Gestion de la camera avec glViewPort
    Par arrakis42 dans le forum OpenGL
    Réponses: 4
    Dernier message: 24/05/2013, 03h27
  3. Problème camera avec les HTC
    Par AÐÐ LINE dans le forum Android
    Réponses: 0
    Dernier message: 18/01/2011, 08h51
  4. Changement angle camera avec glulookat()
    Par Despak dans le forum OpenGL
    Réponses: 3
    Dernier message: 28/02/2007, 10h16
  5. Redefiniton de la camera avec gluLookAt();
    Par AliceD dans le forum OpenGL
    Réponses: 3
    Dernier message: 03/08/2006, 18h44

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