Enabled GPU Acceleration for Identification Node.
This commit is contained in:
@ -3,14 +3,13 @@
|
||||
Identification Overlay Node:
|
||||
- Creates an OCR region in data_collector with a blue overlay.
|
||||
- Detects instances of a specified word and draws adjustable overlays.
|
||||
- Users can configure offset, margin, and polling frequency dynamically.
|
||||
- Users can configure offset, margin, polling frequency, and select OCR engine.
|
||||
"""
|
||||
|
||||
import re
|
||||
from OdenGraphQt import BaseNode
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from PyQt5.QtCore import QTimer
|
||||
from Modules import data_manager, data_collector
|
||||
from Modules import data_collector
|
||||
|
||||
|
||||
class IdentificationOverlayNode(BaseNode):
|
||||
@ -24,7 +23,9 @@ class IdentificationOverlayNode(BaseNode):
|
||||
self.add_text_input("search_term", "Search Term", text="Aibatt")
|
||||
self.add_text_input("offset_value", "Offset Value (X,Y)", text="0,0") # X,Y Offset
|
||||
self.add_text_input("margin", "Margin", text="5") # Box Margin
|
||||
self.add_text_input("polling_freq", "Polling Frequency (ms)", text="500") # New input
|
||||
self.add_text_input("polling_freq", "Polling Frequency (ms)", text="500") # Polling Rate
|
||||
self.add_combo_menu("ocr_engine", "Type", items=["CPU", "GPU"])
|
||||
self.set_property("ocr_engine", "CPU") # Set default value after adding the menu
|
||||
|
||||
self.region_id = "identification_overlay"
|
||||
data_collector.create_ocr_region(self.region_id, x=250, y=50, w=300, h=200, color=(0, 0, 255))
|
||||
@ -45,7 +46,7 @@ class IdentificationOverlayNode(BaseNode):
|
||||
"""
|
||||
polling_text = self.get_property("polling_freq")
|
||||
try:
|
||||
polling_interval = max(100, int(polling_text)) # Minimum 100ms to avoid overloading
|
||||
polling_interval = max(50, int(polling_text)) # Minimum 50ms for near real-time
|
||||
except ValueError:
|
||||
polling_interval = 500 # Default to 500ms
|
||||
|
||||
@ -58,6 +59,7 @@ class IdentificationOverlayNode(BaseNode):
|
||||
search_term = self.get_property("search_term")
|
||||
offset_text = self.get_property("offset_value")
|
||||
margin_text = self.get_property("margin")
|
||||
ocr_engine = self.get_property("ocr_engine")
|
||||
|
||||
# Read and apply polling frequency updates
|
||||
self.update_polling_frequency()
|
||||
@ -77,8 +79,10 @@ class IdentificationOverlayNode(BaseNode):
|
||||
if not search_term:
|
||||
return
|
||||
|
||||
# Get detected word positions
|
||||
detected_positions = data_collector.find_word_positions(self.region_id, search_term, offset_x, offset_y, margin)
|
||||
# Get detected word positions using the selected OCR engine
|
||||
detected_positions = data_collector.find_word_positions(
|
||||
self.region_id, search_term, offset_x, offset_y, margin, ocr_engine
|
||||
)
|
||||
|
||||
# Draw detected word boxes
|
||||
data_collector.draw_identification_boxes(self.region_id, detected_positions, color=(0, 0, 255))
|
||||
|
Reference in New Issue
Block a user