Sosyal açıldı! Bir göz at → Hemen gir →

? Duration ( 0% ) python Soru Cevap

41asd41

KY Kıdemli Üye
KAYIT
12 Ara 2023
Mesajlar
272
Tepki puanı
0
Merhaba arkadaşlar bi proje üstünde çalışıyorum fakat silah rpr noktasında sıkışıp kaldım bu konuda yardımcı olarak üstadlardan yardım bekliyorum
Olay şu
silahın %0 da olan durability alıyorum ekran taratıyorum fakat silah
%24 bazan % 20 Bazan bazan %19 da filan silah değiştirme işini tedikliyor bir türlü %0 da değiştiremedim
Threshold confidance ne kdar yüksek yaparsam yapim yinede ya hiç bulmuyor yada dediğim gibi %0 harici kırmızı olduğu ve 0 a benzer tüm eşleşmelerde silahı değiştiriyor yapan arkadaşlar bunu nasıl yapabildi merak ediyorum.
kullandığım kütüphane biri
Spoyler: pyautogui
def locate_on_screen(self, image_path, confidence=0.85, grayscale=False):
try:
screenshot = np.array(pyautogui.screenshot())
screenshot = cv2.cvtColor(screenshot, cv2.COLOR_RGB2GRAY if grayscale else cv2.COLOR_RGB2BGR)
template = cv2.imread(self.resource_path(image_path), cv2.IMREAD_GRAYSCALE if grayscale else cv2.IMREAD_COLOR)
if template is None:
self.status_queue.put(f"Hata: photos klasöründe {image_path} dosyası bulunamadı.")
logging.error(f"Resim dosyası bulunamadı: {image_path}")
return None
scales = np.linspace(0.8, 1.2, 5)
for scale in scales:
scaled_template = cv2.resize(
template,
(0, 0),
fx=scale,
fy=scale,
interpolation=cv2.INTER_AREA if scale < 1 else cv2.INTER_CUBIC
)
t_h, t_w = scaled_template.shape[:2]
if t_h > screenshot.shape[0] or t_w > screenshot.shape[1]:
continue
result = cv2.matchTemplate(screenshot, scaled_template, cv2.TM_CCOEFF_NORMED)
_, max_val, _, max_loc = cv2.minMaxLoc(result)
if max_val >= confidence:
logging.debug(f"Resim bulundu: {image_path}, ölçek: {scale}, konum: {max_loc}, güven: {max_val}, grayscale: {grayscale}")
return (max_loc[0], max_loc[1], t_w, t_h)

self.status_queue.put(f"{image_path} bulunamadı (eşik: {confidence}).")
logging.debug(f"Resim bulunamadı: {image_path}, confidence: {confidence}, grayscale: {grayscale}")
return None
except Exception as e:
self.status_queue.put(f"Resim arama hatası: {e}")
logging.error(f"Resim arama hatası: {image_path}, hata: {e}")
return None

diğeri de cv2 nin kendi ekran arama kütüphanesi
Spoyler: CV2 EKRAN ARAMA
def locate_on_screen(self, image_path, confidence=0.8, grayscale=True, region=None):
try:
screenshot = self.capture_region_once(region or (0, 0, mss().monitors[1]["width"], mss().monitors[1]["height"]), grayscale=grayscale)
if screenshot is None:
logging.info(f"{image_path} için ekran görüntüsü alınamadı.")
return None
template = cv2.imread(self.resource_path(image_path), cv2.IMREAD_GRAYSCALE if grayscale else cv2.IMREAD_COLOR)
if template is None:
self.status_queue.put(f"Hata: photos klasöründe {image_path} dosyası bulunamadı.")
logging.error(f"Resim dosyası bulunamadı: {image_path}")
return None
t_h, t_w = template.shape[:2]
result = cv2.matchTemplate(screenshot, template, cv2.TM_CCOEFF_NORMED)
_, max_val, _, max_loc = cv2.minMaxLoc(result)
if max_val >= confidence:
logging.debug(f"Resim bulundu: {image_path}, konum: {max_loc}, güven: {max_val}")
return (max_loc[0], max_loc[1], t_w, t_h)
logging.info(f"{image_path} bulunamadı (eşik: {confidence}).")
return None
except Exception as e:
self.status_queue.put(f"Resim arama hatası: {image_path}, hata: {e}")
logging.error(f"Resim arama hatası: {image_path}, hata: {e}")
return None

Fakat bir yerlerde bir konuyu eksik yapiyor olabilirim öneri ve fikirlerinize açığım farklı düşüncelerden bu işi çözebilirim gibi geliyor.
bide şunun üzerinde çalışıyorum ama nasıl olacak bilmiyorum
kullanıcı silahın resmini alacak kırmızı renk tonu olursa invertorydeki resmine tıklayacak şekilde çalışıyorum. Güncel ve güvenilir hizmet. ?
 
Anasayfa Kayıt ol Giriş yap
Üst Alt