Fully Customizable GPU Accelerated Identification Nodes
This commit is contained in:
Binary file not shown.
@ -3,12 +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, polling frequency, and select OCR engine.
|
||||
- Users can configure offset, margin, polling frequency, overlay color, and thickness.
|
||||
"""
|
||||
|
||||
import re
|
||||
from OdenGraphQt import BaseNode
|
||||
from PyQt5.QtCore import QTimer
|
||||
from PyQt5.QtGui import QColor
|
||||
from Modules import data_collector
|
||||
|
||||
|
||||
@ -25,10 +26,14 @@ class IdentificationOverlayNode(BaseNode):
|
||||
self.add_text_input("margin", "Margin", text="5") # Box Margin
|
||||
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.set_property("ocr_engine", "CPU") # Default to CPU mode
|
||||
|
||||
# Custom overlay options
|
||||
self.add_text_input("overlay_color", "Overlay Color (RGB)", text="0,0,255") # Default blue
|
||||
self.add_text_input("thickness", "Line Thickness", text="2") # Default 2px
|
||||
|
||||
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))
|
||||
data_collector.create_ocr_region(self.region_id, x=250, y=50, w=300, h=200, color=(0, 0, 255), thickness=2)
|
||||
|
||||
data_collector.start_collector()
|
||||
self.set_name("Identification Overlay")
|
||||
@ -76,6 +81,20 @@ class IdentificationOverlayNode(BaseNode):
|
||||
except ValueError:
|
||||
margin = 5 # Default margin if invalid input
|
||||
|
||||
# Parse overlay color
|
||||
color_text = self.get_property("overlay_color")
|
||||
try:
|
||||
color = tuple(map(int, color_text.split(","))) # Convert "255,0,0" -> (255,0,0)
|
||||
except ValueError:
|
||||
color = (0, 0, 255) # Default to blue if invalid input
|
||||
|
||||
# Parse thickness
|
||||
thickness_text = self.get_property("thickness")
|
||||
try:
|
||||
thickness = max(1, int(thickness_text)) # Ensure at least 1px thickness
|
||||
except ValueError:
|
||||
thickness = 2 # Default thickness
|
||||
|
||||
if not search_term:
|
||||
return
|
||||
|
||||
@ -84,5 +103,5 @@ class IdentificationOverlayNode(BaseNode):
|
||||
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))
|
||||
# Draw detected word boxes with custom color & thickness
|
||||
data_collector.draw_identification_boxes(self.region_id, detected_positions, color=color, thickness=thickness)
|
||||
|
Reference in New Issue
Block a user