Fixed a lot of bugs.
Still no luck though.. findContours fails because windowedFrame is a 0*0 matrix.