Ask Your Question
0

Callback parameters not being updated

asked 2020-09-27 16:20:19 -0600

squenix008 gravatar image

updated 2020-09-27 20:00:52 -0600

Hi

i am using the setMouseCallback, same usage as https://answers.opencv.org/question/3... But for some reason one of the fields is not updated inside the callback The code:

    struct cbParams_t
    {
        Point pSingle;
        vector<Point> pUpAndpDown;
        Mat croppedCloth;
        int count;
        cbParams_t() : pSingle(), pUpAndpDown(), croppedCloth(), count() {}
    } ;

    // registering the callback:

    cbParams_t cbParams;
    setMouseCallback( "Img2", onMouseImg2, &cbParams )

    // inside the callback:

    static void onMouseImg2(int event, int i, int j, int flags, void* param)
    {
    cbParams_t * pCbParams = (cbParams_t *) param ;
    int * pCount = &(pCbParams->count);
    (* pCount ) ++;
...
    }
    // but when i come back inside the callback count is not incremented

Best regards.

edit retag flag offensive close merge delete

Comments

your example is somewhat incomplete. how / where do you invoke / call this piece of code ?

berak gravatar imageberak ( 2020-09-27 20:12:07 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-09-27 22:34:45 -0600

squenix008 gravatar image

updated 2020-09-27 22:36:16 -0600

I found out what was going wrong, it seems cbParams_t cbParams; was not declared globally but inside one of the functions.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-09-27 16:20:19 -0600

Seen: 158 times

Last updated: Sep 27 '20