Traitement d'image

Résolu
cs_DavDav02 Messages postés 11 Date d'inscription mercredi 22 juin 2005 Statut Membre Dernière intervention 22 mai 2006 - 27 mars 2006 à 15:35
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 - 27 mars 2006 à 16:27
Bonjour à tous,

J'ai un projet qui consiste à effectuer une capture d'image à l'aide d'une webcam branchée en usb (voir code ci dessous). Jusque là, tout va bien. MAIS :
L'imae est capturée et enregistrée en 320*240 et en .jpg!!!!!!!!!

J'ai besoin d'obtenir ma capture en 640*480!!!!!!!! et en .bmp!!!!!!

Pouvez vous m'aider svp!!!! Merci

Voici mon code:


private
void Form1_Load(
object sender, System.EventArgs e)
{


DateTime temps = DateTime.Now;





//recuperation de la date



string jour = temps.Day.ToString();



string mois = temps.Month.ToString();



string anne = temps.Year.ToString();



string rep = jour+"."+mois+"."+anne;



//creation des repertoires


path = "c:\\capture\"+rep ;



//creation du repertoire principale


Directory.CreateDirectory("c:\\capture\");



//creation du sous repertoire


Directory.CreateDirectory(path);


}



private
void timer1_Tick(
object sender, System.EventArgs e)


{



try


{





//qualiter de compression Jpeg



short nQuality = 500;





//Capturer une image du webcam


CAMSERVERLib.Camera cam =
new CAMSERVERLib.CameraClass();





byte[] picture = (
byte[])cam.GrabFrame( nQuality );


MemoryStream ms =
new MemoryStream(picture);


Bitmap bmp =
new Bitmap( ms );



//Afficher l'image dans le pictureBox



this.pictureBox1.Image=bmp;


}



catch{}


}



private
void button1_Click(
object sender, System.EventArgs e)


{



if(
this.timer1.Enabled==
true)


{



//Arrétée le timer



this.button1.Text="Démarrer";



this.timer1.Enabled=
false;


DateTime temp = DateTime.Now;



//recuperation des heures , minutes , secondes pour enregistrement de la photo



string heure = temp.Hour.ToString();



string minutes = temp.Minute.ToString();



string secondes = temp.Second.ToString();



string photo = heure+"h"+minutes+"m"+ secondes+"s".ToString() ;



try


{



//nom de la photo


nom = path +"\"+photo+".jpg";


pictureBox1.Image.Save(nom.ToString());


}



catch( Exception a )


{


MessageBox.Show(a.ToString());


}


}



else


{



this.button1.Text="Capturer";



this.timer1.Enabled=
true;


}


}


<gras>DavDav

3 réponses

MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
27 mars 2006 à 15:50
Salut,

Pour sauvegarder en bmp, utilise cette surchargede la méthode Image.Save :



this.pictureBox1.Image.Save(nom
, System.Drawing.Imaging.
ImageFormat.Bmp);


Mx
MVP C#
3
cs_DavDav02 Messages postés 11 Date d'inscription mercredi 22 juin 2005 Statut Membre Dernière intervention 22 mai 2006
27 mars 2006 à 16:24
Merci beaucoup pour ton aide. Ma photo est maintenant bien capturée en .bmp!!!

Il me faut maintenant parvenir à avoir une résolution de 640*480 et non 320*240!!!
Si quelqu'un peut m'aider, ca serait bien Merci
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
27 mars 2006 à 16:27
Je pense que la il faut voir au niveau du composant que tu utilises pour capturer ton image.

Autrement, il faudrait resizer ton image en l'agrandissant a la volée, mais tu perdras en qualité :/


Mx
MVP C#
0
Rejoignez-nous