rng.uniform
may be a uniform random law on [0,255]. So you have random colors...
Try to change
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
for
Scalar color = Scalar(0,255, 0 );
Colors are coded using the BGR system. B=0 G=255 R=0 is going to be green !
Bye,