Cosine function period
One may use the following closed formula to compute numFlashes:

numFlashes = 5 * mAccumulatedTime / pi.


This follows from the fact that the period of the function abs(cos(x)) is pi and, if an oscillating function in variable x has a period T, then the number of oscillations, n, is given by the formula:

n = x / T.


Thus, your function definition may be corrected, and even simplified, as follows:

const float PI = acosf(-1);

void Player::update(const float&amp; deltaTime)
{
    mAccumulatedTime += deltaTime;
    float opacity = abs(cosf(5*mAccumulatedTime)) * 255;
    int numFlashes = 5 * mAccumulatedTime / PI;
    cout &lt;&lt; numFlashes &lt;&lt; endl;
    mSprite.setFillColor(sf::Color(255, 255, 255, opacity));
}