One factor is the individual: some individuals devoice more than others. Then you have to look at context, but additionally you have to be more specific about what you are measuring (and I should add that this is fundamentally a measurement question). The direct measurements are observable semi-periodic vibration during stop closure as well as periods of turbulent aperiodic noise preceding and following closure. An indirect measure is duration of the preceding vowel, and possibly spectral and formant effects on the preceding vowel. The last point is about the fact the fact that in pairs like "cap, cab", the voicing distinction is recoverable from the quality of the vowel [æ], even when trimmed so that durations are equal. Certain effects are categorial and others are continuous, for example vowels are always shortened before final underlyingly voiceless phonemes (at least for the speakers I've seen) but not before voiced ones, and this is true even when final /b d g/ are completely voiceless. The pattern of periodic voicing during closure seems to be quite variable within speakers (though may be categorial for some).
The main context for distinction can be labeled "encourages voicing" vs. "doesn't". Between voiced sonorant segments, /d/ is voiced in General American. Word-initially before a vowel, there is significant variation, where /g/ most strongly tends to devoice and /b/ least strongly does. /d/ is in the middle (this relates to the length of the vocal tract from the glottis to the stop closure, the longer, the more likely there is voicing). In final position, vocal fold vibration during the entire closure is unlikely, but there is often left-edge voicing that dies out during the closure. But there is also an effect on the preceding vowel, where voiced consonants correlate with longer vowels and voiceless consonants correlate with shorter vowels. Obstruent clusters are particularly messy. The clusters in "Casper" and "Casbah" are distinct, but there is no vocal fold vibration during the stop closure (at least for me, and I am a "voiced" speaker).
One thing that can be looked at, in comparing languages, is the amplitude of voicing during stop closure. In English, the tendency in initial position is that if there is voicing, it is low-amplitude and often dies out before the release, which is different from French and other languages with full voicing.
A final complication is flapping, in dialects that have it: /t,d/ become very short voiced [ɾ] intervocalically (in foot-medial position).