Nesne tanıma ve ölçeklendirme

arkadaşlar merhaba okul için bir projem olan bu konuda sizden yardım istiyorum , kütüphanede sürekli doğru yapıyorum herşeyi fakat genel olarak aşağıdaki gibi staabil bir kod yazamıyorum. İstediğim şey ise videoda hareket halindeyken bir nesneyi tanımak , bunun araba,motor,uçak gibi araçları tanıyarak bir scale ile oranlandırılarak dikdörtgen içinde gösterilip tespitini yapmak istiyorum. Yardımcı olursanız çok sevinirim bayadır ugrastım yapamıyorum , teşekkür ederim…

Aramıza hoş geldiniz :partying_face:


Yazdığınız bir kod var mı?

evet atayım hemen
import cv2

Source data

img_file = “iha.png”

create an openCV image

img = cv2.imread(img_file,0)

pre trained Car and Pedestrian classifiers

car_classifier = ‘Ucak3.xml’

create trackers using classifiers using OpenCV

car_tracker = cv2.CascadeClassifier(car_classifier)

detect cars

cars = car_tracker.detectMultiScale(img)

display the coordinates of different cars - multi dimensional array

print(cars)

draw rectangle around the cars

for (x,y,w,h) in cars:
cv2.rectangle(img, (x,y), (x+w, y+h), (0,255,0), 2)
cv2.putText(img, ‘Car’, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)

Finally display the image with the markings

cv2.imshow(‘my detection’,img)

wait for the keystroke to exit

cv2.waitKey()

print(“I’m done”)

import cv2

Source data

img_file = “iha.png”

create an openCV image

img = cv2.imread(img_file,0)

pre trained Car and Pedestrian classifiers

car_classifier = ‘Ucak3.xml’

create trackers using classifiers using OpenCV

car_tracker = cv2.CascadeClassifier(car_classifier)

detect cars

cars = car_tracker.detectMultiScale(img)

display the coordinates of different cars - multi dimensional array

print(cars)

draw rectangle around the cars

for (x,y,w,h) in cars:

cv2.rectangle(img, (x,y), (x+w, y+h), (0,255,0), 2)

cv2.putText(img, 'Car', (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)

Finally display the image with the markings

cv2.imshow(‘my detection’,img)

wait for the keystroke to exit

cv2.waitKey()

print(“I’m done”)

Şu konuyu okuyup kodları düzenleyebilir misiniz?

‘’'python
import cv2

Source data

img_file = “iha.png”

create an openCV image

img = cv2.imread(img_file,0)

pre trained Car and Pedestrian classifiers

car_classifier = ‘Ucak3.xml’

create trackers using classifiers using OpenCV

car_tracker = cv2.CascadeClassifier(car_classifier)

detect cars

cars = car_tracker.detectMultiScale(img)

display the coordinates of different cars - multi dimensional array

print(cars)

draw rectangle around the cars

for (x,y,w,h) in cars:

cv2.rectangle(img, (x,y), (x+w, y+h), (0,255,0), 2)

cv2.putText(img, 'Car', (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)

Finally display the image with the markings

cv2.imshow(‘my detection’,img)

wait for the keystroke to exit

cv2.waitKey()

print(“I’m done”)
‘’’

Maalesef yine olmamış. Kullandığınız işaret yanlış. En üstteki satır şu şekilde olmalı :

image

En alt ise şu şekilde :

image

İşareti kopyalamak için :

`

import cv2

# Source data

img_file = "iha.png"

# create an openCV image

img = cv2.imread(img_file,0)

# pre trained Car and Pedestrian classifiers

car_classifier = 'Ucak3.xml'

# create trackers using classifiers using OpenCV

car_tracker = cv2.CascadeClassifier(car_classifier)

# detect cars

cars = car_tracker.detectMultiScale(img)

# display the coordinates of different cars - multi dimensional array

print(cars)

# draw rectangle around the cars

for (x,y,w,h) in cars:

    cv2.rectangle(img, (x,y), (x+w, y+h), (0,255,0), 2)

    cv2.putText(img, 'Car', (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)

# Finally display the image with the markings

cv2.imshow('my detection',img)

# wait for the keystroke to exit

cv2.waitKey()

print("I'm done")
1 Beğeni