initial rectangle detection