refactor flow into a class that can be integrated into opencv for processing