Python Dili Kullanılarak OpenCV Kütüphanesi ile Kayıp Eşya Tespiti

preview_player
Показать описание
Daha fazla bilgi için:
Afyon Kocatepe Üniversitesi
Teknoloji Fakültesi
Elektrik Elektronik Mühendisliği
Afyon Kocatepe University
Technology Faculty
Department of Electrical Electronics Engineering
Рекомендации по теме
Комментарии
Автор

Tebrik ederim. Harika bir çalışma olmuş.

omerafacan
Автор

##doğru çalışan kod bu şekilde oldu bende
import cv2
import time

class Camera:

def __init__(self, camera_id):
print("Camera Constructor")
self.cap = cv2.VideoCapture(camera_id)


def __del__(self):
print("Camera destrcutor")
self.cap.release()
cv2.destroyAllWindows()

def is_opened(self):
return self.cap.isOpened()


def read_frame(self):


if self.cap.isOpened():

ret, frame = self.cap.read()

if ret == False:
print("No Camera found")

return ret, frame



def find_score(des1, des2):

matches = bf.knnMatch(des1, des2, k=2)
if len(matches)==0:
return 0

good = []
for m, n in matches:
if m.distance < 0.5 * n.distance:
good.append([m])

score = len(good)
return score

color = (0, 255, 0)
timeFound = timeNow = time.time()
sift =

bf = cv2.BFMatcher()

##cam = Camera("Kayip_Esya.avi")
cam = cv2.VideoCapture(0)
ret, frame = cam.read()
width = frame.shape[1]
height = frame.shape[0]

bbox = cv2.selectROI(frame, False)

x1 = int(bbox[0])
x2 = int(bbox[0] +bbox[2])
y1 = int(bbox[1])
y2 = int(bbox[1]+bbox[3])

imageOrj = frame[y1:y2, x1:x2, :]

kpROI, descROI = sift.detectAndCompute(imageOrj, None)

imageOrj = cv2.resize(imageOrj, (100, 100))
frame[height-130:height-30, 10:110]=imageOrj

##cam = cv2.VideoCapture(0)
while(cam.isOpened()):

while True:

ret, frame = cam.read()

if ret == False:
break

frame[height-130:height-30, 10:110]=imageOrj

image = frame[y1:y2, x1:x2, :]

kp, desc = sift.detectAndCompute(image, None)
score = find_score(desc, descROI)
print(score)

timeNow = time.time()
if (score)> 2:
timeFound = time.time()

if(timeNow-timeFound)>1:
print("Kayip Esya!!!")
cv2.putText(frame, 'Kayip Esya!!!', (x1, y1), 2, 1, (255, 255, 255), 1, cv2.LINE_AA)
color = (255, 255, 0)
else:
color = (0, 255, 0)


cv2.rectangle(frame, (x1, y1), (x2, y2), color, 3)
cv2.imshow('Frame', frame)



k = cv2.waitKey(1) & 0xff
if k == 27:
break

cv2.destroyAllWindows
del cam

omerafacan