Fixed it the reason half the screen is black is due to me not waiting for scanning to finish, but I know the whole picture works
I made code more efficient and fixed your color detection to be faster and accurate.