hawkeye camera support(not tested)

This commit is contained in:
meelstorm
2025-08-19 12:45:50 +02:00
parent f80b275ad8
commit 6ef6aced8d
170 changed files with 20190 additions and 72 deletions

View File

@@ -182,13 +182,26 @@ namespace Hawkeye.VisionBuilder
private void loadRecipeToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "*.hrcp|*.hrcp";
dialog.Filter = "Suported types|*.jhrcp;*.hrcp";
PrepareDialog(dialog);
if (dialog.ShowDialog() == DialogResult.OK)
{
var path = dialog.FileName;
LoadRecipe(path);
var ext = Path.GetExtension(path);
if (ext == ".jhrcp")
{
LoadRecipeJSON(path);
}
else if (ext == ".hrcp")
{
LoadRecipeBinary(path);
}
else
{
MessageBox.Show("Unsupported file format. Please use .hrcp or .jhrcp files.");
return;
}
}
}
@@ -210,7 +223,7 @@ namespace Hawkeye.VisionBuilder
private string _loadedPath = null;
public void LoadRecipe(string path)
public void LoadRecipeBinary(string path)
{
_loadedPath = path;
var bytes = File.ReadAllBytes(path);
@@ -218,13 +231,23 @@ namespace Hawkeye.VisionBuilder
BinaryReader reader = new BinaryReader(stream);
_workflowList.PythonMissing += _workflowList_PythonMissing;
_workflowList.Load(reader, _discoveryService);
ReinitCameraPanel(_workflowList);
OrganizeWindows(null, null);
_visionStepsPanel.RefreshWorkflow();
}
public void LoadRecipeJSON(string path)
{
_loadedPath = path;
_workflowList.LoadJSON(path,_discoveryService);
ReinitCameraPanel(_workflowList);
OrganizeWindows(null, null);
_visionStepsPanel.RefreshWorkflow();
}
private void _workflowList_PythonMissing()
{
SetupConfig();
@@ -234,20 +257,33 @@ namespace Hawkeye.VisionBuilder
private void saveRecipeToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "*.hrcp|*.hrcp";
dialog.Filter = "*.jhrcp|*.jhrcp|*.hrcp|*.hrcp";
PrepareDialog(dialog);
if (dialog.ShowDialog() == DialogResult.OK)
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
_workflowList.RecipeImage = _workflowList.Context.LastCameraImage.ImageData;
_workflowList.Save(bw);
ms.Close();
File.WriteAllBytes(dialog.FileName, ms.ToArray());
var ext = Path.GetExtension(dialog.FileName);
if (ext == ".jhrcp")
{
_workflowList.SaveJSON(dialog.FileName);
}
else
{
SaveBinary(dialog.FileName);
}
}
}
private void SaveBinary(string path)
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
_workflowList.RecipeImage = _workflowList.Context.LastCameraImage.ImageData;
_workflowList.Save(bw);
ms.Close();
File.WriteAllBytes(path, ms.ToArray());
}
private void toolBtnConfiguration_Click(object sender, EventArgs e)
{
SetupConfig();