Search

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

[Python] List 정렬 프로그램 구현

Programming/Python 2017. 2. 6. 20:30 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[Python] List 정렬 프로그램 구현





List 에 append 로 integer 값을 하나씩 넣은 후


오름차순 정렬하여 출력하는 프로그램








import sys

numberList =[]


for j in range(10):
    i = int(input("input: "))
    numberList.append(i)
    s1= 0
    print("Ori: {0}".format(numberList))
    while s1 < j:
        if numberList[s1] > numberList[s1+1]:
            numberList[s1] ^= numberList[s1+1]
            numberList[s1+1] ^= numberList[s1]
            numberList[s1] ^= numberList[s1+1]
        s1 = s1 + 1
    while s1 > 0:
        if numberList[s1] < numberList[s1-1]:
            numberList[s1] ^= numberList[s1-1]
            numberList[s1-1] ^= numberList[s1]
            numberList[s1] ^= numberList[s1-1]
        s1 = s1 - 1
    print("Sorted: {0}".format(numberList))

print(numberList)








import sys

numberList =[]
indexList =[]


for j in range(10):
    i = int(input("input: "))
    numberList.append(i)
    indexList.append(0)
    for k in range(len(numberList)-1):
        if i < numberList[k]:
            indexList[k] = indexList[k] + 1
        else:
            indexList[j] = indexList[j] + 1
    print("Ori: {0}".format(numberList))
    print("Sorted: {0}".format(indexList))
    for k1 in range(len(numberList)):
        for k2 in range(len(numberList)):
            if k1 == indexList[k2]:
                sys.stdout.write(str(numberList[k2]))
                sys.stdout.write(" ")
                break
    sys.stdout.write("\n")

print(numberList)






 

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

[Python/OpenCV] Near-Duplicate Image Detection #2  (0) 2020.06.02
[Python/OpenCV] Near-Duplicate Image Detection #1  (0) 2020.06.02
[Python 3.6] * 찍기  (0) 2017.02.02