ERROR WHILE EXECUTION

HI i tried executing the program in this video .I did both copied from github and then typed it manually but nothing is working it is showing me the same error

File “Face_Detection.py”, line 14
faces = face_cascade.detectMultiScale(frame,1.3,5)
^
IndentationError: unindent does not match any outer indentation level

Im trying to troubleshoot this from hours even changed all tabs to spaces and vice versa in my atom editor but nothing is working

Hi @Sid10
Request you to share your code through the Coding Blocks IDE (cb.lk/ide) or the drive link to it.
It would be a lot easier for me to help you if the code is available with me.

import cv2

cap = cv2.VideoCapture(0)

face_cascade = cv2.CascadeClassifier(“haarcascade_frontalface_alt.xml”)
while True:
ret,frame = cap.read()
if ret == False:
continue
faces = face_cascade.detectMultiScale(frame,1.3,5)
for face in faces:
x,y,w,h = face
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,255),2)
cv2.imshow(“Faces”,frame)

key = cv2.waitKey(1) & 0xFF
if key==ord('q'):
	break

cap.release()
cv2.destroyAllWindows()

Hi @Sid10,

Request you to share through the Coding Blocks IDE or share the complete .py file through drive.
As you can see, indentation is of utmost importance in Python, and the the code pasted here is lacking it completely. Hence, I’m unable to help you with indentation related errors with this information.

Hey @Sid10

Just went through your code. It was a case of mixed Tabs and Spaces. Checkout this link:


Here, I have replaced all tabs with spaces. I advice you to use any online service or plugin in your text editor (whenever you face such errors) in the future which can replace all tabs with spaces or vice-versa.

Hope this helps. You can now mark the doubt as resolved in the “My Doubts” section.
Happy Learning!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.