Réponse acceptée !
bon voila une solus pour ceux que ca interesse, si vous avez meilleure idee faites moi signe...
#pragma
once#include
<cv.h>#include
<highgui.h>#pragma
comment(lib,"cv.lib")#pragma
comment(lib,"highgui.lib")#include
<stdio.h>#include
<windows.h>#include
<stdio.h>#if
!defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)#define
AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_#endif
// !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)int
width=GetSystemMetrics( SM_CXSCREEN ) ;//largeur ecranint
height=GetSystemMetrics( SM_CYSCREEN );//hauteur ecranHBITMAP hbitmap;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int
WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
static
CHAR szAppName[] ="Salut" ; HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if
(!RegisterClass (&wndclass)) {
MessageBox (NULL, TEXT (
"Problème!" ),szAppName, MB_ICONERROR) ; return
0 ; }
hwnd = CreateWindow (szAppName,
// nom de la classe ""
, // titre de la fenêtre WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ,
// style de la fenêtre 0,
// position initiale en x 0,
// position initiale en y width,
// largeur initiale height,
// hauteur initiale NULL,
// handle de la fenêtre mère NULL,
// handle du menu de la fenêtre hInstance,
// handle de l'instance NULL) ;
// paramètres de création ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
//************************************* Pour l Image de la webcam********************************
CvCapture* capture=cvCaptureFromCAM(0);
IplImage *result;
//mettre une image "imprime ecran" dans le repertoire du project, elle sert juste a redimensionner la capture de la webcam en plein ecran.
result= cvLoadImage(
"image.bmp");BITMAPINFO bmpinfo;
// info sur l'image a envoyer a l ecran// Donne les infos sur le bitmapbmpinfo.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);bmpinfo.bmiHeader.biWidth = result->width;
// largeurbmpinfo.bmiHeader.biHeight = result->height;
//hauteurbmpinfo.bmiHeader.biPlanes = 1;
bmpinfo.bmiHeader.biBitCount = 24;
//L image envoyer est en 24 bit sinon ca fait canal + sans decodeur!!!! bmpinfo.bmiHeader.biCompression = DIB_RGB_COLORS;
bmpinfo.bmiHeader.biSizeImage = 0;
bmpinfo.bmiHeader.biXPelsPerMeter = 0;
bmpinfo.bmiHeader.biYPelsPerMeter = 0;
bmpinfo.bmiHeader.biClrUsed = 0;
bmpinfo.bmiHeader.biClrImportant = 0;
HDC hDC;
hDC=GetDC(hwnd);
while
(GetMessage (&msg, NULL, 0, 0)) {
cvResize( cvQueryFrame(capture), result, CV_INTER_LINEAR);
//il faut configurer le driver de la web cam si vous voulez retourner l image simplement
SetDIBitsToDevice(hDC, 0, 0, result->width, result->height, 0, 0, 0, result->height,result->imageData, &bmpinfo, DIB_RGB_COLORS);
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return
msg.wParam ; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message){
case WM_TIMER:return 0;case WM_CREATE:break;case WM_KEYDOWN:switch(wParam){
case VK_ESCAPE: // touche echap pour quitterDestroyWindow(hwnd);
return 0;}
break;case
WM_DESTROY:PostQuitMessage (0) ;
return 0 ;}
return DefWindowProc (hwnd, message, wParam, lParam);}