dev
This commit is contained in:
parent
59ddc333c7
commit
0f145f679a
10
config/vision/labels/test_absence.pbtxt
Normal file
10
config/vision/labels/test_absence.pbtxt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
item {
|
||||
id: 1
|
||||
name: 'ok'
|
||||
color: '0x55AA55'
|
||||
}
|
||||
item {
|
||||
id: 2
|
||||
name: 'ko'
|
||||
color: '0xff0000'
|
||||
}
|
||||
10
config/vision/labels/test_presence.pbtxt
Normal file
10
config/vision/labels/test_presence.pbtxt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
item {
|
||||
id: 1
|
||||
name: 'ok'
|
||||
color: '0x55AA55'
|
||||
}
|
||||
item {
|
||||
id: 2
|
||||
name: 'ko'
|
||||
color: '0xff0000'
|
||||
}
|
||||
20
config/vision/recipes/test_absence.ini
Normal file
20
config/vision/recipes/test_absence.ini
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# O-RING PRESENCE DETECTOR
|
||||
# FOR FERRARI 000952054
|
||||
|
||||
[general]
|
||||
name: test Assemza
|
||||
instruction: CONTROLLARE PRESENZA PUNTO VERDE
|
||||
neural_network: none
|
||||
type: smart_camera
|
||||
camera_type: hikrobot_sc
|
||||
num_cameras: 1
|
||||
rotations=0
|
||||
solution_name=test_absent
|
||||
|
||||
[markers]
|
||||
|
||||
[zones]
|
||||
p1: 620,630 600,600 ok
|
||||
|
||||
[labels]
|
||||
|
||||
BIN
config/vision/recipes/test_absent.scsln
Normal file
BIN
config/vision/recipes/test_absent.scsln
Normal file
Binary file not shown.
20
config/vision/recipes/test_presence.ini
Normal file
20
config/vision/recipes/test_presence.ini
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# O-RING PRESENCE DETECTOR
|
||||
# FOR FERRARI 000952054
|
||||
|
||||
[general]
|
||||
name: Test presenza
|
||||
instruction: CONTROLLARE PRESENZA PUNTO VERDE
|
||||
neural_network: none
|
||||
type: smart_camera
|
||||
camera_type: hikrobot_sc
|
||||
num_cameras: 1
|
||||
rotations=0
|
||||
solution_name=test_presence
|
||||
|
||||
[markers]
|
||||
|
||||
[zones]
|
||||
p1: 620,630 600,600 ok
|
||||
|
||||
[labels]
|
||||
|
||||
BIN
config/vision/recipes/test_presence.scsln
Normal file
BIN
config/vision/recipes/test_presence.scsln
Normal file
Binary file not shown.
|
|
@ -23,7 +23,7 @@ class HikrobotSmartCamera(Component):
|
|||
self.ok_frames = []
|
||||
self.ok_results =[]
|
||||
|
||||
def config_changed(self, vision_recipe=None):
|
||||
def config_changed(self):
|
||||
self.connected = False
|
||||
global MV_VS_OK
|
||||
device_info_list = MV_VS_DEVICE_INFO_LIST()
|
||||
|
|
@ -85,32 +85,8 @@ class HikrobotSmartCamera(Component):
|
|||
return -2
|
||||
|
||||
# Set the camera recipe
|
||||
# Load recipe from vision/recipes directory
|
||||
if vision_recipe is not None:
|
||||
# Use the vision_recipe parameter to load the recipe
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
|
||||
recipes_dir = Path("./config/vision/recipes")
|
||||
recipe_path = recipes_dir / f"{vision_recipe}.ini"
|
||||
|
||||
if recipe_path.exists():
|
||||
config = ConfigParser(inline_comment_prefixes="#")
|
||||
config.read(recipe_path)
|
||||
if "general" in config and "solution_name" in config["general"]:
|
||||
solutionName = config["general"]["solution_name"]
|
||||
self.log.info(f"Loading solution: {solutionName} from {recipe_path}")
|
||||
mv_lib.MV_VS_SetStringValue(pHandle, "SrcOperateSolutionName", solutionName)
|
||||
mv_lib.MV_VS_SetCommandValue(pHandle, "CommandProjectLoad")
|
||||
time.sleep(5)
|
||||
else:
|
||||
self.log.error(f"No solution_name found in {recipe_path}")
|
||||
else:
|
||||
self.log.error(f"Recipe file not found: {recipe_path}")
|
||||
elif self.config.get("general", {}).get("solution_name", None) is not None:
|
||||
# Fallback to the old method if vision_recipe is not provided
|
||||
solutionName = self.config["general"]["solution_name"]
|
||||
self.log.info(f"Using fallback solution: {solutionName}")
|
||||
if self.config.vision_config.get("solution_name",None) is not None:
|
||||
solutionName = self.config.vision_config["solution_name"]
|
||||
mv_lib.MV_VS_SetStringValue(pHandle, "SrcOperateSolutionName", solutionName)
|
||||
mv_lib.MV_VS_SetCommandValue(pHandle, "CommandProjectLoad")
|
||||
time.sleep(5)
|
||||
|
|
@ -122,14 +98,14 @@ class HikrobotSmartCamera(Component):
|
|||
self.connected = True
|
||||
|
||||
@Component.reconfig_on_error
|
||||
def _get(self, vision_recipe=None):
|
||||
def _get(self):
|
||||
if not self.connected:
|
||||
self.config_changed(vision_recipe=vision_recipe)
|
||||
self.config_changed()
|
||||
if not self.connected:
|
||||
return
|
||||
concat_frame = None
|
||||
concat_results = []
|
||||
rot = self.config["general"]["rotations"].split(",")
|
||||
rot = self.config.vision_config["rotations"].split(",")
|
||||
for cam_idx in range(self.num_cameras):
|
||||
cam = self.cam_list[cam_idx]
|
||||
self.log.info(f"GET FRAME CAMERA # {cam_idx}")
|
||||
|
|
@ -160,7 +136,6 @@ class HikrobotSmartCamera(Component):
|
|||
frame = cv2.rotate(frame, cv2.ROTATE_180)
|
||||
else:
|
||||
self.connected = False
|
||||
return
|
||||
if concat_frame is None:
|
||||
concat_frame = copy.deepcopy(frame)
|
||||
else:
|
||||
|
|
@ -172,10 +147,10 @@ class HikrobotSmartCamera(Component):
|
|||
|
||||
super()._get([concat_frame, self.ok_results])
|
||||
|
||||
def resume(self, vision_recipe=None):
|
||||
def resume(self):
|
||||
self.log.info(f"RESUMING")
|
||||
if not self.connected:
|
||||
self.config_changed(vision_recipe=vision_recipe)
|
||||
self.config_changed()
|
||||
if self.connected:
|
||||
# init OK result memory
|
||||
self.ok_frames = [None for n in range(self.num_cameras)]
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ try:
|
|||
self.components["vision"].set_sources({"hikrobot_sc": self.components["hikrobot_sc"].out})
|
||||
# Connect the recipe_changed_signal from Vision to HikrobotSmartCamera
|
||||
self.components["vision"].recipe_changed_signal.connect(
|
||||
lambda recipe_name: self.components["hikrobot_sc"].config_changed(vision_recipe=recipe_name)
|
||||
lambda recipe_name: self.components["hikrobot_sc"].config_changed()
|
||||
)
|
||||
|
||||
# connect tecna to screwdriver
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user