Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>To point out the obvious:</em> the non-smoothness of your mouse implementation comes from the fact that the rectangle given by camshift is only accurate to the accuracy of one frame pixel, so the smallest movement possible will be screensize/framesize rounded to the nearest screen pixel.</p> <p>If that is the case, some kind of pointer acceleration could be applied, just like it is done when real, low-quality mice are used (of course, in case of multiple thousand dpi laser mice, there is no need for such thing). Basically, the distance the cursor moves on screen is not the distance taken by the pointer input (in this case, camshift rectangle displacement), but a cleverly chosen function of it. So, using an acceleration function f(x), the steps of moving the pointer will be like this:</p> <ol> <li>Calculate vector of pointer input displacement, let that be denoted by <strong>v</strong>.</li> <li>Calculate the corresponding unit-length vector, let that be denoted by <strong>u</strong>.</li> <li>The on-screen pointer displacement is <strong>v'</strong>=f(|<strong>v</strong>|) * <strong>u</strong></li> </ol> <p>I'd chose f(x) in a form like <em>beta</em> * e^(<em>alpha</em> * x - 1), where 0 &lt; <em>alpha</em> and 0 &lt; <em>beta</em> &lt;= 1 are parameters which should be empirically chosen.</p> <p>Basically, any function will do it that has a derivate of 1 or less at 0 (allows you to use the full accuracy of the input for precise cursor movements), goes to infinity as x increases (large movements should correspond to large movements of the cursor), is monotonically increasing and has a monotonically increasing first derivate. <strong>Edit:</strong> It is also needed that the acceleration function has a value of 0 at 0, otherwise very strange movements will happen. :)</p> <p>It is also desirable to have f(<em>framewidth</em>) = <em>screenwidth</em> so that moving the tracked object across the frame results in the cursor being moved across the screen. An exponential formula is quite pleasing to work with, but using a quadratic or higher degree polynomial may turn out to be computationally simpler, depending on what performance requirements are there...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload