bug fix about gcc warning "struct XX declared inside parameter list.
1. add detected motion to database after it was detected,
   not at the ending of the program exiting;
bug fix about assert error when working_mode is picture