336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import time
import cv2
import numpy as np
from mss import mss


print("load finger png files...")
imageFinger1 = cv2.imread("finger1.png")
imageFinger2 = cv2.imread("finger2.png")
imageFinger3 = cv2.imread("finger3.png")
imageFinger4 = cv2.imread("finger4.png")
print("load finger png files... Done")


with mss() as sct:
mon1 = sct.monitors[1]
mon2 = sct.monitors[2]
mon3 = sct.monitors[3]
mon4 = sct.monitors[4]
box = {'top': mon4['top'] +400, 'left': mon4['left'] + 200, 'width': 150, 'height': 190}
# mon = sct.monitors[0]
while True:
last_time = time.time()
capturedImage = np.array(sct.grab(box))
capturedImage = cv2.cvtColor(capturedImage, cv2.COLOR_BGRA2RGB)
imageFinger1 = cv2.cvtColor(imageFinger1, cv2.COLOR_BGRA2RGB)
imageFinger2 = cv2.cvtColor(imageFinger2, cv2.COLOR_BGRA2RGB)

#print('fps: {0}'.format(1 / (time.time()-last_time)))

#cv2.imshow('capturedImage', capturedImage)

difference = cv2.subtract(capturedImage, imageFinger1)
b, g, r = cv2.split(difference)
diff = cv2.countNonZero(b) + cv2.countNonZero(g) + cv2.countNonZero(r)
cv2.imshow('imageFinger1', difference)
print("png 1 diff = " + str(diff))
if diff == 0:
print("Detected finger png 1 !!!")
cv2.imshow('imageFinger1', difference )

difference = cv2.subtract(capturedImage, imageFinger2)
b, g, r = cv2.split(difference)
diff = cv2.countNonZero(b) + cv2.countNonZero(g) + cv2.countNonZero(r)
print("png b bbbb = " + str(b))
print("png b diff = " + str(cv2.countNonZero(b)))
print("png g diff = " + str(cv2.countNonZero(g)))
print("png r diff = " + str(cv2.countNonZero(r)))
cv2.imshow('imageFinger2', difference)
print("png 2 diff = " + str(diff))

if diff == 0:
print("Detected finger png 2 !!!")
cv2.imshow('imageFinger1', difference)


if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break




'Programming > Python' 카테고리의 다른 글

[Python/OpenCV] Near-Duplicate Image Detection #2  (0) 2020.06.02
[Python] List 정렬 프로그램 구현  (0) 2017.02.06
[Python 3.6] * 찍기  (0) 2017.02.02
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Android , OpenCV 연동하여 카메라 촬영시 해상도 문제



params.setPictureSize(resolution.width, resolution.height); params.setPreviewSize(resolution.width, resolution.height);


Picture Size 실제 찍히는 사진 사이즈와


Preview Size 미리보기로 나오는 화면 사이즈가 별도로 존재하니 꼭 확인 바랍니다.



Android Studio 1.4 and OpenCV 3.0.0 연동

Programming/Android 2015. 12. 19. 02:39 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Android Studio 1.4 and OpenCV 3.0.0 연동


Android Studio 1.4


https://dl.google.com/dl/android/studio/install/1.4.0.10/android-studio-bundle-141.2288178-windows.exe


OpenCV_Java_AndroidStudio

https://github.com/quanhua92/OpenCV_Java_AndroidStudio