Hi Dominique,
The first problem which you mentioned about the script which is combining two different color and seeing them as one object arising because the script when create an object during the foreground segmentation convert the image to Binary image and use that masked image to create a bounding box or extract an object from the image, thus it lost the color property of image.
Instead you can first threshold out different color ranges from the image after the foreground segmentation and use them to extract or distinguish different colored balls. In case if you are not familiar with how to approach this, May be this LINK will give you a good head start.
I hope this helps.