What about using long form of create here instead of writing custom logic?

    _mask.create(count, 1, CV_8U, -1, true);