반응형
OpenCV waitKey 함수 간단 설명 : 네이버 블로그 (naver.com)
OpenCV waitKey 함수 간단 설명
waitKey( 키 입력 대기 시간 ms) 키 입력 대기 시간 함수 매개 변수로 넣는 키 입력 대기 시간은 ms 단위...
blog.naver.com
import cv2
frameWidth = 640
frameHeight = 480
cap = cv2.VideoCapture(0)
cap.set(3, frameWidth) # Width
cap.set(4, frameHeight) # Height
cap.set(10, 150) # Brightness
while True:
success, img = cap.read()
cv2.imshow("",img)
if cv2.waitKey(0) and 0xFF == ord('q'):
break
cap.release()
q를 눌러도 반응이 없다. 그래서 해결방법을 찾아봤다.
코드를 다시 보니
if cv2.waitKey(0) and 0xFF == ord('q'):
에서 and가 아니라 비트연산 &를 했어야했다.. 헷갈림의 문제
그리고 콘솔에서 q 누르는게 아니라 img 창에서 q 눌러야 반응한다.
수정한 결과
import cv2
frameWidth = 640
frameHeight = 480
cap = cv2.VideoCapture(0)
cap.set(3, frameWidth) # Width
cap.set(4, frameHeight) # Height
cap.set(10, 150) # Brightness
while True:
success, img = cap.read()
cv2.imshow("", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
반응형
'개발 기록 > Coding&Debugging' 카테고리의 다른 글
[OpenCV / PIL] 'int' object is not subscriptable Error (0) | 2021.12.28 |
---|---|
[VSCode 에러] The Python path in your debug configuration is invalid. (0) | 2021.12.28 |
아두이노 컴파일 시 error: cannot convert 'USBSerial*' to 'HardwareSerial*' in assignment 문제 (0) | 2021.09.03 |
0509 (0) | 2021.05.09 |
구름 IDE에 임베디드 개발환경 설치하기 (도전! 임베디드 OS 만들기) (0) | 2021.05.09 |