using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using HalconDotNet;
|
|
namespace HalconTools
|
{
|
public class JobAssistance
|
{
|
public JobAssistance()
|
{
|
}
|
|
/// <summary>
|
/// 单独工具运行
|
/// </summary>
|
/// <param name="tool"></param>
|
public JobResult ToolRun(HImage image,JobTool tool)
|
{
|
JobResult tmpResult = new JobResult();
|
FitAssistant mfit = new FitAssistant();
|
MatchingAssistant mMatch = new MatchingAssistant();
|
ScrewAssistant mScrew = new ScrewAssistant();
|
|
switch (tool.type)
|
{
|
case ToolType.FindCircle:
|
|
tmpResult.fitCircleResult = new FitCircleResult();
|
mfit.mImage = image;
|
tmpResult.fitCircleResult = mfit.FitCircle(tool.fitCircleParam);
|
|
break;
|
|
case ToolType.FindLine:
|
|
tmpResult.fitLineResult = new FitLineResult();
|
mfit.mImage = image;
|
tmpResult.fitLineResult = mfit.FitLine(tool.fitLineParam);
|
|
break;
|
|
case ToolType.Matching:
|
|
tmpResult.matchingResult = new MatchingResult();
|
mMatch.mImage = image;
|
mMatch.parameterSet = tool.matchingParam;
|
|
mMatch.loadShapeModel(tool.modelPath);
|
mMatch.detectShapeModel();
|
|
tmpResult.matchingResult = mMatch.tResult;
|
|
break;
|
|
case ToolType.Screw:
|
|
tmpResult.screwResult = new ScrewResult();
|
mScrew.mImage = image;
|
mScrew.SetPara(tool.screwParam);
|
mScrew.Run();
|
tmpResult.screwResult = mScrew.mScrewResult;
|
|
break;
|
}
|
|
return tmpResult;
|
}
|
|
}
|
}
|