fix bug in gpu bgsegm sample

create `d_fgimg` matrix before cleaning.
Merge pull request #1650 from jet47:fix-gpu-bgsegm-sample