title: OpenCV passing values by reference or pointer to callback functions
body: <p>I'm trying to avoid using global variables in an openCV project (I'll have my supervisor no doubt teach me as to why they are bad rah rah rah :) -  but at the moment they seem to be the only way I can get information out of mouse and trackbar callback functions.</p>
  
  <p>Using the mouse example - at the moment I have as globals:</p>
  
  <pre><code>vector&lt;Point2d&gt; vectorOfPoints;
  int clickCount = 0;
  </code></pre>
  
  <p>At the moment I have this line in main:</p>
  
  <pre><code>setMouseCallback("test",onMouse, NULL);  
  </code></pre>
  
  <p>Then above main: </p>
  
  <pre><code>void onMouse(int event, int x, int y, int f, void* ){           
      if(event == CV_EVENT_LBUTTONDOWN){  
          vectorOfPoints.push_back(Point(x,y));
          clickCount++;
      }
  }
  </code></pre>
  
  <p>It is working, but what is the syntax to get read/write access to both vectorOfPoints and clickCount inside the callback function without using globals?</p>
  
  <p>I have found this question online a few times but the answers are unclear to me or wont work. There are hints within comments as how to do it, but I am so far unable to interpret the jargon correctly.</p>
  
  <p>I was hoping for something as simple as the syntax I use to pass variables as references to methods ...</p>
  
  <pre><code>void referenceExampleMethod(vector&lt;Point2d&gt;&amp; referenceExample){
      //do something with referenceExample...
  } 
  </code></pre>
  
  <p>...less convoluted the better</p>
  
  <p>I'm scared to ask (jargon overload!) but maybe it's 100% relevant - what is void*  ??</p>
  
  <p>Any help appreciated</p>