mouthMinX = int(x + (w / 4) - (w / 16)) mouthMinY = int(y + 3 * (h / 4) - (h / 8)) mouthMaxX = int(x + 3 * (w / 4) + (w / 16)) mouthMaxY = int(y + 3 * (h / 4) + h / 8 + h / 16) mouthH = mouthMaxY - mouthMinY mouthYPosition = int(mouthMinY + (mouthH / 8) * 5) isSmiling, isFrowning = SmileDetection.mouthSmiling( gray, mouthMinX, mouthMinY, mouthMaxX - mouthMinX, mouthMaxY - mouthMinY) if isSmiling: r.updateMouth(1) r.updateBrow(browState) rawCapture.flush() elif isFrowning: r.updateMouth(2) r.updateBrow(browState) rawCapture.flush() else: r.updateMouth(0) r.updateBrow(browState) rawCapture.flush() r.getReaction() # clear the stream in preparation for the next frame rawCapture.truncate(0) # if the `q` key was pressed, break from the loop