fix bug in gpu bgsegm sample

create `d_fgimg` matrix before cleaning.