Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi every one i got a little problem i need to create a app capture image with directshow and c++ here the details
i need to capture image autodetect and manual
ability to configure the output and camera zoom etc ...
i have reached the phase of capturing image and save it in bmp
and i have stopped seeking in msdn without any stuff
may i haven't understand directshow very well [what fitler to use and how to combine between those filters ]
i hope i will find a refuge for my questions
and the second question is if there is any way to design the user's interface without instead of creating every component by hand in win32 ?
Posted
Comments
Sergey Alexandrovich Kryukov 9-Aug-12 15:01pm    
First part is not a question, and the last line is not a valid question, because everything is "by hand". If you need something like a visual designer, using it is even more "by hand" than writing code; so, what are you looking for?
--SA
merousoft 10-Aug-12 6:20am    
sorry i wasn't so precise
here is the question how to use or which filter i need to create a render that captures users's faces ?
like this way
http://research.microsoft.com/en-us/um/cambridge/projects/autocollage/help/ImageBrowser-Face-Manual.jpg
thx
Volynsky Alex 10-Aug-12 5:01am    
See also this link:
http://chetangole.com/blog/2008/07/how-to-take-screen-shots-of-c-program-output/
merousoft 10-Aug-12 6:18am    
screen shot isn't what i'm looking for .
how to configure filter // IBaseFilter to get more detail about input Pin to be able to handle it except if i need to create my own filter
and what is the filter that i can use to produce a render that shows a rectangle
to detect face like this http://research.microsoft.com/en-us/um/cambridge/projects/autocollage/help/ImageBrowser-Face-Manual.jpg
Volynsky Alex 10-Aug-12 6:24am    
Yes, I understand merousoft
My advice is to read the information on DS

VB
If you want simulate the printscreen in C++.
Try this small example then...


C++
#include <windows.h>
char EditText[256];
int EditTextLength;
/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Clipboard Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               544,                 /* The programs width */
               375,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND hwndButton;
    static HWND hwndEdit;
    HGLOBAL hGlobal;
    PSTR pGlobal;

    switch (message)                  /* handle the messages */
    {
    case WM_CREATE:
        hwndButton = CreateWindow ( TEXT ("button"),"Cut Text",WS_CHILD|WS_VISIBLE|1,55,100,100,25,hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance,NULL);
        hwndEdit = CreateWindow (TEXT ("edit"),NULL,WS_CHILD| ES_LEFT|WS_BORDER| WS_VISIBLE,55, 50, 100, 25, hwnd,
                                 (HMENU) 1,((LPCREATESTRUCT) lParam) -> hInstance ,NULL);
        return 0;

    case WM_COMMAND:

        switch (wParam)
        {
        case 1:
            EditTextLength = GetWindowTextLength(hwndEdit) +1;
            GetWindowText(hwndEdit, EditText, EditTextLength);
            hGlobal = GlobalAlloc(GHND|GMEM_SHARE,
                                  EditTextLength*sizeof (char));
            pGlobal = (char*)GlobalLock (hGlobal);
            strcpy (pGlobal, EditText);
            GlobalUnlock(hGlobal);

            OpenClipboard(hwnd);
            EmptyClipboard();
            SetClipboardData(CF_TEXT, hGlobal);
            CloseClipboard();
            break;
        }
        return 0;

    case WM_DESTROY:
        PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
        break;
    default:                      /* for messages that we don't deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


</windows.h>
 
Share this answer
 
Comments
merousoft 10-Aug-12 5:45am    
yes i did that Alex the thing is i have to create buttons & listboxes & and image to set the captured image there and to show it to the users
so i need to handle events on those constrols it's hard to manage to components
in win32
/*
CreateWindow("BUTTON", "continuer", WS_CHILD | WS_VISIBLE,
400, 50, 100, 30, hwnd, (HMENU)RELEASE, myCurrentApp, NULL);
*/
secondly please i need to better understand each filter specificity !!! cause i suffer from the lack of info ^_^
Volynsky Alex 10-Aug-12 6:20am    
Info about DirectShow you can find here:
http://www.youtube.com/watch?v=bl_ADLC76oQ
http://www.youtube.com/watch?v=BOGF3WkmcL8&feature=relmfu http://www.youtube.com/watch?v=ZzIKOGKJEwc&feature=relmfu http://www.youtube.com/watch?v=BA1Vkx77fZ4&feature=relmfu http://www.youtube.com/watch?v=RN8ygMtQFu4&feature=relmfu
i have used the ISampleGrabber to get buffer and convert it to image
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900