DirectX.capture capture et traitement des image en temps réel

Résolu
gearmat Messages postés 12 Date d'inscription mercredi 30 juillet 2008 Statut Membre Dernière intervention 31 août 2010 - 16 avril 2010 à 18:57
gearmat Messages postés 12 Date d'inscription mercredi 30 juillet 2008 Statut Membre Dernière intervention 31 août 2010 - 19 avril 2010 à 12:41
salut a tous,



Je suis entrain de coder une appli pour faire la lecture de code barre via webcam

j'utilise la librairie directX.capture pour capturer les images et Zxing pour les décoder

j'ai un problème je veux prendre une image toutes les 100ms faire une détection et décoder si il y a un code dans l'image. j'utilise un thread mais ca ne marche.

je le fait via un bouton et ca marche très bien. avez vous une autre méthode que le thread

ps : je suis novice

using System;
using System.Data;
using System.Text;
using System.Drawing;
using DirectX.Capture;
using System.Windows.Forms;
using System.Timers;
using System.ComponentModel;
using System.Collections.Generic;
using com.google.zxing.multi;
using com.google.zxing.common;
using com.google.zxing.qrcode.detector;
using com.google.zxing;
using System.Threading;
    


namespace test
{
    public partial class Form1 : Form
    {
        private Filters InputOptions = new Filters();
        public Thread fullcapturepdecode;
        public Capture captureVX = null;
               
        public Form1()
        {
            InitializeComponent();
            Camopen();
           
            fullcapturepdecode = new Thread(new ThreadStart(capturendecode));
                  
        }
        public void capturendecode()
        {
           
            
            while (Thread.CurrentThread.IsAlive)
            {
                try
                {
                    prendunefram();
                    //decodeunefram();
                    
                }
                catch (Exception exept)
                {
                    this.ErrorMessage(exept);
                }
               
            }
        }

        private void ErrorMessage(Exception e)
        {
            MessageBox.Show(e.Message, "Webcam Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            fullcapturepdecode.Start();          
        }
        private void prendunefram()
        {
            try
            {
                captureVX.CaptureFrame();
               


            }
            catch (Exception exept)
            {
                this.ErrorMessage(exept);
            }
        }

   




erreur
A voir également:

5 réponses

gearmat Messages postés 12 Date d'inscription mercredi 30 juillet 2008 Statut Membre Dernière intervention 31 août 2010
16 avril 2010 à 18:59
erreur

L'exception System.InvalidCastException n'a pas été gérée
Message="Impossible d'effectuer un cast d'un objet COM de type 'System.__ComObject' en type d'interface 'DShowNET.ISampleGrabber'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{6B652FFF-11FE-4FCE-92AD-0266B5D7C78F}' a échoué en raison de l'erreur suivante : Cette interface n'est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE))."
Source="DShowNET"
StackTrace:
à DShowNET.ISampleGrabber.SetCallback(ISampleGrabberCB pCallback, Int32 WhichMethodToCallback)
à DirectX.Capture.Capture.CaptureFrame()
à test.Form1.prendunefram() dans T:\Visual Studio 2008\Projects\test\test\Form1.cs:ligne 82
à test.Form1.capturendecode() dans T:\Visual Studio 2008\Projects\test\test\Form1.cs:ligne 47
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
InnerException:
3
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
17 avril 2010 à 14:55
Salut, apparemment ta classe de capture ne supporte pas d'être appellée depuis un autre thread, essaye depuis un System.Windows.Forms.Timer ou depuis un thread MTA :

myThread.SetApartmentState( ApartmentState.MTA );
3
gearmat Messages postés 12 Date d'inscription mercredi 30 juillet 2008 Statut Membre Dernière intervention 31 août 2010
17 avril 2010 à 17:50
TIMER marche pas

le thread MTA je vais essayer


dans l'erreur il y a ca DShowNET.ISampleGrabber je voie ce que je peux faire avec
3
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
18 avril 2010 à 07:59
Qu'est ce qu'il se passe avec le Timer ? J'ai bien précisé un : System.Windows.Forms.Timer
3

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
gearmat Messages postés 12 Date d'inscription mercredi 30 juillet 2008 Statut Membre Dernière intervention 31 août 2010
19 avril 2010 à 12:41
ca bon ca marche merci :D

maintenant j'ai des problemes avec Zxing mais ca sera pour un prochain épisode
3
Rejoignez-nous