qr코드 인식 : http://blog.daum.net/pg365/186
1. 그레이로 변경
image = cv2.imread("sample.jpg", cv2.IMREAD_COLOR)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
2. 이미지 저장
cv2.imwrite('image.jpg', image)
3. 블랙 화이트 분리
ret,thresh1 = cv2.threshold(gray,127,255,cv2.THRESH_BINARY)
4. 화이트 색상 HSV 값
http://stackoverflow.com/questions/22588146/tracking-white-color-using-python-opencv
sensitivity = 15
lower_white = np.array([0,0,255-sensitivity])
upper_white = np.array([255,sensitivity,255])
5. 색상 반전
imagem = cv2.bitwise_not(imagem)
6. 카메라 해상도 변경
cap = cv2.VideoCapture(0)
cap.set(3, 1280.)
cap.set(4, 720.)
7. 외곽선 추출
python
http://www.pyimagesearch.com/2014/04/21/building-pokedex-python-finding-game-boy-screen-step-4-6/
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.bilateralFilter(gray, 11, 17, 17)
edged = cv2.Canny(gray, 30, 200)
cnts = cv2.findContours(edged.copy(), cv2.RETR_TREE,
cv2.CHAIN_APPROX_SIMPLE)[-2]
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:10]
screenCnt = None
print 'start'
for cnt in cnts:
epsilon = 0.1 * cv2.arcLength(cnt, True)
polygon = cv2.approxPolyDP(cnt, epsilon, True)
if len(polygon) == 4:
#if True:
screenCnt = polygon
#cv2.drawContours(temp, [screenCnt], -1, (0, 255, 0), 3)
cv2.drawContours(image, [screenCnt], -1, (0, 255, 0), 3)
#cv2.imshow("Screen", temp)
print 'find!!'
break
print 'end'
c
===========아래===========
http://hongkwan.blogspot.kr/2013/01/opencv-7-4-example.html
'영상처리 > OpenCV' 카테고리의 다른 글
OpenCV - Diffence Image 영상차 (0) | 2017.01.04 |
---|