Capture image à partir d'une webcam
bonjour tous le monde :)
je travaille sur un mini projet (manipulation d'une webcam), alors je veux capturer une image chaque 2 seconde de la webcam!!! alors j'ai récupéré la cam dans un panel!!
j'ai fait cette méthode pour la capture :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public void savePictureCam1()
{
// Create a Bitmap of the same dimension of panelVideoPreview (Width x Height)
using (Bitmap bitmap = new Bitmap(panelVideoPreviewCam2.Width, panelVideoPreviewCam2.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
// Get the paramters to call g.CopyFromScreen and get the image
Rectangle rectanglePanelVideoPreview = panelVideoPreviewCam2.Bounds;
Point sourcePoints = panelVideoPreviewCam2.PointToScreen(new Point(panelVideoPreviewCam2.ClientRectangle.X, panelVideoPreviewCam2.ClientRectangle.Y));
g.CopyFromScreen(sourcePoints, Point.Empty, rectanglePanelVideoPreview.Size);
}
string strGrabFileName = String.Format(@"C:\Users\yamen\Desktop\pictureCam2\" + combolstVideoDevices2.Text + "_{0:yyyyMMdd_hhmmss}.jpg", DateTime.Now);
bitmap.Save(strGrabFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
} |
puis je fais l'appelle de cette méthode dans un timer et ça marche !!
le problème c'est qu'il prend une screen de l'ecran avec "les dimensions du panel" alors j'ai des images capturer de la cam , c vrai!! mais par exp si je déplace une fenêtre au dessus du panel il capte aussi une partie de la fenêtre puisque c'est une screen!!! voila une image qui explique :
http://img11.hostingpics.net/pics/94...0307121628.jpg
alors je voudrais faire la capture même si la panel est derrière une fenêtre ou la fenêtre de l'application réduite .......
et merci d'avance :)