Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can't do without waitkey, if you plan to use imshow.

but you could make the grab/read part of the capture depend on mouseclick:

// avoid global vars, pass a struct* instead:
struct User
    VideoCapture cap;
    Mat m;

void mouse(int k, int x, int y, int s, void *p)
    User * u  = (User*)p;
    if ( k && s )
int main(int,char**)
    User u;
    while( u.cap.isOpened() )
        if (! u.m.empty())
        int k = waitKey(10);
        if ( k==27 ) break;
    return 0;