ops late...
:)
I could not run your code... the order you draw stuff is the order they appear so if you draw your rect after the img(cam,0,0) it will be drawn over the cam image. As for a trail you might need to set a transparency for the cam, but this will blur the cam image also... So you might need to store yours rect positions in an array and draw a them with decreasing transparency, like
this example...
hth