Rewrote the entire code from scratch in OpenCV2. Fixed Bugs. SWT now works correctly